drf-spectacular

Sane, flexible OpenAPI 3.0/3.1/3.2 schema generation for Django REST Framework

Library
PyPI
v0.30.0
2,851stars
BSD 3-Clause License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
78/100Good
Development Activity80
Maintenance64
Community68
Maturity60
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
81/100Excellent
Architecture82
Code Quality84
Innovation80
Learning Curve78

drf-spectacular generates OpenAPI schemas directly from a Django REST Framework project’s serializers, views, and viewsets, going well beyond DRF’s built-in schema generator. It started as a heavily modified fork of DRF’s native OpenAPI generator, built specifically to extract more accurate schema information automatically, stay usable on real-world (not toy) APIs, and produce output that works cleanly with popular client-code generators like openapi-generator and Swagger Codegen.

The library covers the parts of API documentation that are otherwise painful to keep accurate by hand: nested/recursive serializer components, polymorphic responses, authentication scheme detection, i18n, request/response examples, and built-in extension points for a long list of common DRF add-ons (SimpleJWT, django-filter, django-oauth-toolkit, django-polymorphic, drf-nested-routers, Pydantic, and more).

What You Get

  • Automatic OpenAPI 3.0.3 / 3.1 / 3.2 schema generation from DRF serializers, views, viewsets, and function-based views
  • @extend_schema and @extend_schema_field decorators to override or augment inferred schema details (parameters, request/response bodies, examples, polymorphic responses)
  • Built-in SpectacularAPIView, Swagger UI, and Redoc views for serving and browsing the generated schema
  • Authentication scheme detection for DRF-native auth plus SimpleJWT, OAuth Toolkit, dj-rest-auth, and others out of the box
  • First-class integrations for django-filter, drf-nested-routers, django-polymorphic, Pydantic (>=2.0), and django-rest-framework-gis
  • Vendor extension (x-*) support across info, operations, parameters, components, and security schemes, plus i18n and sane operation_id naming

Common Use Cases

  • Generating an always-in-sync OpenAPI spec for a DRF API instead of hand-maintaining Swagger/YAML files
  • Serving interactive Swagger UI or Redoc documentation directly from a Django app with no extra infrastructure
  • Feeding a generated schema into client-code generators (TypeScript, Java, etc.) to produce typed API clients
  • Documenting polymorphic or deeply nested serializer responses that DRF’s built-in schema generator can’t express
  • Auditing an API’s authentication and permission surface via the generated security schemes

Under The Hood

Architecture — The package is organized as a Django app (drf_spectacular/) with generators.py performing the core schema-building walk over a DRF Router/APIView set, openapi.py assembling the resulting OpenAPI document, and plumbing.py/utils.py housing the serializer/field introspection helpers that turn DRF component types into OpenAPI schema fragments. extensions.py implements an extension-point system (OpenApiSerializerExtension, OpenApiAuthenticationExtension, etc.) that the contrib/ package uses to register first-class support for third-party libraries (SimpleJWT, django-filter, Pydantic, django-oauth-toolkit) without touching the core generator. views.py/renderers.py expose the schema and Swagger/Redoc UI as ordinary DRF views.

Tech Stack — Pure Python, built against Django and Django REST Framework, packaged with a standard pyproject.toml/setup.cfg, using PyYAML/uritemplate/jsonschema as core runtime dependencies and an extensive requirements/ directory of optional dependencies for each contrib integration it supports.

Code Quality — The tests/ directory is large and organized by feature area (test_basic.py, test_callbacks_split_request.yml, a dedicated tests/contrib/ suite per third-party integration, and both OAS 3.0 and 3.1 golden-file fixtures), run via runtests.py/tox.ini across multiple Django/DRF version combinations, with Codecov coverage tracking. The project ships a py.typed marker and has years of continuous, active maintenance (drf-spectacular is the de facto standard OpenAPI generator for DRF, having effectively superseded drf-yasg).

API Design — Zero-config usage works for straightforward serializers (add it to INSTALLED_APPS, point DEFAULT_SCHEMA_CLASS at it, done), while the @extend_schema decorator gives an escape hatch for every case introspection can’t resolve alone — extra parameters, response overrides per status code, polymorphic responses, and per-field type hints via @extend_schema_field. The contrib/ extension mechanism means adopting a supported third-party library (SimpleJWT, django-filter) requires no manual schema code at all, which keeps the common path close to zero-boilerplate despite the underlying introspection being substantial.

Used by 12 apps in this directory

Python
54%
Other

authentik

Authentication · Security

24,980

The self-hosted Identity Provider that replaces Okta, Auth0, and Entra ID with a unified SSO platform supporting SAML, OAuth2/OIDC, LDAP, RADIUS, and WebAuthn.

View details
92
Repo Health
81
Technical
68
Dependency
Built with
Python54%
TypeScript33%
Updated today
Python
68%
Other

Baserow

No Code Platforms · Databases

5,635

Open-source no-code platform to build databases, apps, automations, and AI agents — self-hosted or cloud, with full data ownership.

View details
89
Repo Health
84
Technical
68
Dependency
Built with
Python68%
JavaScript15%
Vue12%
Updated today
Python
83%
Other

Bugsink

Developer Tools · Monitoring

2,018

Self-hosted error tracking that accepts Sentry SDKs out of the box, so you keep your instrumentation and drop the monthly bill.

View details
84
Repo Health
80
Technical
76
Dependency
Built with
Python83%
HTML15%
Updated 1 weeks ago
Python
64%
BSD 3

Flagsmith

Developer Tools · Devops · Ab Testing Experimentation

6,518

Open-source feature flagging, remote config, and A/B/multivariate testing platform for web, mobile, and server-side apps — self-host or use the hosted SaaS.

View details
91
Repo Health
82
Technical
65
Dependency
Built with
Python64%
TypeScript31%
Updated today
TypeScript
38%
Apache 2.0

Label Studio

AI Development · Data Engineering

28,083

Label Studio is an open-source, multi-type data labeling platform that lets teams annotate images, text, audio, video, and time series data with a configurable XML-based UI and export annotations in formats ready for any ML framework.

View details
93
Repo Health
87
Technical
68
Dependency
Built with
TypeScript38%
JavaScript27%
Python25%
Updated today
Python
60%
MIT

LibrePhotos

File Storage

8,044

Self-hosted photo library with AI-powered face recognition, semantic search, and automatic event albums — no cloud required.

View details
82
Repo Health
78
Technical
67
Dependency
Built with
Python60%
TypeScript37%
Updated 3 days ago
Python
45%
GPL 3.0

MaxKB

AI Development · Knowledge Management

22,539

Build enterprise-grade AI agents with RAG, workflows & multi-modal support

View details
91
Repo Health
68
Technical
66
Dependency
Built with
Python45%
Vue37%
TypeScript17%
Updated today
Python
61%
GPL 3.0

Paperless-ngx

Bookmarks Archiving

44,394

Turn your paper pile into a searchable digital archive with OCR, AI classification, and automated workflows — all running on your own server.

View details
91
Repo Health
88
Technical
70
Dependency
Built with
Python61%
TypeScript30%
Updated today
Python
55%
Other

PostHog

Analytics · Monitoring · Developer Tools

37,777

The all-in-one open source product platform combining analytics, session replay, feature flags, error tracking, AI observability, and a built-in data warehouse in a single self-hostable stack.

View details
92
Repo Health
80
Technical
67
Dependency
Built with
Python55%
TypeScript36%
Updated today

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search