Skip to main content

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-spectacular and drf-yasg for OpenAPI schema generation.
  • Outputs an organized Excel file (api_documentation.xlsx) with all API documentation.

Installation

  1. Install the Package:

    pip install drf-excel-export
    
  2. Add to Django INSTALLED_APPS: Add drf_excel_export to your INSTALLED_APPS in your Django project’s settings.py:

    INSTALLED_APPS = [
        ...,
        'drf_excel_export',
    ]
    
  3. Configure drf-spectacular or drf-yasg (if not already installed): Install and configure either drf-spectacular or drf-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.py if 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:

  1. Fork the repository.
  2. Create a new branch (feature/my-feature).
  3. Commit your changes.
  4. Push to the branch.
  5. 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][mailto:donaldtedom0@gmail.com].

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

drf-excel-export-0.1.0.tar.gz (5.1 kB view details)

Uploaded Source

Built Distribution

drf_excel_export-0.1.0-py3-none-any.whl (6.3 kB view details)

Uploaded Python 3

File details

Details for the file drf-excel-export-0.1.0.tar.gz.

File metadata

  • Download URL: drf-excel-export-0.1.0.tar.gz
  • Upload date:
  • Size: 5.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.15

File hashes

Hashes for drf-excel-export-0.1.0.tar.gz
Algorithm Hash digest
SHA256 04e811bb6fbd6eb5253b5a4f5258a66978587660d2b40636a0548aacb7fe0a9d
MD5 54206bb8b5491957cd571565dd201f24
BLAKE2b-256 25179c9c5ff80f65bcdf4ab139e904eb65a4ae098f6d98d489d0afd61c7b407a

See more details on using hashes here.

File details

Details for the file drf_excel_export-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for drf_excel_export-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a99c3889c100d574d76cbc566ce6b11984350ef348969140b561a21edfa65983
MD5 9581fed567a69438598fbd7f7af3f1e4
BLAKE2b-256 1d26d3fd06d082f35b98bc9b0601b6a25dc5709bd1109942a238b19b9d695f5d

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page