Skip to content

feat(openapi): move spec to a module and add a route-drift guard#88

Merged
mikewheeleer merged 1 commit into
StableRoute-Org:mainfrom
Jagadeeshftw:enhancement/openapi-31-single-source
Jun 24, 2026
Merged

feat(openapi): move spec to a module and add a route-drift guard#88
mikewheeleer merged 1 commit into
StableRoute-Org:mainfrom
Jagadeeshftw:enhancement/openapi-31-single-source

Conversation

@Jagadeeshftw

Copy link
Copy Markdown
Contributor

Summary

The GET /api/v1/openapi.json handler previously returned a hand-written inline literal that omitted /api/v1/config. This moves the spec into a dedicated, typed module and adds a guard so docs can never silently drift from the routes.

  • New src/openapi.ts exports a typed openApiSpec const (openapi: "3.0.3", existing info, complete paths). All previously-empty {} operation objects now carry real summary strings, and the missing /api/v1/config (get/patch) path is added.
  • src/index.ts imports the module; the handler now does res.json(openApiSpec).
  • src/__tests__/openapi.test.ts asserts openapi === "3.0.3" and info.version === "1.0.0", plus a route-drift guard: it walks the Express router stack, converts :param{param}, and asserts every registered /api/v1/... path (skipping /health and /api/v1/openapi.json) is a key in the spec.
  • README documents the spec module and drift guard.

Closes #79

Tests

PASS src/__tests__/openapi.test.ts
Tests:       3 passed, 3 total

Security notes: No new attack surface; the handler serves a static documentation object and the drift guard only reads route metadata in tests.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@Jagadeeshftw Jagadeeshftw force-pushed the enhancement/openapi-31-single-source branch from b28019d to e88b1b1 Compare June 24, 2026 02:18
@mikewheeleer

Copy link
Copy Markdown
Contributor

good move putting the OpenAPI spec in a module with validation. lgtm 🙌

@mikewheeleer mikewheeleer merged commit 2549c4e into StableRoute-Org:main Jun 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Generate the OpenAPI document from a single source of truth

2 participants