route-to-openapi
Generates RESTful API documentation (OpenAPI 3.0 / Swagger spec) by scanning route definitions in code for Flask, FastAPI, Express, Gin, and other frameworks. Trigger when users ask about API documentation, OpenAPI, Swagger, endpoint docs, generating docs from code, or extracting endpoints.
pinned to #9d252b3updated last month
Ask your AI client: “install skills/route-to-openapi”.
Requires the metahub MCP server installed in your client. Set up MCP.
mh install skills/route-to-openapimetahub onboarded this repo on the author's behalf.
If you own github.com/zebbern/claude-code-guide on GitHub, claim the listing to take over publishing. Your claim preserves the existing eval history and badges; only the curator label is replaced with verified-publisher on your next publish.
Stars
4,568
Last commit
last month
Latest release
published
- #ai
- #ai-agent
- #ai-agent-tools
- #anthropic-claude
- #claude
- #claude-ai
- #claude-api
- #claude-code
- #claude-code-communication
- #claude-code-guide
- #claude-code-skills
- #claude-commands
- #claude-desktop
- #claude-mcp
- #claude-sonnet
- #code
- #mcp
- #mcp-agents
- #mcp-tools
- #vscode-extension
About this skill
Pulled from SKILL.md at publish time.
Automatically scan route/endpoint definitions in source code and generate RESTful API documentation conforming to the OpenAPI 3.0.3 specification.
Automated checks the publisher passed at publish time — structure, docs, safety, and whether the artifact behaves as claimed.9d252b3· last month
Behavioral checks ran but aren't published for this artifact; the static checks above ran at publish time.
Documentation
8 passed1 warningHomepage or repository declaredwarn
No homepage or repository declared.
Add a "homepage" or "repository" field to SKILL.md.
Description quality
41 words · 291 chars — "Generates RESTful API documentation (OpenAPI 3.0 / Swagger spec) by scanning rou…"
README is present and substantial
168,182 chars · 12 sections · 127 code blocks
Tags / topics declared
20 total — ai, ai-agent, ai-agent-tools, anthropic-claude, claude, claude-ai (+14)
README has usage / example sections
found: Quick Start · Example · Example
Homepage / docs URL declared
no homepage declared (registry will use the repo URL) — info-only, not blocking
Description is substantive
Description is 41 words.
Documentation present and substantive
Documentation present (SKILL.md, 621 words).
Documentation shows usage
Documentation includes 2 code examples.
Release history
1- releasecurrent9d252b3warnlast month
Contents
Automatically scan route/endpoint definitions in source code and generate RESTful API documentation conforming to the OpenAPI 3.0.3 specification.
Supports major web frameworks with automatic framework detection. Extracts HTTP methods, paths, parameters, request bodies, response models, and doc comments, then outputs a standard OpenAPI spec file ready to import into Swagger UI or Redoc.
Quick Start
# Scan source directory, output OpenAPI spec in JSON format
python scripts/generate_api_doc.py ./src
# Specify output format and file
python scripts/generate_api_doc.py ./src --format yaml --output api-spec.yaml
# Specify framework and API metadata
python scripts/generate_api_doc.py ./app --framework flask --title "My API" --version 2.0.0
# Add server URLs
python scripts/generate_api_doc.py ./routes --server http://localhost:3000 --server https://api.example.com
Supported Frameworks
| Language | Framework | Parsing Method |
|---|---|---|
| Python | Flask | AST parsing (decorators + type annotations + docstrings) |
| Python | FastAPI | AST parsing (decorators + Pydantic models + type annotations) |
| Python | Django REST Framework | AST parsing (@api_view decorators) |
| JavaScript/TypeScript | Express.js | Regex matching (app.get() / router.get() + JSDoc) |
| Go | Gin | Regex matching (r.GET() / group.GET() + comments) |
| Go | Echo | Regex matching (e.GET() + comments) |
Extraction Capabilities
The script automatically extracts the following information:
- HTTP Methods: GET / POST / PUT / DELETE / PATCH, etc.
- Route Paths: Automatically converts each framework's path parameter format to the OpenAPI
{param}format - Path Parameters: Extracted from route patterns (with type inference)
- Query Parameters: Extracted from function signatures (Python frameworks)
- Request Bodies: Inferred from type annotations and Pydantic models (FastAPI)
- Response Models: Extracted from the
response_modelparameter (FastAPI) - Endpoint Descriptions: Extracted from docstrings / JSDoc / inline comments
- Tag Grouping: Automatically grouped by source file module name
Path Parameter Format Conversion
| Framework | Source Format | Converted Result |
|---|---|---|
| Flask | <int:user_id> | {user_id} (type: integer) |
| FastAPI | {user_id} | {user_id} (unchanged) |
| Express | :user_id | {user_id} |
| Gin/Echo | :user_id | {user_id} |
Parameters
| Parameter | Description | Default |
|---|---|---|
source_dir | Source directory to scan (required) | - |
-f, --format | Output format: json or yaml | json |
-o, --output | Output file path | stdout |
--framework | Force a specific framework (skip auto-detection) | Auto-detect |
--title | API documentation title | API Documentation |
--version | API version number | 1.0.0 |
--description | API description text | Empty |
--server | Server URL (can be specified multiple times) | None |
Output Example
{
"openapi": "3.0.3",
"info": {
"title": "My API",
"version": "1.0.0"
},
"paths": {
"/users": {
"get": {
"summary": "List all users",
"operationId": "list_users",
"tags": ["users"],
"parameters": [
{
"name": "limit",
"in": "query",
"required": false,
"schema": { "type": "integer" }
}
],
"responses": {
"200": { "description": "Successful response" }
}
}
},
"/users/{user_id}": {
"get": {
"summary": "Get user by ID",
"operationId": "get_user",
"tags": ["users"],
"parameters": [
{
"name": "user_id",
"in": "path",
"required": true,
"schema": { "type": "integer" }
}
],
"responses": {
"200": { "description": "Successful response" }
}
}
}
}
}
Prerequisites
- Python 3.8+
- No additional dependencies required — uses only the Python standard library
- The scanned project must use one of the supported web frameworks listed above
Reviews
No reviews yet. Be the first.
Related
Verification Before Completion
Evidence before assertions, always
Writing Plans
Turn specs into phased implementation plans
Test-Driven Development
Red → green → refactor discipline for any feature or bugfix
mh install skills/route-to-openapi