diff --git a/requirements/requirements.txt b/requirements/requirements.txt index f3ccf296c..9edac2949 100644 --- a/requirements/requirements.txt +++ b/requirements/requirements.txt @@ -14,7 +14,7 @@ django-speedinfo==1.4.0 django-extensions==2.1.4 django-image-cropping==1.2 django-webpack-loader==0.6.0 -django-rest-swagger==2.2.0 +drf-yasg==1.13.0 easy-thumbnails==2.5 python-decouple==3.1 psycopg2-binary==2.7.6.1 @@ -31,11 +31,4 @@ pysolr==3.6.0 whoosh==2.7.4 git+git://github.com/interlegis/trml2pdf.git -#git+git://github.com/jasperlittle/django-rest-framework-docs git+git://github.com/interlegis/django-admin-bootstrapped - -#django-compressor==2.2 -#django-bootstrap3==11.0.0 -#django-bower==5.2.0 -#django-sass-processor==0.7.2 -#libsass==0.17.0 diff --git a/sapl/api/urls.py b/sapl/api/urls.py index 752f8cb36..3fba0ea63 100644 --- a/sapl/api/urls.py +++ b/sapl/api/urls.py @@ -1,7 +1,9 @@ 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 - from rest_framework_swagger.views import get_swagger_view from sapl.api.views import (AutoresPossiveisListView, AutoresProvaveisListView, @@ -11,6 +13,7 @@ from sapl.api.views import (AutoresPossiveisListView, AutoresProvaveisListView, from .apps import AppConfig + app_name = AppConfig.name @@ -26,9 +29,8 @@ for app, built_sets in SaplSetViews.items(): urlpatterns_router = router.urls - +# TODO: refatorar para customização da api automática urlpatterns_api = [ - url(r'^autor/provaveis', AutoresProvaveisListView.as_view(), name='autores_provaveis_list'), url(r'^autor/possiveis', @@ -38,13 +40,28 @@ urlpatterns_api = [ url(r'^model/(?P\d+)/(?P\d*)$', ModelChoiceView.as_view(), name='model_list'), - ] -schema_view = get_swagger_view(title='Pastebin API') +schema_view = get_schema_view( + openapi.Info( + title="Sapl API - docs", + default_version='v1', + description="Sapl API - Docs - Configuração Básica", + ), + public=True, + permission_classes=(permissions.AllowAny,), +) urlpatterns_api += [ - url(r'^docs', schema_view), ] + 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 = [ url(r'^api/', include(urlpatterns_api)), diff --git a/sapl/settings.py b/sapl/settings.py index aa61f3512..113902da0 100755 --- a/sapl/settings.py +++ b/sapl/settings.py @@ -81,7 +81,8 @@ INSTALLED_APPS = ( 'crispy_forms', 'floppyforms', - 'rest_framework_swagger', + 'drf_yasg', + #'rest_framework_swagger', 'rest_framework', 'django_filters', diff --git a/setup.py b/setup.py index 31e35410f..e423ecb5a 100644 --- a/setup.py +++ b/setup.py @@ -25,6 +25,7 @@ install_requires = [ 'django-extensions==2.1.4', 'django-image-cropping==1.2.0', 'django-webpack-loader==0.6.0', + 'drf-yasg==1.13.0', 'easy-thumbnails==2.5', 'python-decouple==3.1', 'psycopg2-binary==2.7.6.1', @@ -41,14 +42,7 @@ install_requires = [ 'whoosh==2.7.4', # 'git+git://github.com/interlegis/trml2pdf.git', - # 'git+git://github.com/jasperlittle/django-rest-framework-docs', # 'git+git://github.com/interlegis/django-admin-bootstrapped', - - #'django-compressor==2.2', - #'django-bootstrap3==11.0.0', - #'django-bower==5.2.0', - #'django-sass-processor==0.7.2', - #'libsass==0.17.0', ] setup( name='interlegis-sapl',