agentsclimarketplace

Route to openapi

Skill zebbern/claude-code-guide/skills/route-to-openapi

Claude Code Guide - Setup, Commands, workflows, agents, skills & tips-n-tricks go from beginner to power user!

Install
npx -y skills add zebbern/claude-code-guide --skill route-to-openapi

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

What its author says it does

Copied from the file, not written here

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.

The file declares its own license as MIT. That is the author’s claim about this one file, and it is not the same thing as the license GitHub reports for the repository, which is listed with the other numbers below.

SKILL.md

4.5 KB, as published. Nobody here has run it

route-to-openapi

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

LanguageFrameworkParsing Method
PythonFlaskAST parsing (decorators + type annotations + docstrings)
PythonFastAPIAST parsing (decorators + Pydantic models + type annotations)
PythonDjango REST FrameworkAST parsing (@api_view decorators)
JavaScript/TypeScriptExpress.jsRegex matching (app.get() / router.get() + JSDoc)
GoGinRegex matching (r.GET() / group.GET() + comments)
GoEchoRegex 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_model parameter (FastAPI)
  • Endpoint Descriptions: Extracted from docstrings / JSDoc / inline comments
  • Tag Grouping: Automatically grouped by source file module name

Path Parameter Format Conversion

FrameworkSource FormatConverted 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

ParameterDescriptionDefault
source_dirSource directory to scan (required)-
-f, --formatOutput format: json or yamljson
-o, --outputOutput file pathstdout
--frameworkForce a specific framework (skip auto-detection)Auto-detect
--titleAPI documentation titleAPI Documentation
--versionAPI version number1.0.0
--descriptionAPI description textEmpty
--serverServer 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

Keep looking

Skills are one crate of 328,083. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.