feat: serve OpenAPI spec at /api/v1/openapi.json
Registers a handler that serves the embedded OpenAPI 3.0 spec (compiled into the binary via oapi-codegen) at a browseable endpoint. Uses gen.GetSwagger() to deserialize the embedded base64+gzip spec and returns it as JSON. 46 paths, 42 schemas — agents and humans can now introspect the full API surface without reading Go source.
This commit is contained in:
@@ -159,6 +159,7 @@ func NewHandler(ctx context.Context, pool *db.Pool, cfg config.Config) http.Hand
|
||||
// /api/v1/executions/{id}/logs — streamed command output, no schema type
|
||||
// /api/v1/learning/timeline — derived view, no backing schema type
|
||||
// /api/v1/learning/trend — derived view, no backing schema type
|
||||
// /api/v1/openapi.json — API spec (embedded in binary), self-service
|
||||
//
|
||||
// See .agents/dev/CONTRIBUTING.md §OpenAPI codegen for the policy.
|
||||
|
||||
@@ -296,6 +297,17 @@ func NewHandler(ctx context.Context, pool *db.Pool, cfg config.Config) http.Hand
|
||||
r.With(combinedAuth(cfg, false)).Get("/api/v1/learning/timeline", s.serveLearningTimeline)
|
||||
r.With(combinedAuth(cfg, false)).Get("/api/v1/learning/trend", s.serveLearningTrend)
|
||||
|
||||
// Serve the OpenAPI spec at a browseable endpoint (agents + humans)
|
||||
r.Get("/api/v1/openapi.json", func(w http.ResponseWriter, req *http.Request) {
|
||||
swagger, err := gen.GetSwagger()
|
||||
if err != nil {
|
||||
writeProblem(w, req, http.StatusInternalServerError, "failed to load spec", "")
|
||||
return
|
||||
}
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
json.NewEncoder(w).Encode(swagger)
|
||||
})
|
||||
|
||||
// Mount MCP at /mcp (plan R3-10)
|
||||
nomosAgentID := uuid.Nil
|
||||
if cfg.NomosAgentID != "" {
|
||||
|
||||
Reference in New Issue
Block a user