Browse Source

HOT-FIX: altera inclusão de drf-yasg

Configura urls drf-yasg se ele está presente na lista de apps do projeto
pull/2916/head
Leandro Roberto 5 years ago
parent
commit
09b22e7bd0
  1. 15
      sapl/api/urls.py

15
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,8 +27,11 @@ for app, built_sets in SaplApiViewSetConstrutor._built_sets.items():
urlpatterns_router = router.urls
schema_view = get_schema_view(
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',
@ -39,16 +40,16 @@ schema_view = get_schema_view(
url=settings.SITE_URL,
public=True,
permission_classes=(permissions.AllowAny,),
)
)
urlpatterns_api_doc = [
urlpatterns_api_doc = [
url(r'^docs/swagger(?P<format>\.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 = [

Loading…
Cancel
Save