feat(api): OpenAPI documentation with Swagger UI
/api/openapi.json is generated from a table of endpoints and the Go types the handlers bind and return, including the limits of their binding tags, so the document follows the code. A test fails for routes missing from the table or documented but not served. /api/docs shows it with Swagger UI from our own assets, usable without internet access; "Try it out" works with the browser session. Closes #84 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
This commit is contained in:
1 parent
0c2155fdc2
commit
6d3b1dea5d
18 files changed
+1207
-297
No files matched your search
@@ -5,3 +5,15 @@ var LookupTXT = &lookupTXT
|
||||
|
||||
// AuditActions exposes the audited routes to tests.
|
||||
var AuditActions = auditActions
|
||||
|
||||
// DocumentedRoutes lists the routes in the OpenAPI table.
|
||||
func DocumentedRoutes() []string {
|
||||
out := make([]string, len(endpoints))
|
||||
for i, e := range endpoints {
|
||||
out[i] = e.method + " " + e.path
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
// OpenAPI builds the OpenAPI document.
|
||||
func OpenAPI() map[string]any { return buildOpenAPI("https://uptime.example") }
|
||||
Reference in new issue
Block a user