From cf4c5509d93ed74eebaf12bb7550365644ee3fb3 Mon Sep 17 00:00:00 2001 From: Leandro Roberto Date: Mon, 5 Aug 2019 16:33:12 -0300 Subject: [PATCH] =?UTF-8?q?HOT-FIX:=20altera=20inclus=C3=A3o=20de=20drf-ya?= =?UTF-8?q?sg?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Configura urls drf-yasg se ele está presente na lista de apps do projeto --- sapl/api/urls.py | 45 +++++++++++++++++++++++---------------------- 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/sapl/api/urls.py b/sapl/api/urls.py index 27196146d..4fc853e08 100644 --- a/sapl/api/urls.py +++ b/sapl/api/urls.py @@ -1,7 +1,5 @@ from django.conf import settings from django.conf.urls import include, url -from drf_yasg import openapi -from drf_yasg.views import get_schema_view from rest_framework import permissions from rest_framework.routers import DefaultRouter @@ -29,26 +27,29 @@ for app, built_sets in SaplApiViewSetConstrutor._built_sets.items(): urlpatterns_router = router.urls - -schema_view = get_schema_view( - openapi.Info( - title="Sapl API - docs", - default_version='v1', - description="Sapl API - Docs - Configuração Básica", - ), - url=settings.SITE_URL, - public=True, - permission_classes=(permissions.AllowAny,), -) - -urlpatterns_api_doc = [ - url(r'^docs/swagger(?P\.json|\.yaml)$', - schema_view.without_ui(cache_timeout=0), name='schema-json'), - url(r'^docs/swagger/$', - schema_view.with_ui('swagger', cache_timeout=0), name='schema-swagger-ui'), - url(r'^docs/redoc/$', - schema_view.with_ui('redoc', cache_timeout=0), name='schema-redoc'), -] +urlpatterns_api_doc = [] +if 'drf_yasg' in settings.INSTALLED_APPS: + from drf_yasg import openapi + from drf_yasg.views import get_schema_view + schema_view = get_schema_view( + openapi.Info( + title="Sapl API - docs", + default_version='v1', + description="Sapl API - Docs - Configuração Básica", + ), + url=settings.SITE_URL, + public=True, + permission_classes=(permissions.AllowAny,), + ) + + urlpatterns_api_doc = [ + url(r'^docs/swagger(?P\.json|\.yaml)$', + schema_view.without_ui(cache_timeout=0), name='schema-json'), + url(r'^docs/swagger/$', + schema_view.with_ui('swagger', cache_timeout=0), name='schema-swagger-ui'), + url(r'^docs/redoc/$', + schema_view.with_ui('redoc', cache_timeout=0), name='schema-redoc'), + ] # TODO: refatorar para customização da api automática deprecated_urlpatterns_api = [