feat: serve OpenAPI spec at /api/v1/openapi.json
Some checks failed
ci / build-test (push) Has been cancelled
ci / docker-build (push) Has been cancelled
ci / web (push) Has been cancelled
Desktop App / Build Linux (amd64) (push) Has been cancelled
Desktop App / Attach to Release (push) Has been cancelled

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:
2026-08-12 17:48:10 +02:00
parent 53823595de
commit d79b0862bd
3 changed files with 12 additions and 28 deletions

View File

@@ -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 != "" {