/api-docs
Auto-document your REST API from the code.
Usage
/api-docs # detect framework, output to docs/openapi.yaml
/api-docs --output api-spec.json # custom path + format
/api-docs --format markdown # human-readable instead of OpenAPI
Frameworks supported
- Next.js App Router (
app/api/**/route.ts) - Next.js Pages Router (
pages/api/**.ts) - Express (
app.get('/users', ...)) - Fastify (with schema definitions)
- Hono
- FastAPI (Python)
What it extracts
For each endpoint:
- HTTP method + path
- Path / query params with types
- Request body shape (from Zod / Yup / TypeScript types)
- Response shape (success + error)
- Status codes used
- Auth requirements (detects JWT / cookie / API key middleware)
Output
OpenAPI 3.1 YAML with:
infoblock frompackage.jsonserversfrom env configcomponents.schemasdeduplicated from shared typestagsgrouped by route folder
Optionally renders to Swagger UI / Redoc HTML.
Rules
- Don't invent endpoints that don't exist in code
- If a response shape can't be inferred (returns
unknown), mark explicitly with TODO - Sync only — never modify route handlers