fix: move OpenAPI spec generation to build time#13207
Merged
Conversation
Swagger UI showed "No operations defined in spec!" because swagger-jsdoc scanned .ts source files at runtime, but they don't exist in the bundled Electron app. - Create build-time script to generate static openapi-spec.json - Add --check mode for CI to verify spec is in sync with annotations - Add missing swagger annotation for MCP proxy endpoint - Expand GET / to list all available API endpoints - Move swagger-jsdoc from dependencies to devDependencies Co-Authored-By: Claude Opus 4.6 <[email protected]>
Add openapi:check step to basic-checks job to ensure the committed openapi-spec.json stays in sync with swagger annotations in source. Co-Authored-By: Claude Opus 4.6 <[email protected]>
DeJeune
approved these changes
Mar 4, 2026
Collaborator
Author
|
Note This comment was translated by Claude. Agents-related endpoints are now exposed, please consider whether this meets expectations. Original Contentagents相关端点现在也会暴露出来,需要考虑一下是否符合预期 |
Collaborator
Author
|
Note This comment was translated by Claude. Given that we didn't previously distinguish between requests from inside or outside the application, exposing agents-related endpoints should be fine. Original Content考虑到之前也没有区分来自应用内部/外部的请求,暴露agents相关端点应该也没什么问题。 |
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.
What this PR does
Before this PR:
Swagger UI at
/api-docsshowed "No operations defined in spec!" becauseswagger-jsdocattempted to scan.tssource files at runtime, but in the bundled Electron app (compiled into a singleout/main/index.js), the source files are unavailable. Additionally,GET /only listed the health endpoint.After this PR:
pnpm generate:openapi, producing a staticopenapi-spec.jsonthat is imported at runtimeGET /lists all available API endpoints/v1/mcps/:server_id/mcp) now has swagger documentationpnpm openapi:checkWhy we need it and why it was done in this way
The following tradeoffs were made:
openapi-spec.jsonis committed to the repo so thattypecheckworks without running the generator first. A--checkmode verifies it stays in sync with annotations.swagger-jsdocis moved todevDependenciessince it's only used at build time, reducing the production bundle size.The following alternatives were considered:
require()instead ofimportto avoid typecheck dependency on the generated file — rejected becauseimportis cleaner and the file is committed anyway.Breaking changes
None.
Special notes for your reviewer
openapi:checkscript does a semantic JSON comparison (parse + stringify both sides) so that Biome formatting differences don't cause false failures.router.all()in Express but is documented aspost:in the swagger annotation sinceall:is not a valid OpenAPI 3.0 operation verb.Checklist
/gh-pr-review,gh pr diff, or GitHub UI) before requesting review from othersRelease note