From 6ed53de9fcb5c64e77434abad6a9c07af3277f32 Mon Sep 17 00:00:00 2001 From: Leandro Roberto Date: Mon, 11 Feb 2019 14:43:09 -0200 Subject: [PATCH] =?UTF-8?q?inicia=20configura=C3=A7=C3=A3o=20do=20drf=20do?= =?UTF-8?q?cs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- requirements/requirements.txt | 3 ++- sapl/api/urls.py | 9 ++++++--- sapl/settings.py | 4 +++- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/requirements/requirements.txt b/requirements/requirements.txt index bbf48a155..834cb6dea 100644 --- a/requirements/requirements.txt +++ b/requirements/requirements.txt @@ -14,6 +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 easy-thumbnails==2.5 python-decouple==3.1 psycopg2-binary==2.7.6.1 @@ -30,7 +31,7 @@ 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/jasperlittle/django-rest-framework-docs git+git://github.com/interlegis/django-admin-bootstrapped #django-compressor==2.2 diff --git a/sapl/api/urls.py b/sapl/api/urls.py index 88d78a634..752f8cb36 100644 --- a/sapl/api/urls.py +++ b/sapl/api/urls.py @@ -2,6 +2,8 @@ from django.conf import settings from django.conf.urls import include, url from rest_framework.routers import DefaultRouter +from rest_framework_swagger.views import get_swagger_view + from sapl.api.views import (AutoresPossiveisListView, AutoresProvaveisListView, AutorListView, MateriaLegislativaViewSet, ModelChoiceView, SessaoPlenariaViewSet, @@ -39,9 +41,10 @@ urlpatterns_api = [ ] -if settings.DEBUG: - urlpatterns_api += [ - url(r'^docs', include('rest_framework_docs.urls')), ] +schema_view = get_swagger_view(title='Pastebin API') + +urlpatterns_api += [ + url(r'^docs', schema_view), ] urlpatterns = [ url(r'^api/', include(urlpatterns_api)), diff --git a/sapl/settings.py b/sapl/settings.py index a7229a29a..71e08ebd5 100755 --- a/sapl/settings.py +++ b/sapl/settings.py @@ -81,6 +81,7 @@ INSTALLED_APPS = ( 'crispy_forms', 'floppyforms', + 'rest_framework_swagger', 'rest_framework', 'django_filters', @@ -139,7 +140,7 @@ MIDDLEWARE = [ 'speedinfo.middleware.ProfilerMiddleware', ] if DEBUG: - INSTALLED_APPS += ('debug_toolbar', 'rest_framework_docs',) + INSTALLED_APPS += ('debug_toolbar', ) MIDDLEWARE += ['debug_toolbar.middleware.DebugToolbarMiddleware', ] INTERNAL_IPS = ('127.0.0.1') @@ -159,6 +160,7 @@ REST_FRAMEWORK = { ), 'DEFAULT_RENDERER_CLASSES': ( 'rest_framework.renderers.JSONRenderer', + 'rest_framework.renderers.BrowsableAPIRenderer', ), "DEFAULT_PERMISSION_CLASSES": ( "sapl.api.permissions.SaplModelPermissions",