'Swagger-like' API Documentation for Django Rest Framework

Introduction

It is said that, today’s internet is much more than HTML-powered websites.

Developers need to support AJAX  and native mobile apps.

The defacto package for building these REST APIs with Django is Django REST Framework , it allows you create a json API with extra functionalities.

Django REST Framework Docs (DRF Docs) allows you to list all your API Endpoints that inherit from Django REST Framework automatically. Its purpose is to work out of the box and it should take a minimum to install it.




Installation in just 3 steps:

1. Install using pip:

pip install drfdocs


2. Add 'rest_framework_docs' to your INSTALLED_APPS setting:
INSTALLED_APPS = (
    ...
    'rest_framework_docs',
)

3. Finally include the rest_framework_docs urls in your urls.py:
urlpatterns = [
    ...
    url(r'^docs/', include('rest_framework_docs.urls')),
]

How It Works

The concept is pretty simple.
Once you install it you should go the the url you set (ie. http://0.0.0.0:8000/docs/) and you should see all your API endpoints along with the serializer fields, allowed methods etc for each one.

DRF Docs will then read all your urls and will list those that inherit from Django REST Framework's APIView.

Comments

Popular Posts