Open-source tool that generates a responsive, three-panel API reference site from OpenAPI, Swagger, AsyncAPI, or GraphQL definitions.
axnsan12/drf-yasg
Generates real Swagger/OpenAPI 2.0 specifications and interactive docs from Django REST Framework APIs.
- Stars
- 3,545
- Forks
- 439
- Open issues
- 218
- Last commit
- 28 days ago
What is it?
drf-yasg inspects Django REST Framework views and serializers and produces an OpenAPI 2.0 (Swagger) schema from them, so API documentation reflects the code rather than being maintained by hand. The schema can be served as JSON or YAML, and the library bundles swagger-ui and ReDoc so the generated documentation can be browsed directly from the project.
Setup is a matter of adding the app to INSTALLED_APPS and wiring a schema view into urls.py. Nested serializers are supported, and hooks are available at each stage of spec generation for customization. Caching is built in, and the schema can optionally be validated with swagger-spec-validator.
The project targets OpenAPI 2.0 only. Its maintainers point new projects that need OpenAPI 3.0 toward drf-spectacular, and the README notes that drf-yasg is unlikely to add 3.0 support.
Key features
- 01Generates Swagger/OpenAPI 2.0 specs from DRF views and serializers, including nested serializers.
- 02Serves the spec as JSON or YAML.
- 03Bundles swagger-ui and ReDoc for browsing the documentation.
- 04Provides customization hooks throughout spec generation.
- 05Supports optional validation with swagger-spec-validator and built-in response caching.
- 06Works with URLPathVersioning and NamespaceVersioning.
Use cases
- Documenting an existing Django REST Framework API without writing the spec by hand.
- Producing an OpenAPI 2.0 file for client code generation with swagger-codegen.
- Exposing interactive API docs to internal or public developers from a Django project.
Topics
FAQ
- What is drf-yasg?
- Generates real Swagger/OpenAPI 2.0 specifications and interactive docs from Django REST Framework APIs. drf-yasg inspects Django REST Framework views and serializers and produces an OpenAPI 2.0 (Swagger) schema from them, so API documentation reflects the code rather than being maintained by hand. The schema can be served as JSON or YAML, and the library bundles swagger-ui and ReDoc so the generated documentation can be browsed directly from the project.
- Is drf-yasg free to use? What license does it have?
- drf-yasg is open source under the Other license. Check the license terms before using it in commercial products.
- Is drf-yasg still maintained?
- Actively maintained. The last commit to drf-yasg was on Oct 9, 2026.
- What can I use drf-yasg for?
- Documenting an existing Django REST Framework API without writing the spec by hand. Producing an OpenAPI 2.0 file for client code generation with swagger-codegen. Exposing interactive API docs to internal or public developers from a Django project.
- Where can I get drf-yasg?
- The source code and installation instructions are on GitHub: https://github.com/axnsan12/drf-yasg
Summary generated by AI from the project's README. GitHub stats refresh daily.
Related projects
Java library that generates OpenAPI specifications from code annotations and JAX-RS REST APIs, supporting OpenAPI 3.x.
Swagger UI renders interactive API documentation in the browser from an OpenAPI/Swagger specification file.
Open-source OpenAPI/Swagger toolkit with an interactive API reference, an offline-first API client, and integrations for many web frameworks.
Go tool that generates Swagger 2.0 API documentation from annotations written in your Go source code comments.
A Python web framework for building type-hinted REST APIs on top of Django, with automatic OpenAPI docs and Pydantic validation.