Auto-generate OpenAPI 3.0 documentation from Python API source code
Project description
api-doc-gen
Auto-generate OpenAPI 3.0 documentation from Python API source code.
A CLI tool that scans Python source files (Flask, FastAPI, Django REST) for API route definitions and generates complete OpenAPI 3.0 specifications with documentation quality validation.
Features
- Multi-Framework Scanning — Detects Flask, FastAPI, and Django REST Framework routes
- OpenAPI 3.0 Generation — Produces valid OpenAPI specs in YAML or JSON
- Documentation Quality Validation — 10 built-in rules (DOC-001 to DOC-010)
- Coverage Analysis — Track documentation completeness by endpoint and method
- Rich Terminal Output — Color-coded tables with quality grades
- HTML Report Generation — Shareable documentation reports
- CI/CD Integration —
--fail-onflag for pipeline gates
Installation
pip install -e .
Quick Start
# Generate demo project
api-doc-gen demo
# Scan for endpoints
api-doc-gen scan demo-api/
# Generate OpenAPI spec
api-doc-gen generate demo-api/ -o openapi.yaml
# Validate documentation quality
api-doc-gen validate demo-api/
# Check coverage
api-doc-gen coverage demo-api/
# Generate HTML report
api-doc-gen report demo-api/ -o docs.html
# List validation rules
api-doc-gen rules
Validation Rules
| Rule | Severity | Description |
|---|---|---|
| DOC-001 | ERROR | Endpoint missing summary |
| DOC-002 | WARNING | Endpoint missing description |
| DOC-003 | ERROR | No response definitions |
| DOC-004 | WARNING | Parameter missing description |
| DOC-005 | INFO | No tags assigned |
| DOC-006 | WARNING | Missing operation ID |
| DOC-007 | ERROR | POST/PUT/PATCH without request body |
| DOC-008 | ERROR | Duplicate operation ID |
| DOC-009 | ERROR | Path parameter not documented |
| DOC-010 | WARNING | Inconsistent path naming (mixed case) |
CI/CD Integration
- name: API Doc Validation
run: |
api-doc-gen validate src/ --fail-on error
Testing
python -m pytest tests/ -v
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file api_doc_gen-1.0.0.tar.gz.
File metadata
- Download URL: api_doc_gen-1.0.0.tar.gz
- Upload date:
- Size: 18.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
53cc4a43b30bfb705f05f7eadd64ad6d4ed9ce63db9a9c5a4e3bb8ac603c5347
|
|
| MD5 |
850aa1577066c6431382947cebf69356
|
|
| BLAKE2b-256 |
435cded77e128a6f0d2b14fccea94c7d06d615f756d4228c5326aba26c7b1cd1
|
File details
Details for the file api_doc_gen-1.0.0-py3-none-any.whl.
File metadata
- Download URL: api_doc_gen-1.0.0-py3-none-any.whl
- Upload date:
- Size: 18.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7e5a44f28f64f1ea968656e33fbc38301ff11ea3ecf363463cd7fafc26b5896c
|
|
| MD5 |
59c11174252dbd758fd63dedc40bae89
|
|
| BLAKE2b-256 |
c6dfbacf700bc4ae58be057223868f0af8a8ed24bce9a840b93e96a0a7cab618
|