Skip to content

Commit

Permalink
Add swagger api docs to the scaffold (#25)
Browse files Browse the repository at this point in the history
* Feature: Swagger API Docs

- Installs drf_yasg
- Adds /api-docs url to view swaggerui

* Add packaging to Pipfile

`drf_yasg` needs `packaging` as per open issue:
axnsan12/drf-yasg#412

* Remove commented config
  • Loading branch information
danielsousaio authored Oct 3, 2019
1 parent 193ac6a commit 43af45a
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
2 changes: 2 additions & 0 deletions {{cookiecutter.project_slug}}/Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ django-bootstrap4 = "~=0.0.8"
django-allauth = "~=0.39.1"
django-rest-auth = "~=0.9.5"
django-extensions = "~=2.1.9"
packaging = "*"
drf-yasg = "~=1.16.1"
{% if cookiecutter.is_mobile == "y" %}
fcm-django = "~=0.2.21"
{% endif %}
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
'allauth.socialaccount',
'allauth.socialaccount.providers.google',
'django_extensions',
'drf_yasg',
{% if cookiecutter.is_mobile == "y" %}
# start fcm_django push notifications
'fcm_django',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
from django.contrib import admin
from django.urls import path, include
from allauth.account.views import confirm_email
from rest_framework import permissions
from drf_yasg.views import get_schema_view
from drf_yasg import openapi

urlpatterns = [
path('', include('home.urls')),
Expand All @@ -32,3 +35,18 @@
admin.site.site_header = '{{cookiecutter.project_name}}'
admin.site.site_title = '{{cookiecutter.project_name}} Admin Portal'
admin.site.index_title = '{{cookiecutter.project_name}} Admin'

# swagger
schema_view = get_schema_view(
openapi.Info(
title="{{cookiecutter.project_name}} API",
default_version="v1",
description="API documentation for {{cookiecutter.project_name}} App",
),
public=True,
permission_classes=(permissions.IsAuthenticated,),
)

urlpatterns += [
path("api-docs/", schema_view.with_ui("swagger", cache_timeout=0), name="api_docs")
]

0 comments on commit 43af45a

Please sign in to comment.