Commit 9c7abf30 authored by Samuel GAIST's avatar Samuel GAIST

Merge branch 'jango' into 'master'

Replace django-rest-swagger package that is deprecated with new drf-yasg package

See merge request !301
parents 0b7d964a 8a3d8646
Pipeline #32846 passed with stages
in 31 minutes and 34 seconds
......@@ -338,7 +338,7 @@ INSTALLED_APPS = (
'guardian',
'rest_framework',
'rest_framework_swagger',
'drf_yasg',
'rest_framework.authtoken',
'jsonfield',
'actstream',
......@@ -435,7 +435,10 @@ REST_FRAMEWORK = {
],
'DEFAULT_PARSER_CLASSES': [
'rest_framework.parsers.JSONParser'
]
],
# This setting is mandatory after DRF 3.10
# 'DEFAULT_SCHEMA_CLASS': 'rest_framework.schemas.coreapi.AutoSchema'
}
##############################################################################
......
......@@ -30,7 +30,9 @@ from django.conf import settings
from django.views.generic import TemplateView
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
from rest_framework_swagger.views import get_swagger_view
from rest_framework import permissions
from drf_yasg.views import get_schema_view
from drf_yasg import openapi
from .ui import urls as ui_urls
from .navigation import urls as navigation_urls
......@@ -43,7 +45,19 @@ except ImportError:
from django.contrib import admin
admin.autodiscover()
schema_view = get_swagger_view(title='BEAT API')
schema_view = get_schema_view(
openapi.Info(
title="BEAT API",
default_version='v1',
description="REST API for BEAT platform",
terms_of_service="https://gitlab.idiap.ch/beat/beat.web/blob/master/LICENSE.AGPL",
contact=openapi.Contact(email="beat.support@idiap.ch"),
license=openapi.License(name="AGPLv3 License"),
),
public=True,
permission_classes=(permissions.AllowAny,),
)
# Views
unprefixed_patterns = ui_urls.urlpatterns
......@@ -53,55 +67,55 @@ unprefixed_patterns += [
url(r'^algorithms/',
include('beat.web.algorithms.urls', namespace='algorithms'),
),
),
url(r'^libraries/',
include('beat.web.libraries.urls', namespace='libraries'),
),
),
url(r'^attestations/',
include('beat.web.attestations.urls', namespace='attestations'),
),
),
url(r'^backend/',
include('beat.web.backend.urls', namespace='backend'),
),
),
url(r'^dataformats/',
include('beat.web.dataformats.urls', namespace='dataformats'),
),
),
url(r'^databases/',
include('beat.web.databases.urls', namespace='databases'),
),
),
url(r'^experiments/',
include('beat.web.experiments.urls', namespace='experiments'),
),
),
url(r'^search/',
include('beat.web.search.urls', namespace='search'),
),
),
url(r'^statistics/',
include('beat.web.statistics.urls', namespace='statistics'),
),
),
url(r'^toolchains/',
include('beat.web.toolchains.urls', namespace='toolchains'),
),
),
url(r'^teams/',
include('beat.web.team.urls', namespace='teams'),
),
),
url(r'^plotters/',
include('beat.web.plotters.urls', namespace='plotters'),
),
),
url(r'^reports/',
include('beat.web.reports.urls', namespace='reports'),
),
),
url(r'^accounts/',
include('beat.web.accounts.urls', namespace='accounts'),
......@@ -109,9 +123,11 @@ unprefixed_patterns += [
url(r'^admin/', include(admin.site.urls)),
url(r'^docs/',
schema_view
),
url(r'^swagger(?P<format>\.json|\.yaml)$',
schema_view.without_ui(cache_timeout=0), name='schema-json'),
url(r'^swagger/$',
schema_view.with_ui('swagger', cache_timeout=0), name='schema-swagger-ui'),
url(r'^activity/',
include('actstream.urls'),
......@@ -125,47 +141,48 @@ unprefixed_patterns += [
url(r'^api/v1/teams/',
include('beat.web.team.api_urls', namespace='api_teams'),
),
),
url(r'^api/v1/algorithms/',
include('beat.web.algorithms.api_urls', namespace='api_algorithms'),
),
),
url(r'^api/v1/attestations/',
include('beat.web.attestations.api_urls', namespace='api_attestations'),
),
include('beat.web.attestations.api_urls',
namespace='api_attestations'),
),
url(r'^api/v1/backend/',
include('beat.web.backend.api_urls', namespace='api_backend'),
),
),
url(r'^api/v1/databases/',
include('beat.web.databases.api_urls', namespace='api_databases'),
),
),
url(r'^api/v1/dataformats/',
include('beat.web.dataformats.api_urls', namespace='api_dataformats'),
),
),
url(r'^api/v1/experiments/',
include('beat.web.experiments.api_urls', namespace='api_experiments'),
),
),
url(r'^api/v1/libraries/',
include('beat.web.libraries.api_urls', namespace='api_libraries'),
),
),
url(r'^api/v1/search/',
include('beat.web.search.api_urls', namespace='api_search'),
),
),
url(r'^api/v1/toolchains/',
include('beat.web.toolchains.api_urls', namespace='api_toolchains'),
),
),
url(r'^api/v1/plotters/',
include('beat.web.plotters.api_urls', namespace='api_plotters'),
),
),
url(r'^api/v1/reports/',
include('beat.web.reports.api_urls', namespace='api_reports'),
......@@ -181,11 +198,11 @@ unprefixed_patterns += [
# Process an eventual prefix in the URLs
parsed_url = urlparse(settings.URL_PREFIX)
if (parsed_url.path != '') and (parsed_url.path != '/'):
urlpatterns = [
url(r'^%s/' % parsed_url.path[1:], include(unprefixed_patterns)),
]
urlpatterns = [
url(r'^%s/' % parsed_url.path[1:], include(unprefixed_patterns)),
]
else:
urlpatterns = unprefixed_patterns
urlpatterns = unprefixed_patterns
# Static files (only working during development, when settings.DEBUG is True)
urlpatterns += staticfiles_urlpatterns()
......@@ -193,4 +210,4 @@ urlpatterns += staticfiles_urlpatterns()
# ONLY DURING THE TESTS: Custom error 500 view
if getattr(settings, 'TEST_CONFIGURATION', False):
handler500 = 'beat.web.ui.views.empty_error500_for_tests'
handler500 = 'beat.web.ui.views.empty_error500_for_tests'
......@@ -40,5 +40,6 @@ dependencies:
- django-jsonfield>=1.0,<1.1
- django-jsonfield-compat>=0.4,<0.5
- django-post_office>=3.1,<3.2
- django-rest-swagger>=2.2,<2.3
- drf-yasg>=1.16
- djangorestframework>=3.9,<3.10
- sphinxcontrib-openapi>=0.4.0
......@@ -61,6 +61,7 @@ extensions = [
'sphinx.ext.viewcode',
'sphinxcontrib.programoutput',
'sphinxcontrib.httpdomain',
'sphinxcontrib.openapi',
]
# Always includes todos
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -144,6 +144,8 @@ The following examples assumes that:
Data Format API
---------------
.. (openapi: : specs/swagger.yaml)
Retrieving a list of all the data formats accessible by the user
................................................................
......
......@@ -48,6 +48,7 @@ extensions = [
'sphinx.ext.viewcode',
'sphinxcontrib.programoutput',
'sphinxcontrib.httpdomain',
'sphinxcontrib.openapi',
]
# Be picky about warnings
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment