Generate comprehensive API documentation from TypeScript/Python codebases with OpenAPI 3.1 specifications, interactive documentation, and multi-language code examples
Generates comprehensive API documentation from TypeScript/Python codebases with OpenAPI 3.1 specifications, interactive documentation, and multi-language code examples
/plugin marketplace add greyhaven-ai/claude-code-config/plugin install developer-experience@grey-haven-pluginsAutomatically generate production-ready API documentation from your TypeScript or Python codebase with OpenAPI 3.1 specifications, interactive Swagger UI, and multi-language code examples.
Analyzes your codebase to extract API routes, schemas, and types, then generates:
# Generate OpenAPI spec with Swagger UI
/doc-generate-api --format openapi --interactive true
# Generate and deploy to Cloudflare Pages
/doc-generate-api --deploy cloudflare-pages
# Generate with coverage report
/doc-generate-api --coverage true --validate true
TypeScript:
Python:
For TypeScript (Hono/TanStack Start):
// Extracts from routes like this:
app.get('/users', async (c) => {
const users = await db.query.users.findMany();
return c.json({ data: users });
});
For Python (FastAPI):
# Extracts from routes like this:
@router.get("/users", response_model=List[UserSchema])
async def list_users():
users = await db.query(User).all()
return users
Process:
Complete specification with:
Key Pattern (Generated OpenAPI Structure):
paths:
/users:
get:
summary: List all users
operationId: listUsers
tags: [Users]
security:
- bearerAuth: []
parameters:
- name: page
in: query
schema:
type: integer
minimum: 1
default: 1
responses:
'200':
description: Successful response
content:
application/json:
schema:
type: object
properties:
data:
type: array
items:
$ref: '#/components/schemas/User'
Generates code snippets for each endpoint:
TypeScript/JavaScript:
const response = await fetch('https://api.greyhaven.com/users?page=1', {
headers: {
'Authorization': `Bearer ${API_KEY}`,
'Content-Type': 'application/json'
}
});
const { data } = await response.json();
Python:
response = requests.get(
'https://api.greyhaven.com/users',
params={'page': 1},
headers={'Authorization': f'Bearer {API_KEY}'}
)
users = response.json()['data']
cURL:
curl -X GET 'https://api.greyhaven.com/users?page=1' \
-H "Authorization: Bearer ${API_KEY}"
Swagger UI Features:
Generated Structure:
docs/api/
├── openapi.json # OpenAPI 3.1 spec (JSON)
├── openapi.yaml # OpenAPI 3.1 spec (YAML)
├── index.html # Swagger UI
├── coverage-report.md # Coverage analysis
├── examples/
│ ├── typescript/ # TS code examples
│ ├── python/ # Python examples
│ └── curl/ # cURL examples
└── schemas/ # JSON Schema files
Generates comprehensive coverage report:
# API Documentation Coverage Report
**Overall Coverage**: 87.3%
| Metric | Count | Documented | Coverage |
|--------|-------|------------|----------|
| Endpoints | 42 | 38 | 90.5% |
| Request Schemas | 35 | 31 | 88.6% |
| Response Schemas | 42 | 35 | 83.3% |
| Error Responses | 42 | 40 | 95.2% |
| Code Examples | 42 | 30 | 71.4% |
## Missing Documentation
- POST /orders/{id}/refund - Missing code examples
- PUT /users/{id}/preferences - Missing field descriptions
Coverage Thresholds:
OpenAPI Spec Validation:
npx @redocly/cli lint docs/api/openapi.json
Validates:
Code Example Testing:
describe('API Documentation Examples', () => {
it('TypeScript user list example works', async () => {
const result = await runExample('typescript/users.ts');
expect(result.data).toBeArray();
});
});
Cloudflare Pages Deployment:
# Deploy documentation
wrangler pages deploy docs/build --project-name grey-haven-docs
GitHub Actions CI/CD:
name: Generate API Documentation
on:
push:
branches: [main]
paths:
- 'src/**/*.ts'
- 'src/**/*.py'
jobs:
generate-docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: bun install
- run: bun run doc:generate-api
- run: npx @redocly/cli lint docs/api/openapi.json
# Check coverage threshold
- name: Check coverage
run: |
COVERAGE=$(node scripts/check-doc-coverage.js)
if [ "$COVERAGE" -lt 80 ]; then
echo "Coverage $COVERAGE% below 80% threshold"
exit 1
fi
# Deploy to Cloudflare Pages
- uses: cloudflare/pages-action@v1
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
projectName: grey-haven-docs
| Option | Description | Default |
|---|---|---|
--format | Output format: openapi, asyncapi | openapi |
--version | OpenAPI version: 3.0, 3.1 | 3.1 |
--output | Output directory | docs/api |
--interactive | Generate Swagger UI / Redoc | true |
--examples | Include code examples | true |
--deploy | Deploy to: cloudflare-pages, none | none |
--validate | Validate generated spec | true |
--coverage | Generate coverage report | true |
Keep Documentation In Sync
Maintain High Coverage
Version Your APIs
Test Your Examples
Issue: Generated spec has validation errors
# Validate and see specific errors
npx @redocly/cli lint docs/api/openapi.json --format=stylish
# Fix common issues automatically
npx @redocly/cli lint docs/api/openapi.json --fix
Issue: Missing route definitions
Issue: Code examples don't work
# Run example tests
bun test:api-examples
# Regenerate examples
/doc-generate-api --examples true --force
Works with:
All supporting files are under 500 lines per Anthropic best practices:
examples/ - Complete generation examples
reference/ - Configuration and patterns
templates/ - Copy-paste ready templates
checklists/ - Documentation checklists
Pro Tip: Run this command after implementing new endpoints, then share the generated Swagger UI link with your team. They can start integration immediately with interactive documentation and code examples.