API Documentation Generator
Generate comprehensive API documentation from code.
Workflow
Identify the API framework:
- Express, Fastify, Koa, Hono (Node.js)
- Flask, FastAPI, Django REST Framework (Python)
- Gin, Echo, Chi (Go)
- Actix, Axum (Rust)
- Spring Boot (Java)
- Or a raw OpenAPI/Swagger spec.
Discover endpoints:
- Scan route definitions, controllers, and handler files.
- For each endpoint, extract: method, path, parameters, request body, response, middleware/guards.
For each endpoint, document:
### <METHOD> <path>
<Brief description>
**Authentication:** <Required/Optional/None>
**Parameters:**
| Name | In | Type | Required | Description |
|------|-----|------|----------|-------------|
| id | path | string | yes | Resource ID |
**Request Body:**
```json
{
"field": "type — description"
}
Responses:
| Status |
Description |
| 200 |
Success — returns |
| 400 |
Validation error |
| 401 |
Unauthorized |
| 404 |
Not found |
Example:
curl -X GET https://api.example.com/resource/123 \
-H "Authorization: Bearer <token>"
4. **Choose output format based on user preference:**
- **Markdown** — readable docs for a README or docs site.
- **OpenAPI 3.x YAML/JSON** — machine-readable spec for Swagger UI, Redoc, Postman.
- **Both** — generate both formats.
5. **If generating OpenAPI spec:**
- Include `info`, `servers`, `paths`, `components/schemas`.
- Derive schemas from TypeScript types, Pydantic models, or Go structs.
- Validate the spec with a linter if available.
## Guidelines
- Derive documentation from actual code, not guesses.
- Include realistic example values in request/response samples.
- Document error responses, not just happy paths.
- Group endpoints by resource or domain (e.g., Users, Products, Orders).
- Note rate limits, pagination, and versioning if present in the code.
- If auth middleware exists, document the auth mechanism.
- For GraphQL APIs, document queries, mutations, and subscriptions instead.
1---2name: apidoc3description: Generate API documentation from code. Use when the user says /apidoc, asks to document an API, generate API docs, create endpoint documentation, or produce an OpenAPI/Swagger spec. Triggers: api doc, api documentation, endpoint docs, swagger, openapi, REST docs, API reference, document routes.4---56# API Documentation Generator78Generate comprehensive API documentation from code.910## Workflow11121. **Identify the API framework:**13 - Express, Fastify, Koa, Hono (Node.js)14 - Flask, FastAPI, Django REST Framework (Python)15 - Gin, Echo, Chi (Go)16 - Actix, Axum (Rust)17 - Spring Boot (Java)18 - Or a raw OpenAPI/Swagger spec.19202. **Discover endpoints:**21 - Scan route definitions, controllers, and handler files.22 - For each endpoint, extract: method, path, parameters, request body, response, middleware/guards.23243. **For each endpoint, document:**2526```markdown27### <METHOD> <path>2829<Brief description>3031**Authentication:** <Required/Optional/None>3233**Parameters:**34| Name | In | Type | Required | Description |35|------|-----|------|----------|-------------|36| id | path | string | yes | Resource ID |3738**Request Body:**39```json40{41 "field": "type — description"42}43```4445**Responses:**46| Status | Description |47|--------|-------------|48| 200 | Success — returns <shape> |49| 400 | Validation error |50| 401 | Unauthorized |51| 404 | Not found |5253**Example:**54```bash55curl -X GET https://api.example.com/resource/123 \56 -H "Authorization: Bearer <token>"57```58```59604. **Choose output format based on user preference:**61 - **Markdown** — readable docs for a README or docs site.62 - **OpenAPI 3.x YAML/JSON** — machine-readable spec for Swagger UI, Redoc, Postman.63 - **Both** — generate both formats.64655. **If generating OpenAPI spec:**66 - Include `info`, `servers`, `paths`, `components/schemas`.67 - Derive schemas from TypeScript types, Pydantic models, or Go structs.68 - Validate the spec with a linter if available.6970## Guidelines7172- Derive documentation from actual code, not guesses.73- Include realistic example values in request/response samples.74- Document error responses, not just happy paths.75- Group endpoints by resource or domain (e.g., Users, Products, Orders).76- Note rate limits, pagination, and versioning if present in the code.77- If auth middleware exists, document the auth mechanism.78- For GraphQL APIs, document queries, mutations, and subscriptions instead.