feat: OpenAPI documentation with Swagger UI #85

Merged
Sebi merged 3 commits from feat/api-docs into main 2026-11-22 14:47:23 +00:00
Owner

Stacked on #83.

  • Generated, not hand-written: apidocs.go lists every /api/v1 route with summary, tag, permission, session-only flag, request and response type. openapi.go turns the Go types into OpenAPI 3.1 schemas by reflection: json tags, pointers as nullable, uuid/time formats, and binding limits (required, max/min → maxLength/maxItems/maximum). Monitor config shapes per type are included as components.
  • Can't drift: TestEveryRouteIsDocumented fails for undocumented routes and for documented routes that no longer exist; TestOpenAPIDocument checks that all $refs resolve and required fields exist, plus spot checks.
  • Swagger UI (swagger-ui-dist 5.35.1, pinned) at /api/docs, served from our assets (works offline/self-hosted); "Try it out" uses the browser session and sends the CSRF header. /api/openapi.json is public. Linked from settings and the API token page.
  • Security schemes: bearer API token (ust_…) and session cookie; session-only routes are marked.
  • Swagger was chosen over swaggo annotations (comment noise on every handler) and a hand-written file (drifts).

Closes #84

🤖 Generated with Claude Code

https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3

Stacked on #83. - **Generated, not hand-written:** `apidocs.go` lists every `/api/v1` route with summary, tag, permission, session-only flag, request and response type. `openapi.go` turns the Go types into OpenAPI 3.1 schemas by reflection: json tags, pointers as nullable, uuid/time formats, and `binding` limits (required, max/min → maxLength/maxItems/maximum). Monitor config shapes per type are included as components. - **Can't drift:** `TestEveryRouteIsDocumented` fails for undocumented routes and for documented routes that no longer exist; `TestOpenAPIDocument` checks that all $refs resolve and required fields exist, plus spot checks. - **Swagger UI** (swagger-ui-dist 5.35.1, pinned) at `/api/docs`, served from our assets (works offline/self-hosted); "Try it out" uses the browser session and sends the CSRF header. `/api/openapi.json` is public. Linked from settings and the API token page. - Security schemes: bearer API token (`ust_…`) and session cookie; session-only routes are marked. - Swagger was chosen over swaggo annotations (comment noise on every handler) and a hand-written file (drifts). Closes #84 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
Sebi added this to the M6 Admin UI milestone 2026-11-22 12:03:18 +00:00
Sebi changed target branch from feat/checker-activity to main 2026-11-22 12:52:23 +00:00
Sebi added 3 commits 2026-11-22 12:52:23 +00:00
Refs #82

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
feat: show which checker ran a check and what it is doing
ci / image (pull_request) Successful in 4m31s
ci / lint (pull_request) Successful in 4m38s
ci / build (pull_request) Successful in 6m33s
ci / test (pull_request) Successful in 8m27s
0c2155fdc2
Every recent check on a monitor page names and links the checker
instance that ran it. The checker page shows whether it is active, its
version, the checks it runs right now and has queued, and the viewer's
latest results on it, refreshing every five seconds. Platform checkers
serve all organizations, so other organizations' work appears only as a
count. Checks in progress are tracked in Redis between handing out a job
and receiving its result.

Closes #82

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
feat(api): OpenAPI documentation with Swagger UI
ci / lint (pull_request) Successful in 12m12s
ci / image (pull_request) Successful in 2m22s
ci / build (pull_request) Successful in 6m46s
ci / test (pull_request) Successful in 14m8s
6d3b1dea5d
/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
Sebi merged commit 12c642bf49 into main 2026-11-22 14:47:23 +00:00
Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: ZB-Server/uptimesebi#85