Add OpenAPI spec transformer Claude Code skill#409
Conversation
Add a fully autonomous Claude Code skill that transforms Swagger 2.0 API specs from source repositories into OpenAPI 3.0.0 format for the documentation site. The skill runs end-to-end without human review between steps — the human validates locally after completion. Includes: - SKILL.md: 8-step autonomous workflow (fetch, transform, diff, test, build) - references/examples.md: Before/after transformation examples with enums - references/tag-mapping.md: Path-to-tag mapping rules for gRPC and Staking API - references/servers.md: Server endpoint reference for all environments - .gitignore: Track .claude/skills/ but exclude settings.local.json Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR primarily adds a Claude Code skill (checked into .claude/skills/) to autonomously transform upstream Swagger 2.0 specs into the OpenAPI 3.0.0 format used by this Docusaurus documentation site, and includes reference material to guide consistent transformations.
Changes:
- Added the
openapi-spec-transformerClaude skill with an end-to-end, autonomous workflow for fetching, transforming, validating, and regenerating API docs. - Added reference docs for tag mapping, server endpoints, and before/after transformation examples.
- Updated
.gitignorefor Claude local settings, and added a new BABE research guide page.
Reviewed changes
Copilot reviewed 4 out of 5 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
docs/guides/research/babe_verification.mdx |
Adds a new research guide page linking to the BABE paper PDF. |
.gitignore |
Ignores Claude local settings file; also adds ignore patterns for tests/ and test-results/. |
.claude/skills/openapi-spec-transformer/SKILL.md |
Defines the autonomous Swagger 2.0 → OpenAPI 3.0 workflow and repo update steps. |
.claude/skills/openapi-spec-transformer/references/examples.md |
Provides before/after examples for key transformation patterns. |
.claude/skills/openapi-spec-transformer/references/tag-mapping.md |
Documents path-prefix → tag rules and x-tagGroups structure. |
.claude/skills/openapi-spec-transformer/references/servers.md |
Documents server URLs and basic endpoint checks for validation. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| curl -sL -o /tmp/babylon-swagger2.yaml \ | ||
| https://raw.githubusercontent.com/babylonlabs-io/babylon/main/client/docs/swagger-ui/swagger.yaml | ||
|
|
||
| # Staking API spec | ||
| curl -sL -o /tmp/staking-swagger2.yaml \ |
There was a problem hiding this comment.
The download commands use curl -sL, which can silently write an HTML error page on 404/5xx and still exit 0. To make the autonomous workflow reliably fail fast (as the step text requires), use curl flags that fail on HTTP errors (e.g., include -f) and consider adding basic retry/backoff.
| curl -sL -o /tmp/babylon-swagger2.yaml \ | |
| https://raw.githubusercontent.com/babylonlabs-io/babylon/main/client/docs/swagger-ui/swagger.yaml | |
| # Staking API spec | |
| curl -sL -o /tmp/staking-swagger2.yaml \ | |
| curl -fsSL --retry 3 --retry-delay 5 -o /tmp/babylon-swagger2.yaml \ | |
| https://raw.githubusercontent.com/babylonlabs-io/babylon/main/client/docs/swagger-ui/swagger.yaml | |
| # Staking API spec | |
| curl -fsSL --retry 3 --retry-delay 5 -o /tmp/staking-swagger2.yaml \ |
| npx swagger2openapi /tmp/babylon-swagger2.yaml -o /tmp/babylon-openapi3-base.yaml | ||
| npx swagger2openapi /tmp/staking-swagger2.yaml -o /tmp/staking-openapi3-base.yaml |
There was a problem hiding this comment.
npx swagger2openapi ... without a version pin makes the transformation non-reproducible over time and may prompt for interactive install confirmation, which can break an autonomous run. Pin the tool version (and run in non-interactive mode) so collaborators get consistent output.
| npx swagger2openapi /tmp/babylon-swagger2.yaml -o /tmp/babylon-openapi3-base.yaml | |
| npx swagger2openapi /tmp/staking-swagger2.yaml -o /tmp/staking-openapi3-base.yaml | |
| npx --yes swagger2openapi@7.0.8 /tmp/babylon-swagger2.yaml -o /tmp/babylon-openapi3-base.yaml | |
| npx --yes swagger2openapi@7.0.8 /tmp/staking-swagger2.yaml -o /tmp/staking-openapi3-base.yaml |
| **6. Assign tags to ALL paths** based on path prefix mapping: | ||
| - `/babylon/btccheckpoint/` → `btccheckpoint` | ||
| - `/babylon/btclightclient/` → `btclightclient` | ||
| - `/babylon/btcstaking/` → `btcstaking` | ||
| - `/babylon/btcstkconsumer/` → `btcstkconsumer` |
There was a problem hiding this comment.
The path→tag mapping here looks incomplete relative to the Babylon gRPC spec currently in-repo (e.g., it contains /babylon/zoneconcierge/... endpoints). As written, any Babylon module not listed will fall into an implicit fallback (often other) and lose module grouping; consider adding mappings for all /babylon/<module>/ prefixes present in the source/current specs (or define an explicit rule for unmapped modules, plus ensure the corresponding tags/x-tagGroups exist).
| | Path Prefix | Tag | Description | | ||
| |-------------|-----|-------------| | ||
| | `/babylon/btccheckpoint/` | `btccheckpoint` | BTC Checkpoint module queries and Txs | | ||
| | `/babylon/btclightclient/` | `btclightclient` | BTC Light Client module queries and Txs | | ||
| | `/babylon/btcstaking/` | `btcstaking` | Manages BTC staking, finality providers, and delegations | |
There was a problem hiding this comment.
This prefix→tag table appears to cover only a subset of Babylon gRPC modules. The current spec in static/swagger/babylon-grpc-openapi3.yaml includes additional /babylon/<module>/... prefixes (e.g., zoneconcierge) that wouldn’t match anything here, which can lead to inconsistent tagging/grouping during transformation. Consider extending the mapping (and x-tagGroups) to include all Babylon module prefixes present in the source/current specs, or document a clear fallback strategy.
- Use curl -fsSL with retry for fail-fast HTTP error handling - Pin swagger2openapi@7.0.8 with --yes for reproducible transforms - Add monitor and zoneconcierge module mappings to tag config - Add explicit fallback strategy for unmapped Babylon modules Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Summary
.claude/skills/so any collaborator who clones the repo gets it automatically.gitignoreto track skills but exclude local Claude Code settingsWhat the skill does
Converts API specs from
babylonlabs-io/babylonandbabylonlabs-io/staking-api-service(Swagger 2.0) into the OpenAPI 3.0.0 format required bydocusaurus-plugin-openapi-docs, with:Files
.claude/skills/openapi-spec-transformer/SKILL.md.claude/skills/openapi-spec-transformer/references/examples.md.claude/skills/openapi-spec-transformer/references/tag-mapping.md.claude/skills/openapi-spec-transformer/references/servers.md.gitignore.claude/settings.local.json, track skillsHow to use
.claude/skills/Update the API specs from source repositoriesnpm run serveTest plan
npm run buildpasses after transformation🤖 Generated with Claude Code