Skip to content

Conversation

@Patrick-Ehimen
Copy link
Contributor

Summary

Implements automatic documentation generation for the Merkle API using OpenAPI/Swagger specification.

Resolves #335

Changes

1. OpenAPI Specification

  • Created specs/merkle-api.yaml with complete API documentation for:
    • POST /api/create - Create Merkle airdrop campaigns
    • GET /api/eligibility - Check recipient eligibility
    • GET /api/validity - Validate campaign IPFS CID

2. Auto-Generation CLI Command

  • Added cli/commands/autogen/merkle.ts for generating docs from spec
  • Integrated into main autogen workflow
  • Follows same pattern as existing GraphQL autogen

3. Docusaurus Configuration

  • Installed docusaurus-plugin-openapi-docs and docusaurus-theme-openapi-docs
  • Configured plugin to generate docs from OpenAPI spec
  • Added docItemComponent: "@theme/ApiItem" for proper SSG support
  • Added theme to themes array

4. Auto-Generated Documentation

  • API overview page
  • Individual endpoint pages with request/response schemas
  • Tag-based organization (Campaign, Verification)
  • Interactive API explorer with Swagger UI

Benefits

  • Single source of truth: OpenAPI spec is the only file to maintain
  • Always up-to-date: Auto-regenerates on build via bun run cli/index.ts autogen
  • Consistent formatting: Professional, standardized API docs
  • Interactive: Built-in API explorer for testing endpoints
  • Reduced maintenance: No more manual MDX file updates

Testing

Build tested successfully:

npx tsx cli/index.ts autogen merkle  # Generates docs
npx docusaurus build                  # SSG build passes ✅

Related Issues

Future Work

The OpenAPI spec is currently maintained manually in this repo. For 100% automation, see merkle-api#47 which proposes adding utoipa to the Rust backend to auto-generate the spec from code.

Implements automatic documentation generation for the Merkle API using OpenAPI/Swagger specification, resolving issue sablier-labs#335.

## Changes

- Created OpenAPI specification (`specs/merkle-api.yaml`) for all 3 Merkle API endpoints:
  - POST /api/create - Create Merkle airdrop campaigns
  - GET /api/eligibility - Check recipient eligibility
  - GET /api/validity - Validate campaign IPFS CID

- Added CLI command (`cli/commands/autogen/merkle.ts`) for auto-generating docs
  - Integrated into main autogen workflow
  - Follows same pattern as existing GraphQL autogen

- Configured Docusaurus with OpenAPI plugin:
  - Installed docusaurus-plugin-openapi-docs and docusaurus-theme-openapi-docs
  - Added plugin configuration to config/plugins.ts
  - Added theme to docusaurus.config.ts
  - Set docItemComponent to @theme/ApiItem for proper SSG support

- Auto-generated documentation files:
  - API overview page
  - Individual endpoint pages with request/response schemas
  - Tag pages for API organization

## Benefits

- Single source of truth for API documentation (the OpenAPI spec)
- Automatic regeneration on build via autogen command
- Consistent, professional formatting
- Interactive API explorer (Swagger UI)
- Reduced manual maintenance burden

## Related Issues

- Closes sablier-labs#335
- Related: sablier-labs/merkle-api#47 (future full automation from Rust code)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Automatically generate the Merkle API documentation using Swagger or similar tool

1 participant