drf-yasg
Automated generation of real Swagger/OpenAPI 2.0 schemas from Django Rest Framework code.
Decision gist · record as of 2026-08-14
Yes. drf-yasg is a mature, actively maintained tool for Django REST Framework projects that need Swagger/OpenAPI 2.0 documentation. Low install friction, no security issues, and permissive licensing make it a straightforward choice. The main caveat is that it targets OpenAPI 2.0, not 3.0; if you need OpenAPI 3.0 support, consider drf-spectacular instead. For existing DRF projects or new ones committed to OpenAPI 2.0, this is a reliable dependency.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Requires Django and Django REST Framework installed; static files must be served (django.contrib.staticfiles required).
- Low friction installation with a pure-Python wheel.
- Actively maintained with a recent release; supports current Django (4.0–5.2) and Python (3.9–3.13) versions.
License · maintenance · safety
BSD-3-Clause (permissive) — BSD-3-Clause permissive license allows commercial and private use with minimal restrictions; you must include a copy of the license and retain copyright notices.
last release 2026-02-24 (171 days) · last repo commit 2026-07-20 · 3,545 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 3,099,552 downloads/mo, #2,755 on PyPI
Alternatives
Verify before relying
pip install drf-yasg
# In settings.py
INSTALLED_APPS = ['django.contrib.staticfiles', 'drf_yasg', ...]
# In urls.py
from drf_yasg.views import get_schema_view
from drf_yasg import openapi
schema_view = get_schema_view(
openapi.Info(title="API", default_version='v1'),
public=True,
)
urlpatterns = [
path('swagger/', schema_view.with_ui('swagger', cache_timeout=0), name='schema-swagger-ui'),
]- Whether the package's OpenAPI 2.0 output is compatible with all code generation tools mentioned in the description.
- Performance impact of schema generation on larger APIs beyond the caching mitigation described.
What it is and what it does
drf-yasg is a code-first API documentation tool for Django REST Framework that introspects your DRF views and serializers to generate a Swagger/OpenAPI 2.0 specification. It bundles swagger-ui and ReDoc viewers, so you get interactive documentation endpoints out of the box—no manual schema writing required. The generated specs can be served as JSON or YAML and are cacheable for performance.
The package handles nested serializers, response schemas, and model definitions compatible with code generation tools. It supports DRF's URLPathVersioning and NamespaceVersioning schemes. The documentation notes that OpenAPI 3.0 support is unlikely; for new projects targeting OpenAPI 3.0, the maintainers recommend drf-spectacular instead. Validation against the OpenAPI 2.0 spec is optional but can catch schema errors at generation time.
Use it for
- Auto-generate interactive API documentation for a Django REST Framework service without writing YAML or JSON by hand.
- Expose Swagger UI and ReDoc viewers at standard endpoints for API consumers to explore and test endpoints.
- Generate OpenAPI 2.0 specs for code generation tools to produce client libraries in other languages.
- Validate generated schemas against the OpenAPI 2.0 spec to catch structural errors early in development.
- Cache the schema view to avoid regenerating specs on every request in production.
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes.
drf-yasg is a mature, actively maintained tool for Django REST Framework projects that need Swagger/OpenAPI 2.0 documentation. Low install friction, no security issues, and permissive licensing make it a straightforward choice. The main caveat is that it targets OpenAPI 2.0, not 3.0; if you need OpenAPI 3.0 support, consider drf-spectacular instead. For existing DRF projects or new ones committed to OpenAPI 2.0, this is a reliable dependency.
Install
drf-yasg on PyPI
Before you install
Low friction installation with a pure-Python wheel. Actively maintained with a recent release; supports current Django (4.0–5.2) and Python (3.9–3.13) versions. No known vulnerabilities.
Requires Django and Django REST Framework installed; static files must be served (django.contrib.staticfiles required).
License in practice
BSD-3-Clause permissive license allows commercial and private use with minimal restrictions; you must include a copy of the license and retain copyright notices.
Quickstart
pip install drf-yasg
# In settings.py
INSTALLED_APPS = ['django.contrib.staticfiles', 'drf_yasg', ...]
# In urls.py
from drf_yasg.views import get_schema_view
from drf_yasg import openapi
schema_view = get_schema_view(
openapi.Info(title="API", default_version='v1'),
public=True,
)
urlpatterns = [
path('swagger/', schema_view.with_ui('swagger', cache_timeout=0), name='schema-swagger-ui'),
]
Verify before relying
- Whether the package's OpenAPI 2.0 output is compatible with all code generation tools mentioned in the description.
- Performance impact of schema generation on larger APIs beyond the caching mitigation described.
Package facts
| License | BSD-3-Clause permissive |
| Python support | Supports the current Python release >=3.9 |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | 7 packagesdjangodjangorestframeworkinflectionpackagingpytzpyyamluritemplate |
| Maintenance | Actively maintained 171 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 3,099,552 / month, #2,755 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | Development Status :: 5 - Production/StableEnvironment :: Web EnvironmentFramework :: DjangoFramework :: Django :: 4.0Framework :: Django :: 4.1Framework :: Django :: 4.2Framework :: Django :: 5.0Framework :: Django :: 5.1Framework :: Django :: 5.2Intended Audience :: DevelopersOperating System :: OS IndependentProgramming Language :: PythonProgramming Language :: Python :: 3Programming Language :: Python :: 3 :: OnlyProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.9Topic :: DocumentationTopic :: Software Development :: Code Generators |
Evidence: drf_yasg-1.21.15-py3-none-any.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “openapi 2.0 schema django”
- drf-yasgGenerates Swagger/OpenAPI 2.0 specifications automatically from…
- flexValidates Swagger 2.0 API specifications against JSON Schema and…
- drf-spectacularGenerates OpenAPI 3.0.3, 3.1, and 3.2 schemas automatically from…
Give your agent the search over MCP, or paste the wish link into any chat.
More Documentation packages
Docutils converts plaintext documentation in reStructuredText format into multiple output formats including HTML, XML, and LaTeX using a modular processing system.
Sphinx generates professional documentation from reStructuredText source files, producing HTML, PDF, EPUB, and other formats with automatic cross-references, code highlighting, and hierarchical navigation.
Griffe extracts the complete structure and signatures of Python programs to generate API documentation or detect breaking changes in your project's public API.
Install it if you need to programmatically inspect Python code structure, generate API docs, or enforce API stability in CI.
A Sphinx extension that outputs documentation in serialized HTML formats (JSON and pickle) alongside standard HTML.
Alabaster is a clean, responsive Sphinx theme for documentation that requires Python 3.10 or newer and Sphinx 6.2 or newer.
A Sphinx extension that generates HTML help files from reStructuredText documentation source.
See also django-rest-swagger · drf-spectacular · drf-spectacular-sidecar · bravado · flask-swagger · connexion · bravado-core · essentials-openapi · drf-spectacular-jsonapi · spectree