A tool to export Django REST Framework API documentation to Excel
Project description
drf-excel-export
drf-excel-export is a Django package that enables easy export of Django REST Framework (DRF) API documentation to an Excel file. It is compatible with both drf-spectacular and drf-yasg for generating OpenAPI schemas, providing flexibility based on your existing DRF setup.
Features
- Exports API endpoint information, including paths, HTTP methods, descriptions, parameters, and response codes.
- Compatible with both
drf-spectacularanddrf-yasgfor OpenAPI schema generation. - Outputs an organized Excel file (
api_documentation.xlsx) with all API documentation.
Installation
-
Install the Package:
pip install drf-excel-export
-
Add to Django
INSTALLED_APPS: Adddrf_excel_exportto yourINSTALLED_APPSin your Django project’ssettings.py:INSTALLED_APPS = [ ..., 'drf_excel_export', ]
-
Configure drf-spectacular or drf-yasg (if not already installed): Install and configure either
drf-spectacularordrf-yasg, as one of these libraries is required for schema generation:-
For
drf-spectacular:pip install drf-spectacular
Then, in
settings.py:REST_FRAMEWORK = { 'DEFAULT_SCHEMA_CLASS': 'drf_spectacular.openapi.AutoSchema', } SPECTACULAR_SETTINGS = { 'TITLE': 'Your API Title', 'DESCRIPTION': 'API description here', 'VERSION': '1.0.0', }
-
For
drf-yasg:pip install drf-yasg
Add a schema view in your
urls.pyif you wish to view the schema:from rest_framework import permissions from drf_yasg.views import get_schema_view from drf_yasg import openapi schema_view = get_schema_view( openapi.Info( title="Your API Title", default_version='v1', description="API description here", ), public=True, permission_classes=(permissions.AllowAny,), )
-
Usage
To generate the API documentation in Excel format, run the following management command from your Django project’s root directory:
python manage.py export_excel
This command will generate an Excel file, api_documentation.xlsx, in the current directory, containing details of all API endpoints.
Excel File Structure
The exported Excel file contains the following columns:
- Endpoint: The URL path of the endpoint.
- Method: HTTP method (GET, POST, etc.).
- Description: Description of the endpoint.
- Parameters: List of parameters (query, path, etc.).
- Response Codes: List of possible HTTP response codes for the endpoint.
Example Output
| Endpoint | Method | Description | Parameters | Response Codes |
|---|---|---|---|---|
| /api/sample/ | GET | Returns a sample message | - | 200 |
| /api/sample/ | POST | Receives data | data, id | 201, 400 |
Contributing
Contributions are welcome! Please follow these steps to contribute:
- Fork the repository.
- Create a new branch (
feature/my-feature). - Commit your changes.
- Push to the branch.
- Open a Pull Request.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Support
For support or questions, please open an issue on the GitHub repository or contact the author via email.
Project details
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 drf-excel-export-0.1.3.tar.gz.
File metadata
- Download URL: drf-excel-export-0.1.3.tar.gz
- Upload date:
- Size: 5.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
118e0059ad82c78d9109cca704eb151ad20dbdd9f56dcdc3f43ee0ef72909137
|
|
| MD5 |
3152c5834971bdae40825780fb8e602e
|
|
| BLAKE2b-256 |
fa3096ee252c091b8dd84570e0c8f2186a52791eab1e610cac1203f8599da351
|
File details
Details for the file drf_excel_export-0.1.3-py3-none-any.whl.
File metadata
- Download URL: drf_excel_export-0.1.3-py3-none-any.whl
- Upload date:
- Size: 6.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
05e7b6fccd6d8deca85499bbab7d80f3b6a15798dc2b0eaba3d2e150d0eb8ff0
|
|
| MD5 |
b3dca9f13554b649a55759cd88e22469
|
|
| BLAKE2b-256 |
5d41b6eeb47c13be1225cb9039fac26d42f5ac24777b3c71cf1deeb8d15810ce
|