Skip to content

Commit cce5e5d

Browse files
authored
feat: add OpenAPI tags for improved SDK generation and API organization (#655)
## Summary Adds OpenAPI tags to improve SDK generation and API documentation organization, as discussed in #644. ## Changes - **Go Code**: Define tag metadata (name + description) in `internal/api/router/router.go` using Huma's `api.OpenAPI().Tags` - **Reference Spec**: Update `docs/reference/api/openapi.yaml` to match the generated spec - **Tags Added**: servers, publish, auth, admin, health, ping ## Benefits - ✅ Improved SDK generation with proper service grouping (e.g., `serversService`, `publishService`) - ✅ Better API documentation organization in Scalar UI, Swagger UI, and other tools - ✅ Code-first approach ensures reference spec stays in sync via compliance tests ## Testing - ✅ Compliance test passes: `go test -v ./internal/api -run TestOpenAPIEndpointCompliance` - ✅ All 4 reference endpoints verified as implemented - ✅ TypeScript SDK regenerated successfully with proper tag-based grouping ## Related Closes #644
1 parent 1a7cd97 commit cce5e5d

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

docs/reference/api/openapi.yaml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,16 @@ info:
1111
name: MIT
1212
identifier: MIT
1313

14+
tags:
15+
- name: servers
16+
description: Operations for discovering and retrieving MCP servers
17+
- name: publish
18+
description: Operations for publishing MCP servers to the registry
19+
1420
paths:
1521
/v0/servers:
1622
get:
23+
tags: [servers]
1724
summary: List MCP servers
1825
description: Returns a list of all registered MCP servers
1926
parameters:
@@ -41,6 +48,7 @@ paths:
4148
$ref: '#/components/schemas/ServerList'
4249
/v0/servers/{serverName}/versions:
4350
get:
51+
tags: [servers]
4452
summary: List all versions of an MCP server
4553
description: Returns all available versions for a specific MCP server, ordered by publication date (newest first)
4654
parameters:
@@ -70,6 +78,7 @@ paths:
7078
example: "Server not found"
7179
/v0/servers/{serverName}/versions/{version}:
7280
get:
81+
tags: [servers]
7382
summary: Get specific MCP server version
7483
description: Returns detailed information about a specific version of an MCP server. Use the special version `latest` to get the latest version.
7584
parameters:
@@ -106,12 +115,13 @@ paths:
106115
example: "Server not found"
107116
/v0/publish:
108117
post:
118+
tags: [publish]
109119
summary: Publish MCP server (Optional)
110120
description: |
111121
Publish a new MCP server to the registry or update an existing one.
112-
122+
113123
**Note**: This endpoint is optional for registry implementations. Read-only registries may not provide this functionality.
114-
124+
115125
Authentication mechanism is registry-specific and may vary between implementations.
116126
security:
117127
- bearerAuth: []

internal/api/router/router.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,18 @@ func NewHumaAPI(cfg *config.Config, registry service.RegistryService, mux *http.
139139
// Create a new API using humago adapter for standard library
140140
api := humago.New(mux, humaConfig)
141141

142+
// Add OpenAPI tag metadata with descriptions
143+
api.OpenAPI().Tags = []*huma.Tag{
144+
{
145+
Name: "servers",
146+
Description: "Operations for discovering and retrieving MCP servers",
147+
},
148+
{
149+
Name: "publish",
150+
Description: "Operations for publishing MCP servers to the registry",
151+
},
152+
}
153+
142154
// Add metrics middleware with options
143155
api.UseMiddleware(MetricTelemetryMiddleware(metrics,
144156
WithSkipPaths("/health", "/metrics", "/ping", "/docs"),

0 commit comments

Comments
 (0)