Auto-generate API documentation from code and comments. Use when API endpoints change, or user mentions API docs. Creates OpenAPI/Swagger specs from code. Triggers on API file changes, documentation requests, endpoint additions.
// You write:
/**
* Get user by ID
* @param {string} id - User ID
* @returns {User} User object
*/
app.get('/api/users/:id', async (req, res) => {
const user = await User.findById(req.params.id);
res.json(user);
});
// I auto-generate OpenAPI spec:
paths:
/api/users/{id}:
get:
summary: Get user by ID
parameters:
- name: id
in: path
required: true
description: User ID
schema:
type: string
responses:
'200':
description: User found
content:
application/json:
schema:
$ref: '#/components/schemas/User'
example:
id: "123"
name: "John Doe"
email: "[email protected]"
'404':
description: User not found
FastAPI Endpoint
# You write:
@app.get("/users/{user_id}")
def get_user(user_id: int) -> User:
"""Get user by ID"""
return db.query(User).filter(User.id == user_id).first()
// I auto-generate:
paths:
/users/{user_id}:
get:
summary: Get user by ID
parameters:
- name: user_id
in: path
required: true
schema:
type: integer
responses:
'200':
description: Successful response
content:
application/json:
schema:
$ref: '#/components/schemas/User'
Complete OpenAPI Document
openapi: 3.0.0
info:
title: User API
version: 1.0.0
description: API for user management
servers:
- url: https://api.example.com/v1
paths:
/api/users:
get:
summary: List all users
responses:
'200':
description: Users array
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/User'
components:
schemas:
User:
type: object
properties:
id:
type: string
name:
type: string
email:
type: string
format: email
Detection Logic
Framework Detection
I recognize these frameworks automatically:
Express.js (Node.js)
FastAPI (Python)
Django REST (Python)
Spring Boot (Java)
Gin (Go)
Rails (Ruby)
Comment Parsing
I extract documentation from:
JSDoc comments (/** */)
Python docstrings
JavaDoc
Inline comments with decorators
Documentation Enhancement
Missing Information
// Your code:
app.post('/api/users', (req, res) => {
User.create(req.body);
});
// I suggest additions:
/**
* Create new user
* @param {Object} req.body - User data
* @param {string} req.body.name - User name (required)
* @param {string} req.body.email - User email (required)
* @returns {User} Created user
* @throws {400} Invalid input
* @throws {409} Email already exists
*/