Add Swagger/OpenAPI API docs (swagger-ui + swagger-autogen) #27
Reference in New Issue
Block a user
No description provided.
Delete Branch "feature/swagger-docs"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Adds interactive OpenAPI 3.0 / Swagger documentation for the entire REST API, generated directly from the route definitions so it stays in lock-step with the code.
swagger-autogenwalks the Express mount chain fromsrc/app.jsand emits a fully-qualified spec (/api/v1/...).swagger-ui-expressserves it as browsable, try-it-out docs.What you get
/api/docs/api/docs.jsonCoverage: 51 paths / 64 operations, every one tagged, summarized, and documented with parameters, request body, security requirement, and the response codes it actually returns.
Changes
Dependencies (
server/package.json)swagger-ui-express— runtime (ships in the Docker image via--omit=dev)swagger-autogen— dev-onlynpm run swaggerGenerator —
server/swagger/swagger.jscookieAuth(theuomm_tokensession cookie) andbearerAuth(mobile access-token JWT).Per-endpoint annotations —
#swagger.*comments added next to every route (auth,mobile,sso,public,admin, plus/api/health). Response codes were taken from the controllers, not guessed:400validation,401/403auth,404,409conflicts,429rate-limits,302SSO redirects,502mail failure, and multipart for image uploads.Wiring —
server/src/app.jsserves/api/docsand/api/docs.json, guarded so a missing spec logs a warning and disables docs instead of crashing.Docs —
README.mdgains an "API documentation (Swagger)" section (URLs, how to Authorize in the UI, regeneration command) plus tech-stack and project-structure entries.Regenerating the spec
After adding or changing a route:
Verification
/api/docs.json-> 200 (OpenAPI 3.0.0),/api/docs/-> 200 (UI renders),/api/health-> 200.node -c.Reviewer note
Response codes reflect what the handlers actually return. The request/response body shapes in the component schemas are reconstructed from the validators and controllers — worth a glance in the UI to confirm field names match the DB columns exactly before merging.
🤖 Generated with Claude Code