How to auto generate Rest API Docs in Django Rest Framework with Open API schema for your Rest API?
Auto Generate Rest API Documentation in Django

Experienced Full Stack Software Engineer with 4+ Years of experience, proficient in Django and React, with expertise in Python, JavaScript and Typescript, also an author of Dev.Junction Blogs & YouTube Channel, expert in Python/Django, Rest Framework, ReactJS/NextJS and TypeScript, currently based in Pune, India.
Note: If you are looking for a Full Stack Developer (Django+React), then connect with me on LinkedIn or contact me through my portfolio.
Let's directly jump into the steps without wasting any time.
- Open your root
urls.pyand paste this code at the end of yoururls.pyfile -
from rest_framework.documentation import include_docs_urls
urlpatterns.extend([
# For autogenerated API documentation
path(
"api/docs/",
include_docs_urls(title="DevJunction API Docs"),
name='drf-doc'
),
])
Next step is to allow Django Rest Framework to use Open API schema generator for all the Rest API created using DRF
generics views,viewsetsorview classes-Add this at the end of your
settings.pyfile -
REST_FRAMEWORK = {
'DEFAULT_SCHEMA_CLASS': 'rest_framework.schemas.coreapi.AutoSchema',
}
- One final step is to install a
pippackage in your project's virtual environment -
pip install coreapi
- Yuhuuu! You did it, just run your project in local and open your browser and go this location to see the auto generated API docs - http://localhost:8000/api/docs
For more such crispy blogs, follow DevJunction, subscribe to our newsletter and get notified.
Social Links
LinkedIn: https://www.linkedin.com/in/mnamegaurav/
Website: https://gaurav.devjunction.in/
GitHub: https://github.com/mnamegaurav
Instagram: https://www.instagram.com/mnamegaurav/
Twitter: https://twitter.com/mnamegaurav






