Skip to content

docs(api): add OpenAPI spec + Swagger UI for Node API (bounty #502)#578

Merged
Scottcjn merged 1 commit intoScottcjn:mainfrom
edisonlv:bounty-502-openapi
Mar 5, 2026
Merged

docs(api): add OpenAPI spec + Swagger UI for Node API (bounty #502)#578
Scottcjn merged 1 commit intoScottcjn:mainfrom
edisonlv:bounty-502-openapi

Conversation

@edisonlv
Copy link
Copy Markdown
Contributor

@edisonlv edisonlv commented Mar 4, 2026

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

  • Added docs/api/openapi.yaml (OpenAPI 3.0 spec)
  • Added/updated docs/api/swagger.html (self-contained Swagger UI page loading local spec)

Endpoints Documented

Public:

  • GET /health
  • GET /ready
  • GET /epoch
  • GET /api/miners
  • GET /api/stats
  • GET /api/hall_of_fame
  • GET /api/fee_pool
  • GET /balance?miner_id=X
  • GET /lottery/eligibility?miner_id=X
  • GET /explorer

Authenticated:

  • POST /attest/submit
  • POST /wallet/transfer/signed
  • POST /wallet/transfer
  • POST /withdraw/request

Verification

  • OpenAPI spec validated with swagger tooling
  • Swagger UI renders successfully
  • Live endpoint alignment checked against rustchain.org responses (/health, /epoch, /api/fee_pool)

Closes #502

@github-actions github-actions bot added documentation Improvements or additions to documentation size/M PR: 51-200 lines labels Mar 4, 2026
Copy link
Copy Markdown

@lustsazeus-lab lustsazeus-lab left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

  1. 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
  2. Empty Array Example - The /api/hall_of_fame endpoint shows top_miners: [] but should include example miner objects to show the expected structure.

  3. Missing Error Responses - Consider adding error responses (400, 401, 500) for better API contract documentation.

  4. Request Body Refs - For authenticated endpoints with request bodies, consider using $ref components 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

Copy link
Copy Markdown

@lustsazeus-lab lustsazeus-lab left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review: OpenAPI Specification

Good implementation of the OpenAPI 3.0 specification for RustChain Node API.

Strengths:

  1. Comprehensive coverage - Documents 14 endpoints including both public and authenticated operations
  2. Proper OpenAPI 3.0.3 structure - Uses correct schema references, tags, and server definitions
  3. Good documentation - Each endpoint has clear summary and description
  4. Examples provided - Request/response examples help API consumers
  5. Security awareness - Notes self-signed TLS certificate and authentication requirements
  6. Version tracking - Uses semantic versioning (2.2.1)

Suggestions for Improvement:

  1. Response schemas - Add explicit components/schemas definitions for all response types instead of just examples
  2. Error responses - Document 4xx/5xx error responses (e.g., 401 for unauthorized, 404 for not found)
  3. Parameter descriptions - Add description field to path parameters (e.g., miner_id)
  4. Authentication details - For authenticated endpoints, specify the security scheme in components/securitySchemes
  5. Rate limiting - Document any rate limits if applicable
  6. Schema validation - Consider adding required field to schema properties

Minor Issues:

  • The /balance endpoint uses query parameter but the spec shows it as a path parameter
  • Missing description on 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation size/M PR: 51-200 lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants