Description
src/docs/openapi.yaml and src/routes/apiDocs.ts provide API documentation, but the spec is hand-maintained and drifts from the routes actually mounted in src/index.ts (for example several documented endpoints are not wired in). Add a contract test that asserts every path in the OpenAPI spec maps to a real Express route and vice versa.
Requirements and context
- Must be secure, tested, and documented
- Should be efficient and easy to review
- Relevant code:
src/docs/openapi.yaml, src/routes/apiDocs.ts, src/index.ts
- The docs route must not expose the spec to unauthenticated users in production
Suggested execution
- Fork the repo and create a branch
git checkout -b docs/openapi-route-parity
- Implement changes
- Parse
openapi.yaml and enumerate the Express route stack in createApp
- Add a test asserting parity between documented and served paths
- Update the spec to match the mounted routes
- Validate security and correctness assumptions
Test and commit
- Run tests
- Cover edge cases
- Path present in spec but unmounted, route mounted but undocumented, version-prefix handling
- Include test output and notes
Example commit message
docs: enforce OpenAPI/route parity with a contract test
Guidelines
- Minimum 95 percent test coverage
- Clear documentation
- Timeframe: 96 hours
Description
src/docs/openapi.yamlandsrc/routes/apiDocs.tsprovide API documentation, but the spec is hand-maintained and drifts from the routes actually mounted insrc/index.ts(for example several documented endpoints are not wired in). Add a contract test that asserts every path in the OpenAPI spec maps to a real Express route and vice versa.Requirements and context
src/docs/openapi.yaml,src/routes/apiDocs.ts,src/index.tsSuggested execution
git checkout -b docs/openapi-route-parityopenapi.yamland enumerate the Express route stack increateAppTest and commit
npm testExample commit message
docs: enforce OpenAPI/route parity with a contract testGuidelines