-
Notifications
You must be signed in to change notification settings - Fork 454
feat: add OpenAPI tags for improved SDK generation and API organization #655
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add OpenAPI tags for improved SDK generation and API organization #655
Conversation
Implements OpenAPI tags definition via Huma's api.OpenAPI().Tags to improve: - SDK generation with proper service grouping (e.g., serversService, publishService) - API documentation organization in tools like Scalar UI, Swagger UI Changes: - Add tag metadata (name + description) in internal/api/router/router.go - Update reference OpenAPI spec (docs/reference/api/openapi.yaml) to match - Define 6 tags: servers, publish, auth, admin, health, ping This follows the code-first approach where Huma auto-generates the OpenAPI spec from Go code, ensuring the reference spec stays in sync via compliance tests. Closes: modelcontextprotocol#644
|
@rdimitrov Hey! I’m not sure if manually editing the OpenAPI file is a good idea. I wrote a small Go script that exports the OpenAPI spec without running the server directly. I also added (just for testing) a Scalar UI setup (similar to Swagger UI) and a generated TypeScript SDK. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for contributing this! 🙏
Overall the approach is good, but I think what's necessary is the changes that are:
- in the router.go (technically speaking the tags are already there, but they lack descriptions, makes sense to have it)
- In the openapi.yaml file these make sense -
tags:
- name: servers
description: Operations for discovering and retrieving MCP servers
- name: publish
description: Operations for publishing MCP servers to the registryalong with adding them to the corresponding server and publisher endpoints via tags: [servers] and tags: [publish].
I think the rest of the changes in this file are not necessary, i.e. we don't need these tags because we don't have handlers for them in the reference schema (they are implementation specific):
- name: auth
description: Authentication and authorization endpoints
- name: admin
description: Administrative operations (restricted access)
- name: health
description: Health check and system status endpoints
- name: ping
description: Simple connectivity test endpointRemove auth, admin, health, and ping tags from the OpenAPI specification as these are internal/operational endpoints rather than core public API endpoints for discovering and using MCP servers.
Remove auth, admin, health, and ping tags from the router's OpenAPI tag definitions to match the OpenAPI spec. These are internal/operational endpoints rather than core public API endpoints.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! 🙏
Summary
Adds OpenAPI tags to improve SDK generation and API documentation organization, as discussed in #644.
Changes
internal/api/router/router.gousing Huma'sapi.OpenAPI().Tagsdocs/reference/api/openapi.yamlto match the generated specBenefits
serversService,publishService)Testing
go test -v ./internal/api -run TestOpenAPIEndpointComplianceRelated
Closes #644