Skip to content

Commit

Permalink
Feature: Swagger API Docs
Browse files Browse the repository at this point in the history
- Installs drf_yasg
- Adds /api-docs url to view swaggerui
  • Loading branch information
danielsousaio committed Sep 27, 2019
1 parent 193ac6a commit bb96873
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
1 change: 1 addition & 0 deletions {{cookiecutter.project_slug}}/Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ django-bootstrap4 = "~=0.0.8"
django-allauth = "~=0.39.1"
django-rest-auth = "~=0.9.5"
django-extensions = "~=2.1.9"
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 Expand Up @@ -204,6 +205,10 @@
# end fcm_django push notifications
{% endif %}

# swagger config
# LOGIN_URL = "account_login"
# LOGOUT_URL = "account_logout"

if DEBUG:
# output email to console instead of sending
EMAIL_BACKEND = "django.core.mail.backends.console.EmailBackend"
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 bb96873

Please sign in to comment.