← 返回
未分类

API Documentation Generator

Generate comprehensive API documentation from code — extract endpoints, parameters, response schemas, and examples from Express, FastAPI, Django, Rails, and...
从代码生成全面的 API 文档,提取 Express、FastAPI、Django、Rails等框架的端点、参数、响应模式及示例。
charlie-morrison charlie-morrison 来源
未分类 clawhub v1.0.1 1 版本 100000 Key: 无需
★ 0
Stars
📥 365
下载
💾 1
安装
1
版本
#latest

概述

API Documentation Generator

Generate comprehensive API documentation by analyzing source code. Extracts endpoints, parameters, request/response schemas, authentication requirements, and generates examples. Works with Express, FastAPI, Django REST Framework, Rails, Spring Boot, and other frameworks.

Usage

"Generate API docs from my Express app"
"Create API reference documentation"
"Document all endpoints in this project"
"Generate OpenAPI spec from my code"

How It Works

1. Framework Detection

# Detect framework from dependencies
cat package.json 2>/dev/null | python3 -c "
import json,sys
d=json.load(sys.stdin).get('dependencies',{})
for fw in ['express','fastify','koa','hapi','nestjs','next']:
    if fw in str(d): print(f'Node: {fw}')
" 2>/dev/null

cat requirements.txt setup.py pyproject.toml 2>/dev/null | grep -i "fastapi\|django\|flask\|starlette"

2. Endpoint Extraction

Scan source code for route definitions:

Express/Node:

grep -rn "router\.\(get\|post\|put\|patch\|delete\|all\)\|app\.\(get\|post\|put\|patch\|delete\)" src/ routes/

FastAPI/Python:

grep -rn "@app\.\(get\|post\|put\|patch\|delete\)\|@router\.\(get\|post\|put\|patch\|delete\)" src/ app/

Django REST Framework:

grep -rn "class.*ViewSet\|class.*APIView\|path(" */views.py */urls.py

For each endpoint, extract:

  • HTTP method and path
  • URL parameters and query parameters
  • Request body schema (from TypeScript types, Pydantic models, serializers)
  • Response format and status codes
  • Authentication requirements
  • Middleware chain
  • Rate limiting rules

3. Schema Extraction

Analyze types/models for request/response schemas:

  • TypeScript interfaces and types
  • Pydantic models with field validators
  • Django serializers with field definitions
  • Joi/Zod validation schemas
  • JSON Schema definitions

4. Example Generation

Generate realistic request/response examples:

  • Valid request with all required fields
  • Response with realistic data
  • Error response examples (400, 401, 403, 404, 500)
  • Curl command for quick testing
  • SDK examples in popular languages

5. Documentation Output

Generate in multiple formats:

Markdown API Reference:

## POST /api/users

Create a new user account.

**Authentication:** Bearer token required
**Rate limit:** 10 requests/minute

### Request Body
| Field | Type | Required | Description |
|-------|------|----------|-------------|
| email | string | yes | Valid email address |
| name | string | yes | Full name (2-100 chars) |
| role | enum | no | "user" or "admin" (default: "user") |

### Response (201 Created)

{

"id": "usr_abc123",

"email": "user@example.com",

"name": "Jane Smith",

"role": "user",

"createdAt": "2026-04-30T10:00:00Z"

}


### Errors
- `400` — Invalid email format or missing required field
- `409` — Email already registered
- `429` — Rate limit exceeded

OpenAPI 3.1 spec — machine-readable for Swagger UI, Redoc, Postman

6. Completeness Check

Verify documentation quality:

  • All endpoints documented
  • All parameters described
  • Response schemas match actual responses
  • Authentication documented
  • Error codes listed
  • Examples present and valid

Output

## API Documentation Generated

**Framework:** Express.js + TypeScript
**Endpoints found:** 23
**Documentation completeness:** 87%

### Generated Files
- docs/api-reference.md (full markdown reference)
- docs/openapi.yaml (OpenAPI 3.1 spec)
- docs/examples/ (curl examples per endpoint)

### Coverage
| Category | Endpoints | Documented | Missing |
|----------|-----------|------------|---------|
| Auth | 4 | 4 (100%) | — |
| Users | 6 | 5 (83%) | PATCH /users/:id |
| Orders | 8 | 7 (88%) | webhook handler |
| Admin | 5 | 5 (100%) | — |

### Undocumented
- PATCH /api/users/:id — has route but no type annotations
- POST /api/webhooks/stripe — raw req.body, no schema

版本历史

共 1 个版本

  • v1.0.1 当前
    2026-05-07 23:22 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

dev-programming

CodeConductor.ai

larsonreever
AI驱动平台,提供快速全栈开发、智能体、工作流自动化及低代码AI集成的可扩展产品创建。
★ 75 📥 182,389
it-ops-security

Vulnerability Prioritizer

charlie-morrison
在CVSS评分之外,利用EPSS、CISA KEV、资产关键性、可达性分析以及利用成熟度进行漏洞优先级排序
★ 1 📥 515
dev-programming

Github

steipete
使用 `gh` CLI 与 GitHub 交互,通过 `gh issue`、`gh pr`、`gh run` 和 `gh api` 管理议题、PR、CI 运行及高级查询。
★ 681 📥 329,249