feat(openapi): move spec to a module and add a route-drift guard#88
Merged
mikewheeleer merged 1 commit intoJun 24, 2026
Conversation
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
b28019d to
e88b1b1
Compare
Contributor
|
good move putting the OpenAPI spec in a module with validation. lgtm 🙌 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The
GET /api/v1/openapi.jsonhandler 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.src/openapi.tsexports a typedopenApiSpecconst (openapi: "3.0.3", existinginfo, completepaths). All previously-empty{}operation objects now carry realsummarystrings, and the missing/api/v1/config(get/patch) path is added.src/index.tsimports the module; the handler now doesres.json(openApiSpec).src/__tests__/openapi.test.tsassertsopenapi === "3.0.3"andinfo.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/healthand/api/v1/openapi.json) is a key in the spec.Closes #79
Tests
Security notes: No new attack surface; the handler serves a static documentation object and the drift guard only reads route metadata in tests.