OpenAPI Workflow
Goal
The OpenAPI document is not decorative. In this project it is part of the runtime contract workflow between backend and frontend.
Canonical files:
docs/openapi.yamldocs/api-contract.snapshotobsidian-admin-vue/src/service/api/generated
Source of truth chain
The intended chain is:
- Laravel routes and controllers
- documented OpenAPI operations and schemas
- backend contract snapshot checks
- frontend generated SDK and typings
- frontend app-facing API facades
If any link in that chain drifts, the CI gates are supposed to fail.
Backend commands
For backend contract work, use:
php artisan openapi:lint
php artisan api:contract-snapshot
php artisan api:contract-snapshot --writeComposer shortcuts:
composer run openapi:lint
composer run contract:check
composer run contract:writeFrontend regeneration path
After backend OpenAPI changes, regenerate frontend artifacts in:
obsidian-admin-vue
Commands:
pnpm api:types
pnpm openapi:client:official
pnpm typecheck:apiFor release-grade confidence:
pnpm check:ciWhat to update when you add an endpoint
At minimum, check these items:
- route exists and is covered by tests
- OpenAPI operation exists
- request schema is specific enough to generate useful frontend types
- response schema is specific enough to avoid
unknowneverywhere - examples are added for high-value or non-obvious endpoints
- frontend generated SDK stays clean after regeneration
What not to do
Do not treat ApiResponse alone as sufficient documentation for important endpoints.
High-value endpoints should describe field-level payloads, especially for:
- auth session flows
- user / role / permission CRUD
- tenant / organization / team management
- audit logs and audit policies
- feature flags and CRUD schema payloads
CI gates
Representative backend checks:
tests/Feature/OpenApiContractTest.phptests/Feature/OpenApiLintCommandTest.phptests/Feature/ApiContractSnapshotCommandTest.php
Representative frontend checks:
obsidian-admin-vue/scripts/api-client-contract.mjsobsidian-admin-vue/scripts/api-architecture-check.mjsobsidian-admin-vue/docs/compatibility-matrix.md
Rule of thumb
If a backend change can break generated frontend behavior, it is not "just a backend refactor".
Update the OpenAPI contract, regenerate the frontend SDK, and let the gates prove the change is safe.