feat: comprehensive api documentation with OpenAPI/Swagger spec - #38
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The project previously documented its API only as a small table in the README — no machine-readable contract, no request/response schemas, no error codes, and no way to interactively explore or test the endpoints.
This PR adds a complete OpenAPI 3.0.3 specification generated from the existing shared TypeScript contracts, serves it through interactive Swagger UI at
/api-docs, and exposes the raw spec at/api-docs/openapi.jsonfor Postman / Insomnia import and client codegen. It also corrects one error-contract bug so the documented behavior is truthful: invalid leaderboard query parameters now return a clean400instead of leaking a raw validation dump as a500.Highlights:
docs/openapi.yaml— all 6 endpoints, 18 component schemas, 5 query parameters, real examples, and documented400/500error responses.Related Issue
Closes: #32
Change Type (select all that apply)
500→400on invalid query params)Real Behavior Proof
Built and ran the compiled server (
node backend/dist/src/server.js):Swagger UI is live
Machine-readable spec serves and parses
Invalid leaderboard query now returns 400 (was 500)
Invalid wallet address still returns 400
API keeps strict security headers (helmet CSP unaffected by the docs route)
All internal spec references resolve
Validation
npm run typechecknpm run lint --workspace backendnpm run buildnpm testnode backend/dist/src/server.jsChecklist
400,500) documentedcategory,cursor,limit,page,sort)/api-docstypecheck,lint,build, andtestall pass