Django REST Swagger
django-rest-swagger provides Swagger UI integration for Django REST Framework (DRF) 3.5+. The project is currently at version 2.2.0, released in 2017, and is in maintenance mode. New projects are strongly advised to use modern alternatives like drf-yasg or drf-spectacular for OpenAPI/Swagger documentation.
Warnings
- deprecated The `django-rest-swagger` library is deprecated and is in maintenance mode, receiving only critical bug fixes. It's built against older DRF versions and Swagger UI v3.13.6, making it unsuitable for modern projects.
- breaking Version 2.0.0 introduced significant breaking changes, shifting from introspection/YAML overrides to CoreAPI and renderer classes for schema generation, and requiring Django REST Framework 3.4+.
- breaking Version 2.1.0 increased the minimum required Django REST Framework version to 3.5.1.
- gotcha Authentication support, especially for non-session APIs (e.g., Token or JWT authentication), might be limited or require custom workarounds due to the older Swagger UI version and bootstrap client architecture.
Install
-
pip install django-rest-swagger
Imports
- get_swagger_view
from rest_framework_swagger.views import get_swagger_view
Quickstart
# settings.py
INSTALLED_APPS = [
# ...
'rest_framework',
'rest_framework_swagger',
]
# urls.py
from django.urls import re_path
from rest_framework_swagger.views import get_swagger_view
# Replace 'My API' with your project's title
schema_view = get_swagger_view(title='My API')
urlpatterns = [
# ... other url patterns
re_path(r'^swagger/$', schema_view)
]