Skip to main content

🗡️Djagger - OpenAPI schema generator for Django using pydantic

Package Badge Pypi Badge

Automated OpenAPI documentation generator for Django. Djagger provides you with a clean and straightforward way to generate a comprehensive API documentation of your Django project by utilizing pydantic to create schema objects for your views.

Example Django project using Djagger:

Generated API documentation from the example project:

Djagger repo:

Full Documentation:

Djagger is designed to be:

🧾 Comprehensive - Every aspect of your API should be document-able straight from your views, to the full extent of the OpenAPi 3.0 specification.

👐 Unintrusive - Integrate easily with your existing Django project. Djagger can document vanilla Django views (function-based and class-based views), as well as any Django REST framework views. As long as you are using Django’s default URL routing, you are good to go. You do not need to redesign your APIs for better documentation.

🍭 Easy - Djagger uses pure, unadulterated pydantic models to generate schemas. If you have used pydantic, there is no learning curve. If you have not heard of pydantic, it is a powerful data validation library that is pretty straightforward to pickup (like dataclasses). Check it out here. Either way, documenting your APIs will feel less like a chore.

Quickstart

Install using pip

pip install djagger

Add djagger to your INSTALLED_APPS setting in your Django project like this:

INSTALLED_APPS = [
    ...
    'djagger',
]

Include the djagger URLconf in your project urls.py like this if you want to use the built-in document views.

urlpatterns = [
    ...
    path('djagger/', include('djagger.urls')),
]

Examples

Example GET Endpoint

from rest_framework.views import APIView
from rest_framework.response import Response
from pydantic import BaseModel as Schema
import datetime


class ArticleDetailSchema(Schema):
    created : datetime.datetime
    title : str
    author : str
    content : str


class RandomArticleAPI(APIView):
    """Return a random article from the Blog"""

    response_schema = ArticleDetailSchema

    def get(self, request):
        ...
        return Response({})

Generated documentation

UserDetailsAPI Redoc

Example POST Endpoint

from rest_framework.views import APIView
from rest_framework.response import Response
from pydantic import BaseModel as Schema, Field
import datetime


class ArticleDetailSchema(Schema):
    created : datetime.datetime
    title : str
    author : str
    content : str

class ArticleCreateSchema(Schema):
    """POST schema for blog article creation"""
    title : str = Field(description="Title of Blog article")
    content : str = Field(description="Blog article content")


class ArticleCreateAPI(APIView):

    request_schema = ArticleCreateSchema
    response_schema = ArticleDetailSchema

    def post(self, request):
        ...
        return Response({})

Generated documentation

CreateItemAPI Redoc

For more involved examples, check out the example project and the API documentation generated from that project.

Documentation & Support

  • Read the full documentation for Djagger: https://djagger-docs.netlify.app

  • This project is in continuous development. If you have any questions or would like to contribute, please email royhung@protonmail.com

  • If you want to support this project, do give it a ⭐ on github!

Metadata

Release files for djagger 1.1.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for djagger 1.1.4
File Size Uploaded Provenance Actions
djagger-1.1.4.tar.gz 3.0 MB Without provenance Details for djagger-1.1.4.tar.gz

Release files / djagger-1.1.4.tar.gz

Download URL djagger-1.1.4.tar.gz
Size 3.0 MB
Tags Source
SHA-256 checksum
How to use checksums
98548f2facc3a1b77c2c2a1a9a15dc371c27ba7c4160ea2ead62dcb57e27076e
BLAKE2b-256 checksum
How to use checksums
7aa2df7a140aabada2c727352114c82d88ec1553cbd546ab7233a6ee8f1e34af
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.64.0 importlib-metadata/4.8.3 keyring/23.4.1 rfc3986/1.5.0 colorama/0.4.4 CPython/3.6.9

Security for djagger 1.1.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page