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",