This tool is designed to automatically extract API endpoints from a Django project and generate comprehensive documentation using OpenAPI 3.0, enhanced with AI-powered insights.
dj-autoschema is an AI-powered API documentation generator for Django projects. It extracts all API endpoints, infers request and response schemas using Pydantic, and generates highly detailed documentation, including:
Endpoint descriptions (purpose, necessity)
Available features, parameters, and authentication methods
Request body, response body, and potential errors
Automatic serving of openapi.json to ReDoc
This tool streamlines API documentation by leveraging AI to produce comprehensive and structured OpenAPI specifications.
pip install dj-autoschemaAdd dj-autoschema to the Django project’s installed apps:
INSTALLED_APPS = [
...
"dj_autoschema",
]Ensure the .env file exists in the project root and includes the following:
OPENAI_API_KEY=your_openai_api_key_hereRun the documentation generation command:
python manage.py generate_api_docsStart the Django development server:
python manage.py runserverView the API documentation at:
OpenAPI JSON: http://localhost:8000/openapi.json
ReDoc UI: http://localhost:8000/docs/
AI-Generated Descriptions: Extracts endpoint details and enhances them with AI-generated explanations.
Schema Inference: Uses Pydantic to infer request/response structures.
Automated Documentation: No need for manual annotation—just install and run.
OpenAPI & ReDoc Support: Serves openapi.json and integrates seamlessly with ReDoc.
MIT License