Skip to content

Add OpenAPI spec and integrate vitepress-openapi for API docs#16

Merged
amavashev merged 2 commits intomainfrom
claude/api-reference-generator-t41fC
Mar 12, 2026
Merged

Add OpenAPI spec and integrate vitepress-openapi for API docs#16
amavashev merged 2 commits intomainfrom
claude/api-reference-generator-t41fC

Conversation

@amavashev
Copy link
Copy Markdown
Contributor

Summary

This PR adds the Cycles Budget Authority API OpenAPI specification (v0.1.23) and integrates it with the documentation site using vitepress-openapi for interactive API reference generation.

Key Changes

  • Added OpenAPI specification (public/cycles-protocol-v0.yaml): Complete v0.1.23 protocol definition including:

    • Core reserve/commit/release lifecycle endpoints
    • Optional /decide (preflight checks) and /balances (operator visibility) endpoints
    • /events endpoint for post-only accounting
    • Comprehensive normative sections covering auth, tenancy, idempotency, scope derivation, overdraft reconciliation, and error semantics
    • Support for debt/overdraft model with soft-limit reconciliation
    • Detailed schema definitions for all request/response types
  • Integrated vitepress-openapi:

    • Added vitepress-openapi dependency for rendering interactive API documentation
    • Created spec conversion script (scripts/convert-spec.js) to transform YAML spec to JSON
    • Added API reference route (api/operations/[operationId].md) with dynamic path generation
    • Created custom theme integration (/.vitepress/theme/index.ts) to enable OpenAPI components
  • Updated documentation configuration:

    • Modified .vitepress/config.ts to include OpenAPI sidebar generation and API Reference nav link
    • Updated build pipeline to run spec conversion before vitepress build
    • Added .gitignore entry for generated public/openapi.json
  • Updated build scripts (package.json):

    • Added convert-spec script to generate JSON from YAML
    • Modified build and dev scripts to run spec conversion

Implementation Details

The OpenAPI spec defines a minimal, language-agnostic protocol for deterministic budget governance with:

  • Concurrency-safe reservations and idempotent commits
  • Tenant-scoped authentication and authorization
  • Support for multiple units (USD_MICROCENTS, TOKENS, CREDITS, RISK_POINTS)
  • Overdraft policies (REJECT, ALLOW_IF_AVAILABLE, ALLOW_WITH_OVERDRAFT)
  • Comprehensive error semantics with specific HTTP status codes and error codes
  • Backward-compatible evolution contract starting at v0.1.0 with /v1 paths

The integration enables developers to browse and interact with the API specification directly in the documentation site.

https://claude.ai/code/session_01FL2ggKU9YaFR1uUK53nTMY

claude added 2 commits March 12, 2026 21:50
Integrates the Cycles Protocol OpenAPI spec as an interactive,
Redocly-style API reference rendered natively in VitePress via
the vitepress-openapi plugin. The new page lives alongside the
existing manual API reference in the Protocol Reference sidebar.

https://claude.ai/code/session_01FL2ggKU9YaFR1uUK53nTMY
Enhances the OpenAPI reference to generate individual pages per endpoint
(9 operations) with an auto-generated sidebar grouped by API tags
(Decisions, Reservations, Balances, Events), plus a full-spec overview page.

- Add YAML-to-JSON spec conversion script (scripts/convert-spec.js)
- Create dynamic route files for per-operation pages (api/operations/)
- Add full-spec overview page at /api/
- Convert sidebar config to path-based (separate sidebar for /api/ pages)
- Add "API Reference" to top nav
- Add yaml dependency for spec conversion

https://claude.ai/code/session_01FL2ggKU9YaFR1uUK53nTMY
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.

2 participants