docs(api): add OpenAPI spec + Swagger UI for Node API (bounty #502)#578
docs(api): add OpenAPI spec + Swagger UI for Node API (bounty #502)#578Scottcjn merged 1 commit intoScottcjn:mainfrom
Conversation
lustsazeus-lab
left a comment
There was a problem hiding this comment.
Code Review: OpenAPI Spec for RustChain Node API
Summary
Good implementation of OpenAPI 3.0 specification documenting the RustChain node API endpoints. The spec is well-structured and covers both public and authenticated endpoints.
Strengths
- Well-organized endpoints with clear summaries and descriptions
- Proper use of OpenAPI 3.0 standards
- Good examples for most endpoints
- Proper security scheme definition for authenticated endpoints
- Covers major public API endpoints (health, epoch, miners, stats, etc.)
Suggestions for Improvement
-
Incomplete Response Schemas - Several authenticated endpoints lack response schemas:
/attest/submit- Missing response schema for success/failure cases/wallet/transfer/signed- Missing response schema/wallet/transfer- Missing response schema (should include tx_hash or similar)/withdraw/request- Missing response schema
-
Empty Array Example - The
/api/hall_of_fameendpoint showstop_miners: []but should include example miner objects to show the expected structure. -
Missing Error Responses - Consider adding error responses (400, 401, 500) for better API contract documentation.
-
Request Body Refs - For authenticated endpoints with request bodies, consider using
$refcomponents for reusability.
Verification
- OpenAPI YAML structure is valid
- Security schemes properly defined
- Server URL correctly points to rustchain.org
Recommendation
Approve - The spec is functional and provides good API documentation.
Code review for bounty #73 - 5 RTC
lustsazeus-lab
left a comment
There was a problem hiding this comment.
Code Review: OpenAPI Specification
Good implementation of the OpenAPI 3.0 specification for RustChain Node API.
Strengths:
- Comprehensive coverage - Documents 14 endpoints including both public and authenticated operations
- Proper OpenAPI 3.0.3 structure - Uses correct schema references, tags, and server definitions
- Good documentation - Each endpoint has clear summary and description
- Examples provided - Request/response examples help API consumers
- Security awareness - Notes self-signed TLS certificate and authentication requirements
- Version tracking - Uses semantic versioning (2.2.1)
Suggestions for Improvement:
- Response schemas - Add explicit
components/schemasdefinitions for all response types instead of just examples - Error responses - Document 4xx/5xx error responses (e.g., 401 for unauthorized, 404 for not found)
- Parameter descriptions - Add
descriptionfield to path parameters (e.g.,miner_id) - Authentication details - For authenticated endpoints, specify the security scheme in
components/securitySchemes - Rate limiting - Document any rate limits if applicable
- Schema validation - Consider adding
requiredfield to schema properties
Minor Issues:
- The
/balanceendpoint uses query parameter but the spec shows it as a path parameter - Missing
descriptionon some inline schemas
Verdict: Approve ✅
The specification is well-structured and provides significant value for API consumers. The suggestions above are enhancements rather than blockers.
Description
This PR addresses bounty issue #502 by adding comprehensive OpenAPI/Swagger documentation for the RustChain node API.
Developers building tools (wallets, dashboards, bots) can now reference endpoint contracts without reverse-engineering server internals.
Changes Included
docs/api/openapi.yaml(OpenAPI 3.0 spec)docs/api/swagger.html(self-contained Swagger UI page loading local spec)Endpoints Documented
Public:
GET /healthGET /readyGET /epochGET /api/minersGET /api/statsGET /api/hall_of_fameGET /api/fee_poolGET /balance?miner_id=XGET /lottery/eligibility?miner_id=XGET /explorerAuthenticated:
POST /attest/submitPOST /wallet/transfer/signedPOST /wallet/transferPOST /withdraw/requestVerification
rustchain.orgresponses (/health,/epoch,/api/fee_pool)Closes #502