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

***Note: If you are looking for a Full Stack Developer (Django+React), then connect with me on*** [***LinkedIn***](https://www.linkedin.com/in/mnamegaurav/) ***or contact me through my*** [***portfolio***](https://gaurav.devjunction.in/)***.***

## Let's directly jump into the steps without wasting any time.

* Open your **root** `urls.py` and paste this code at the end of your `urls.py` file -
    

```python
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`, `viewsets` or `view classes` -
    
    Add this at the end of your `settings.py` file -
    

```python
REST_FRAMEWORK = {
    'DEFAULT_SCHEMA_CLASS': 'rest_framework.schemas.coreapi.AutoSchema',
}
```

* One final step is to install a `pip` package in your project's virtual environment -
    

```bash
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](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/](https://www.linkedin.com/in/mnamegaurav/)
    
* **YouTube:** [https://www.youtube.com/c/devjunction](https://www.youtube.com/c/devjunction)
    
* **Website:** [https://gaurav.devjunction.in/](https://gaurav.devjunction.in/)
    
* **GitHub:** [https://github.com/mnamegaurav](https://github.com/mnamegaurav)
    
* **Instagram:** [https://www.instagram.com/mnamegaurav/](https://www.instagram.com/mnamegaurav/)
    
* **Twitter:** [https://twitter.com/mnamegaurav](https://twitter.com/mnamegaurav)
