--- id: drf-spectacular version: "0.30.0" license: BSD-3-Clause license_treatment: permissive maintenance: active --- # drf-spectacular — Sane and flexible OpenAPI 3 schema generation for Django REST framework License: permissive · Maintenance: active · Downloads: 13.9M/mo ## What it is and what it does drf-spectacular is an OpenAPI schema generator for Django REST framework that extracts API structure directly from your code and produces valid OpenAPI 3.0.3, 3.1, or 3.2 specifications. It replaces the basic schema generation built into DRF with a more capable alternative that handles real-world API patterns: nested and recursive serializers, polymorphic responses, custom authentication schemes, and vendor extensions. The package works out of the box with sensible defaults but offers deep customization through the @extend_schema decorator and settings, allowing you to override serializers, add examples, control operation IDs, and adjust how components are split. The tool integrates with popular DRF extensions (SimpleJWT, django-filter, Pydantic, django-polymorphic) and provides built-in views to serve the schema via Swagger UI or Redoc. You can generate schemas via CLI (./manage.py spectacular) or serve them live from your API. It depends on Django, djangorestframework, uritemplate, PyYAML, jsonschema, inflection, and typing-extensions—all lightweight, widely-used libraries. Use it for: - Generate and serve interactive API documentation (Swagger UI or Redoc) directly from your Django REST framework code. - Export OpenAPI schemas for use with code generators (client SDKs, mock servers) or third-party API tools. - Document complex APIs with nested serializers, polymorphic responses, and custom authentication without manual schema writing. - Validate API schemas during CI/CD pipelines using the --validate CLI flag. - Customize schema output per-endpoint using @extend_schema decorators to override auto-detected types or add examples. ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. Generates OpenAPI 3.0.3, 3.1, and 3.2 schemas automatically from Django REST framework APIs, with extensive customization options for real-world use cases. Yes. drf-spectacular is actively maintained, has no known vulnerabilities, installs with low friction, and is licensed permissively. It solves a real problem—generating accurate OpenAPI documentation from Django REST framework code—and is widely used (top 5000 PyPI packages). Install it if you need OpenAPI schemas for a DRF API and want automation over manual maintenance. ## Install pip install drf-spectacular uv add drf-spectacular poetry add drf-spectacular ## Installing drf-spectacular Before you install: Low friction install with a pure-Python wheel. Actively maintained with a recent release (39 days ago) and 2851 repository stars. Depends on Django, djangorestframework, and several lightweight utilities (uritemplate, PyYAML, jsonschema, inflection, typing-extensions). License in practice: Licensed under BSD-3-Clause (permissive), allowing commercial and private use with minimal restrictions—only requiring license and copyright notice inclusion. Quickstart: pip install drf-spectacular # In settings.py INSTALLED_APPS = ['drf_spectacular'] REST_FRAMEWORK = {'DEFAULT_SCHEMA_CLASS': 'drf_spectacular.openapi.AutoSchema'} # In urls.py from drf_spectacular.views import SpectacularAPIView urlpatterns = [path('api/schema/', SpectacularAPIView.as_view(), name='schema')] Requires Django 3.2+ and Django REST Framework 3.12+; Python >= 3.8. Verify before relying: - Whether the package's schema generation works correctly with all listed framework versions without manual intervention. - Performance characteristics when generating schemas for large or deeply nested API structures. - Compatibility with third-party DRF extensions beyond those explicitly listed in the description. ## Package facts - License: BSD-3-Clause (permissive) - Python support: supports_current - Install friction: low - Maintenance: active - Downloads: 13.9M/month (top 5,000 on PyPI) - Known vulnerabilities: none known ## Tags openapi schema generation django, drf api documentation, swagger ui django rest, rest framework openapi, api schema generator django, rest api documentation tool, openapi 3 django, api-documentation, code-generation, django-extension [View on SkillFed](https://skillfed.io/packages/drf-spectacular) · [View on PyPI](https://pypi.org/project/drf-spectacular/)