Skip to content

Generate and validate OpenAPI spec against actually-served routes #358

@thlpkee20-wq

Description

@thlpkee20-wq

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
    • npm test
  • 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

Metadata

Metadata

Assignees

Labels

APIStellar WaveIssues in the Stellar wave programbackenddocumentationImprovements or additions to documentation

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions