LMS OpenAPI generation
Problem¶
CMS publishes an OpenAPI document for its API via apps/cms/src/lib/api/openapi/generate.ts. LMS has a small API surface (webhooks, impersonation, asset proxies, NextAuth) but no equivalent contract, so external integrators have to read the source.
This ticket is low priority but cheap once T-003 (error contract) lands, because the shared error/code enum makes response schemas trivial to express.
Proposal¶
- Add
apps/lms/src/lib/api/openapi/generate.tsmodeled on the CMS version. - Register Zod schemas (auth payloads, revalidate payload, error responses) with the OpenAPI registry already used in
apps/lms/src/schemas/. - Add an npm script
openapi:generatethat writesapps/lms/public/openapi.json. - Wire into
predev/ CI build so the file is regenerated when schemas change. - Document the endpoint in apps/lms/docs/.
Acceptance criteria¶
-
npm run openapi:generate --workspace apps/lmsproduces a valid OpenAPI 3.x document atapps/lms/public/openapi.yaml. - Document includes every LMS route handler under
apps/lms/src/app/api/**(excluding deliberate exclusions). - Generation is guarded in CI via
openapi-sync.test.ts(runs underturbo run test:coverage, same pattern as CMS). -
npm run checkpasses.
Out of scope¶
- Adding OpenAPI for server actions (actions are internal transport per standing decision).
Notes / decisions log¶
- 2026-05-24: Ticket created from monorepo audit.
- 2026-05-25: Implemented on existing scaffolding (
scripts/openapi-generate.ts,src/schemas/openapi-registry.ts,/admin/api-docsSwagger UI). Output format ispublic/openapi.yaml(not JSON; matches CMS and Swagger UI). CI guard follows CMS:tests/unit/openapi-sync.test.tscompares committed YAML tobuildOpenApiYaml()— no change tonpm run checkor.github/workflows/ci.yml. Addedopenapi-coverage.test.tsfor route registration drift. Documented exclusions:/api/auth/*,/api/test/*. Error envelope usesApiErrorEnvelope(error,code,issues?) per T-003. Reference doc:apps/lms/docs/reference/openapi.md.