用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/tomevault-io/skills-registry --skill api-docs-generator命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
| Use when this capability is needed.
> Use when this capability is needed.
Review architecture and API design for the vfs-s3 project. Use when the user mentions @architect, asks to review an issue's design, discuss module boundaries, API shape, or architectural decisions for vfs-s3. Also trigger when the user wants to create an ADR (Architecture Decision Record) or evaluate a technical approach for the project. Intended for dispatch from Codex automation or Claude routines; GitHub trigger phrase: @vfs-s3-bot please prepare design doc Use when this capability is needed.
基于 SOC 职业分类
正在显示 SKILL.md
| name | api-docs-generator |
| description | Use when user asks for API docs, OpenAPI spec, Swagger docs, endpoint documentation, |
| metadata | {"author":"dcs-soni"} |
Automatically extract API routes from your codebase and generate comprehensive OpenAPI 3.0 specifications with proper schemas, examples, and descriptions.
When a user asks for API documentation, follow this checklist:
API Documentation Progress:
- [ ] Step 1: Detect API framework and analyze routes
- [ ] Step 2: Extract endpoint definitions
- [ ] Step 3: Infer request/response schemas
- [ ] Step 4: Generate OpenAPI specification
- [ ] Step 5: Create markdown documentation
- [ ] Step 6: Add examples and descriptions
- [ ] Step 7: Validate and output
Run the route analyzer to detect the API framework and find all endpoints:
python .claude/skills/api-docs-generator/scripts/analyze_routes.py .
Supported Frameworks:
Output includes:
For each detected endpoint, extract:
| Property | Source |
|---|---|
| Path | Route definition |
| Method | GET, POST, PUT, PATCH, DELETE |
| Parameters | Path params, query params |
| Request body | Validation schema, TypeScript types |
| Response | Return statements, response calls |
| Auth | Middleware, decorators |
| Tags | File/folder structure |
Express Example:
// Route: POST /api/users
// Extract: path params, body schema, response type
router.post("/", validateRequest(createUserSchema), userController.create);
Extract schemas from validation libraries and TypeScript types:
const createUserSchema = z.object({
email: z.string().email(),
name: z.string().min(2).max(100),
role: z.enum(["admin", "user"]),
});
// → Infer OpenAPI schema with types, formats, constraints
interface UserResponse {
id: string;
email: string;
createdAt: Date;
}
// → Convert to OpenAPI schema
class UserCreate(BaseModel):
email: EmailStr
name: str = Field(..., min_length=2, max_length=100)
# → Convert to OpenAPI schema
Schema Mapping:
| Source Type | OpenAPI Type | Format |
|---|---|---|
| string | string | - |
| number | number | - |
| boolean | boolean | - |
| Date | string | date-time |
| string | ||
| uuid | string | uuid |
| url | string | uri |
| int | integer | int32 |
| array | array | - |
| object | object | - |
Create the OpenAPI 3.0 YAML/JSON file:
openapi: 3.0.3
info:
title: { { API_NAME } }
description: { { API_DESCRIPTION } }
version: { { VERSION } }
contact:
name: API Support
email: support@example.com
servers:
- url: http://localhost:3000
description: Development
- url: https://api.example.com
description: Production
paths:
/api/users:
get:
summary: List users
operationId: listUsers
tags:
- Users
parameters:
- $ref: "#/components/parameters/PageParam"
- $ref: "#/components/parameters/LimitParam"
responses:
"200":
description: Successful response
content:
application/json:
schema:
Generate human-readable API documentation:
python .claude/skills/api-docs-generator/scripts/generate_markdown.py openapi.yaml --output docs/API.md
Output Structure:
# API Documentation
## Authentication
Bearer token required for protected endpoints.
## Endpoints
### Users
#### List Users
`GET /api/users`
**Parameters:**
| Name | Type | Required | Description |
|------|------|----------|-------------|
| page | integer | No | Page number (default: 1) |
| limit | integer | No | Items per page (default: 20) |
**Response:**
```json
[
{
"id": "abc123",
"email": "user@example.com",
"name": "John Doe",
"createdAt": "2024-01-15T10:30:00Z"
}
]
```
POST /api/users
Request Body:
{
"email": "user@example.com",
"name": "John Doe",
"role": "user"
}
...
---
### Step 6: Add Examples and Descriptions
Enhance documentation with:
1. **Request/Response Examples**
- Generate realistic sample data
- Include edge cases
- Show error responses
2. **Descriptions**
- Summarize each endpoint's purpose
- Document business rules
- Note rate limits and permissions
3. **Code Snippets**
- cURL examples
- JavaScript/fetch examples
- Python requests examples
---
### Step 7: Validate and Output
Validate the generated OpenAPI spec:
```bash
python .claude/skills/api-docs-generator/scripts/validate_openapi.py openapi.yaml
Checks:
Output Files:
docs/
├── openapi.yaml # OpenAPI 3.0 spec
├── openapi.json # JSON version
├── API.md # Markdown docs
└── postman_collection.json # Postman import
Create .claude/api-docs-config.yaml to customize:
info:
title: My API
version: 1.0.0
description: Backend API for MyApp
servers:
- url: http://localhost:3000
description: Development
- url: https://api.myapp.com
description: Production
defaults:
auth: BearerAuth
content_type: application/json
tag_from: folder # folder, file, or manual
output:
format: yaml # yaml or json
path: docs/openapi.yaml
markdown: docs/API.md
postman: true
ignore:
- /health
- /metrics
- /internal/*
// Patterns detected:
router.get("/users", handler); // Basic route
router.post("/users", validate, handler); // With middleware
app.use("/api", apiRouter); // Nested routers
# Patterns detected:
@router.get("/users", response_model=List[User])
@router.post("/users", status_code=201)
# + Pydantic models for schemas
// app/api/users/route.ts
export async function GET(request: Request) {}
export async function POST(request: Request) {}
// → Infer routes from file structure
// Patterns detected:
@Controller('users')
@Get()
@Post()
@ApiOperation({ summary: 'List users' }) // Already has OpenAPI decorators
User asks: "Generate OpenAPI docs for my API"
analyze_routes.py → Detects Expresssrc/routes/*.tssrc/schemas/openapi.yamlAPI.mdUser asks: "Create Swagger documentation"
User asks: "Document my Next.js API routes"
app/api/** or pages/api/**Converted and distributed by TomeVault — claim your Tome and manage your conversions.