| name | api-documenter |
| description | Generate API documentation: OpenAPI 3.1 specs, interactive docs with Swagger/Redoc, SDK generation, and JSDoc/TSDoc extraction. |
| metadata | {"thinkfleetbot":{"emoji":"📖","requires":{"anyBins":["npx","node"]}}} |
API Documentation
Generate and maintain API documentation from code and OpenAPI specs.
OpenAPI Spec Validation
npx @apidevtools/swagger-cli validate openapi.yaml
npx @apidevtools/swagger-cli bundle openapi.yaml -o openapi-bundled.yaml
Interactive Docs
Swagger UI
npx @redocly/cli preview openapi.yaml
docker run -p 8080:8080 -e SWAGGER_JSON=/spec/openapi.yaml -v $(pwd):/spec swaggerapi/swagger-ui
Redoc
npx @redocly/cli build-docs openapi.yaml -o docs.html
npx @redocly/cli preview-docs openapi.yaml
Generate OpenAPI from Code
Express/Node.js with swagger-jsdoc
npm install swagger-jsdoc swagger-ui-express
node -e "
const swaggerJsdoc = require('swagger-jsdoc');
const spec = swaggerJsdoc({
definition: { openapi: '3.1.0', info: { title: 'My API', version: '1.0.0' } },
apis: ['./src/routes/*.ts'],
});
console.log(JSON.stringify(spec, null, 2));
" > openapi.json
FastAPI (Python — auto-generates)
curl -s http://localhost:8000/openapi.json | jq . > openapi.json
TypeDoc (TypeScript Documentation)
npx typedoc --entryPoints src/index.ts --out docs/api
npx typedoc --json docs/api.json --entryPoints src/index.ts
npx typedoc --entryPoints src/index.ts --out docs/api --readme README.md
JSDoc Extraction
npx jsdoc src/ -r -d docs/
npx jsdoc src/ -r -d docs/ -t node_modules/clean-jsdoc-theme
SDK Generation from OpenAPI
npx openapi-typescript openapi.yaml -o src/api-types.ts
npx @openapitools/openapi-generator-cli generate \
-i openapi.yaml \
-g typescript-fetch \
-o src/generated/api
npx @openapitools/openapi-generator-cli generate \
-i openapi.yaml \
-g python \
-o generated/python-client
Linting OpenAPI Specs
npx @redocly/cli lint openapi.yaml
npx @stoplight/spectral-cli lint openapi.yaml
Notes
- Write the OpenAPI spec first (design-first), then implement. It's faster than code-first for teams.
- Keep specs in version control alongside the code.
- Validate specs in CI — broken docs are worse than no docs.
- SDK generation saves client teams significant time. Regenerate on every API change.
- Use
$ref to split large specs into manageable files.