feat: Add OpenAPI/Swagger documentation for REST API#816
feat: Add OpenAPI/Swagger documentation for REST API#816strausmann wants to merge 114 commits intoFinsys:mainfrom
Conversation
Do not use the grid layout on mobile but show each tile in a scrollable list instead.
The detailed display of stacks (following x/x/x/x) is too wide for mobile display. So for mobile display only, we limit this information to the total number of stacks.
The dockhand-updater image ships Docker CLI 29.2.1 (API 1.53), which fails on hosts running older Docker daemons (e.g. Synology DSM with Docker 24.0.2 / API 1.43). Every docker command in update.sh returns "client version 1.53 is too new". Query the daemon's API version via /version and pass it as DOCKER_API_VERSION to the updater container env. If the env var is already set on the main container, forward that instead. Fixes Finsys#759
- Add OpenAPI 3.0 specification as typed TypeScript object in src/lib/server/openapi.ts - Add /api/docs endpoint serving the OpenAPI JSON spec (unauthenticated) - Add /api/docs/ui Swagger UI page with layout reset (no sidebar) - Document core endpoints: health, auth, environments, containers, stacks, hawser tokens - Add swagger-ui-dist dependency for interactive API exploration - Register /api/docs as public path (no auth required) Refs Finsys#814 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
strausmann seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
There was a problem hiding this comment.
Pull request overview
This PR introduces an initial OpenAPI 3.0 specification for Dockhand’s REST API and exposes it via new documentation endpoints, including a Swagger UI page for interactive exploration.
Changes:
- Adds a static TypeScript OpenAPI spec (
openapiSpec) describing core API endpoints. - Adds
GET /api/docsto serve the OpenAPI JSON spec. - Adds
/api/docs/uiSwagger UI page intended to be publicly accessible and rendered without the main app layout.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| src/routes/api/docs/ui/+page@.svelte | Adds Swagger UI client page that loads the OpenAPI spec from /api/docs. |
| src/routes/api/docs/ui/+page.server.ts | Adds a server load for the docs UI route (currently informational only). |
| src/routes/api/docs/+server.ts | Adds /api/docs endpoint returning the OpenAPI JSON spec. |
| src/routes/+layout.server.ts | Adds /api/docs to a local PUBLIC_PATHS allowlist used by the layout load. |
| src/lib/server/openapi.ts | Introduces the OpenAPI 3.0 spec object (schemas, paths, security scheme). |
| package.json | Adds swagger-ui-dist and @types/swagger-ui-dist. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Extend Session schema with email, displayName, avatar, provider, permissions - Mark GET /auth/session as public (security: []) - Fix login response: mfaRequired → requiresMfa, add oneOf for MFA/success - Add /api/docs to PUBLIC_PATHS in hooks.server.ts - Remove duplicate Swagger UI CSS injection (fixes 404) - Fix cookie name: session → dockhand_session - Update page.server.ts comment about auth bypass location Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Validates spec structure (version, info, paths, security) - Checks core endpoints are documented - Ensures all paths have HTTP methods and responses Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Document all endpoints across 24 tag groups - Health, Auth, Environments, Containers, Stacks, Git, Images, Networks, Volumes, Prune, Registries, Notifications, Schedules, Users, Roles, Dashboard, Activity, Audit, System, Profile, Config Sets, Hawser, Auto-Update, Logs - Core endpoints with full request/response schemas - Remaining endpoints with summary and response codes - Added reusable $ref parameters and 30+ component schemas Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Merge upstream changes (undici, ws, @types/better-sqlite3) with our additions (swagger-ui-dist, @types/swagger-ui-dist). All dependencies kept, alphabetically sorted.
- package.json: merge both dependency sets (swagger-ui-dist + undici/ws/better-sqlite3) - hooks.server.ts: keep /api/docs in PUBLIC_PATHS with upstream changes
- Verify 100+ paths documented - Check all core endpoint groups (24 tags) - Validate security scheme (cookie name dockhand_session) - Ensure reusable component schemas exist - All operations must have tags, summary, and responses
Note on spec maintenanceThe current OpenAPI spec is a static TypeScript object that must be updated manually when API routes change. This is the pragmatic starting point, but we recognize it's not ideal long-term. Recommended next steps (not part of this PR)
We'd be happy to contribute option 1 (CI validation script) as a follow-up PR if this approach is accepted. |
Test-Plan (after merge)Update# Pull latest Dockhand with OpenAPI
ssh root@100.100.50.40 "docker pull fnsys/dockhand:latest && cd /docker/stacks/dockhand && docker compose up -d"Verify# 1. OpenAPI spec endpoint
curl -sf http://localhost:3000/api/docs \
| python3 -c "import json,sys; d=json.load(sys.stdin); print(f'OpenAPI {d[\"openapi\"]}: {len(d[\"paths\"])} paths')"
# Expected: OpenAPI 3.0.3: 130+ paths
# 2. Swagger UI accessible
curl -sf -o /dev/null -w "HTTP %{http_code}" http://localhost:3000/api/docs/ui
# Expected: HTTP 200
# 3. No auth required for docs
curl -sf http://localhost:3000/api/docs | python3 -c "import json,sys; print('OK')"
# Expected: OK (no 401) |
|
Hi there! Just a friendly ping on this PR. All 8 review comments from the initial review have been addressed in commit Quick summary of what was fixed:
The PR is ready for re-review whenever you have a moment. Happy to make any further adjustments if needed! |
Summary
Adds comprehensive OpenAPI 3.0 documentation for the entire Dockhand REST API — all 130+ endpoints across 24 tag groups.
Endpoints documented (all 130+)
Closes #814. Related: #815, #817
Design Decisions
Files changed
Breaking changes: None