Start the dev server and open:
http://localhost:3000/docs ← Swagger UI (interactive)
http://localhost:3000/docs.json ← Raw JSON spec (for client generation)
src/openapi.yaml
The spec is loaded at runtime from that file, so edits are reflected immediately on the next server restart — no build step needed.
- Implement the route handler in
src/routes/. - Open
src/openapi.yamland add the path underpaths:. - Add or reuse component schemas under
components/schemas:. - Run
npm run validate:spec— must exit 0. - Add at least one test in
src/tests/api.test.tsfor the new endpoint. - Run
npm test— all tests must pass.
npm run validate:specThis checks that src/openapi.yaml is well-formed YAML. For deeper linting
(spec correctness, unused schemas) install @stoplight/spectral-cli:
npx @stoplight/spectral-cli lint src/openapi.yamlnpx openapi-typescript src/openapi.yaml -o src/generated/api.d.tsRe-run this whenever openapi.yaml changes.
Add these steps to your CI pipeline:
- run: npm run validate:spec
- run: npm test