Skip to content

fix: move OpenAPI spec generation to build time#13207

Merged
EurFelux merged 2 commits intomainfrom
fix/api-docs
Mar 4, 2026
Merged

fix: move OpenAPI spec generation to build time#13207
EurFelux merged 2 commits intomainfrom
fix/api-docs

Conversation

@EurFelux
Copy link
Copy Markdown
Collaborator

@EurFelux EurFelux commented Mar 4, 2026

What this PR does

Before this PR:

Swagger UI at /api-docs showed "No operations defined in spec!" because swagger-jsdoc attempted to scan .ts source files at runtime, but in the bundled Electron app (compiled into a single out/main/index.js), the source files are unavailable. Additionally, GET / only listed the health endpoint.

4d4dfe0fb70719c13c8ac25da99e39d6 f8616a00a6f1749e9f728ab652c3192d

After this PR:

  • OpenAPI spec is generated at build time via pnpm generate:openapi, producing a static openapi-spec.json that is imported at runtime
  • Swagger UI correctly displays all 17 API operations
  • GET / lists all available API endpoints
  • MCP proxy endpoint (/v1/mcps/:server_id/mcp) now has swagger documentation
  • CI checks that the committed spec stays in sync with source annotations via pnpm openapi:check
24ddfab2fa635fd63c8452bfc39f8b3f 6a186be4cf9213d9bc9ac8177c566de1

Why we need it and why it was done in this way

The following tradeoffs were made:

  • The generated openapi-spec.json is committed to the repo so that typecheck works without running the generator first. A --check mode verifies it stays in sync with annotations.
  • swagger-jsdoc is moved to devDependencies since it's only used at build time, reducing the production bundle size.

The following alternatives were considered:

  • Using require() instead of import to avoid typecheck dependency on the generated file — rejected because import is cleaner and the file is committed anyway.
  • Gitignoring the generated file and regenerating in CI — rejected because it adds unnecessary CI complexity and the file serves as a reviewable API surface.

Breaking changes

None.

Special notes for your reviewer

  • The openapi:check script does a semantic JSON comparison (parse + stringify both sides) so that Biome formatting differences don't cause false failures.
  • The MCP proxy route uses router.all() in Express but is documented as post: in the swagger annotation since all: is not a valid OpenAPI 3.0 operation verb.

Checklist

Release note

Fix API documentation page (`/api-docs`) showing "No operations defined in spec!" by moving OpenAPI spec generation to build time. The root endpoint (`GET /`) now lists all available API endpoints.

EurFelux and others added 2 commits March 4, 2026 18:04
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]>
Copy link
Copy Markdown
Collaborator

@vaayne vaayne left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@EurFelux
Copy link
Copy Markdown
Collaborator Author

EurFelux commented Mar 4, 2026

Note

This comment was translated by Claude.

Agents-related endpoints are now exposed, please consider whether this meets expectations.


Original Content agents相关端点现在也会暴露出来,需要考虑一下是否符合预期

@EurFelux
Copy link
Copy Markdown
Collaborator Author

EurFelux commented Mar 4, 2026

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相关端点应该也没什么问题。

@EurFelux EurFelux merged commit 7f24cd0 into main Mar 4, 2026
23 checks passed
@EurFelux EurFelux deleted the fix/api-docs branch March 4, 2026 11:27
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.

3 participants