Skip to content

Latest commit

 

History

History
52 lines (34 loc) · 1.27 KB

README.md

File metadata and controls

52 lines (34 loc) · 1.27 KB

Scalar API Reference for Django Ninja

Discord

The easiest way to render a modern and beautiful API reference based on your Django Ninja OpenAPI document.

django-ninja

Installation

pip install git+https://github.com/scalar/scalar.git#subdirectory=packages/scalar_django_ninja

Usage

Integrating Scalar with Django Ninja is simple. Just pass the ScalarViewer instance to the docs parameter of the NinjaAPI instance.

from ninja import NinjaAPI
from scalar_django_ninja import ScalarViewer

api = NinjaAPI(
    version="1.0.0",
    title="API Reference",
    description="API Reference for the Scalar Django Ninja Plugin",
    docs=ScalarViewer(),
    docs_url="/docs/",
)

@api.get("/add")
def add(request, a: int, b: int):
    return {"result": a + b}


urlpatterns = [
    path("admin/", admin.site.urls),
    path("api/", api.urls),
]

This renders a beautiful API reference at /api/docs based on your API.

Community

We are API nerds. You too? Let’s chat on Discord: https://discord.gg/scalar

License

The source code in this repository is licensed under MIT.