Install & Compatibility
Where this runs
tested against v1.21.15 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.95 runs
installs and imports cleanly · install 0.0s · import 0.000s · 93.8MB
glibcpy 3.10–3.95 runs
installs and imports cleanly · install 4.6s · import 0.000s · 95MB
94MB installed
● package 94MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
get_schema_view
✓ from drf_yasg import get_schema_view
✗ from drf_yasg import get_schema_view
To quickly integrate drf-yasg, add 'drf_yasg' to your `INSTALLED_APPS` in `settings.py`. Then, include these URL patterns in your project's `urls.py`. This setup provides endpoints for the OpenAPI schema in JSON/YAML, the interactive Swagger UI, and the ReDoc documentation.
from django.urls import path, re_path
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="My API",
default_version='v1',
description="Test description",
terms_of_service="https://www.google.com/policies/terms/",
contact=openapi.Contact(email="contact@snippets.local"),
license=openapi.License(name="BSD License"),
),
public=True,
permission_classes=(permissions.AllowAny,),
)
urlpatterns = [
re_path(r'^swagger(?P<format>\.json|\.yaml)$', schema_view.without_ui(cache_timeout=0), name='schema-json'),
path('swagger/', schema_view.with_ui('swagger', cache_timeout=0), name='schema-swagger-ui'),
path('redoc/', schema_view.with_ui('redoc', cache_timeout=0), name='schema-redoc'),
]
Debug
Known issues
breakingdrf-yasg no longer guarantees preservation of schema field order due to a change from `OrderedDict` to native `dict` for schema generation.fixReview any client-side or external tools that strictly rely on the order of fields in the generated OpenAPI schema. Most OpenAPI consumers should not depend on field order, but if specific integrations break, consider custom schema generation or alternative validation.
affects: 1.21.15 and higher
deprecatedPython 3.6 support has been officially dropped. Installations on Python 3.6 may encounter issues or lack new features.fixUpgrade your Python environment to 3.7 or higher. The library officially supports Python 3.9+.
affects: 1.21.5 and higher
gotchaIssues with `from __future__ import annotations` and complex type hints, especially on Python 3.12, could lead to schema generation failures.fixEnsure you are on drf-yasg 1.21.15 or newer, which includes fixes for Python 3.12 type parameter syntax. For older versions or other type hint issues, review your type hint usage or consider temporarily disabling `from __future__ import annotations` if possible.
affects: Pre-1.21.15 (especially with Python 3.12)
gotchaWhen using `django-filter`, filter parameters might not appear in the generated Swagger UI if the drf-yasg version is too old.fixUpgrade drf-yasg to 1.21.11 or higher, which includes a fix for `django-filter>=25` compatibility.
affects: Pre-1.21.11
deprecatedThe `drf_yasg.inspectors.coreapi.CoreAPICompatInspector` has been replaced by `drf_yasg.inspectors.query.DrfAPICompatInspector`.fixIf you were using custom inspectors based on `CoreAPICompatInspector`, update your configuration to use `DrfAPICompatInspector` for improved compatibility and future-proofing.
affects: 1.21.7 and higher
Upgrade
Version history
1.21.15latest on PyPI · released Feb 24, 2026
Audit
Dependencies
djangorestframeworkrequiredCore dependency for schema generation. While not a direct pip dependency, it's required for drf-yasg to function.
DjangorequiredCore framework dependency. While not a direct pip dependency, it's required for drf-yasg to function.
PyYAMLrequiredUsed for YAML schema generation, became a direct dependency in 1.21.6.
django-filteroptionalOptional. If using django-filter for API filtering, ensure compatibility with drf-yasg.