Generate API documentation from Express/Fastify route files.
Scans your source code for route definitions (app.get, router.post, fastify.delete, etc.), extracts HTTP methods, paths, and JSDoc descriptions, then outputs a Markdown or JSON document.
npm install -g api-doc-cliapi-doc [options]| Flag | Description | Default |
|---|---|---|
-d, --dir <path> |
Source directory to scan | . |
-o, --output <file> |
Output file path | API.md |
-p, --pattern <glob> |
Glob pattern for route files | **/*route*.{ts,js} |
--json |
Output as JSON instead of Markdown | |
--group-by-file |
Group endpoints by source file |
# Scan current directory with defaults
api-doc
# Scan a specific directory
api-doc -d src/routes
# Custom pattern and output
api-doc -p "**/*.controller.ts" -o docs/endpoints.md
# JSON output grouped by file
api-doc --json --group-by-fileThe tool detects route registrations on these objects:
app(Express)router(Express Router)server/fastify(Fastify)
HTTP methods: GET, POST, PUT, DELETE, PATCH.
JSDoc comments (/** ... */) directly above the route call are extracted as descriptions.
MIT