From: ying.yunlong Date: Tue, 23 Jan 2018 02:53:38 +0000 (+0800) Subject: Move swagger url to swagger dir X-Git-Tag: v1.1.0~37 X-Git-Url: https://gerrit.onap.org/r/gitweb?a=commitdiff_plain;h=e6afb9a8a792bdab4055413540a586d92eb6c924;p=vfc%2Fgvnfm%2Fvnfmgr.git Move swagger url to swagger dir Change-Id: I15b9a3b6ee430f030c8c9d6d2fcc591a233830ea Issue-ID: VFC-670 Signed-off-by: ying.yunlong --- diff --git a/mgr/mgr/settings.py b/mgr/mgr/settings.py index 58cea1f..1845e8e 100644 --- a/mgr/mgr/settings.py +++ b/mgr/mgr/settings.py @@ -97,7 +97,7 @@ SWAGGER_SETTINGS = { 'LOGIN_URL': '/admin/login', 'LOGOUT_URL': '/admin/logout', - 'DEFAULT_INFO': 'mgr.urls.swagger_info' + 'DEFAULT_INFO': 'mgr.swagger.urls.swagger_info' } DATABASES = { diff --git a/mgr/mgr/swagger/urls.py b/mgr/mgr/swagger/urls.py index b59f61b..6bd93f3 100644 --- a/mgr/mgr/swagger/urls.py +++ b/mgr/mgr/swagger/urls.py @@ -13,8 +13,34 @@ # limitations under the License. from django.conf.urls import url +from drf_yasg import openapi +from drf_yasg.views import get_schema_view +from rest_framework import permissions + from mgr.swagger import views +swagger_info = openapi.Info( + title="vnfmgr API", + default_version='v1', + description=""" + +The `swagger-ui` view can be found [here](/cached/swagger). +The `ReDoc` view can be found [here](/cached/redoc). +The swagger YAML document can be found [here](/cached/swagger.yaml).""" +) + +SchemaView = get_schema_view( + validators=['ssv', 'flex'], + public=True, + permission_classes=(permissions.AllowAny,), +) + urlpatterns = [ - url(r'^api/vnfmgr/v1/swagger.json$', views.SwaggerView.as_view()) + url(r'^api/vnfmgr/v1/swagger.json$', views.SwaggerView.as_view()), + url(r'^swagger(?P.json|.yaml)$', SchemaView.without_ui(cache_timeout=0), name='schema-json'), + url(r'^swagger/$', SchemaView.with_ui('swagger', cache_timeout=0), name='schema-swagger-ui'), + url(r'^redoc/$', SchemaView.with_ui('redoc', cache_timeout=0), name='schema-redoc'), + url(r'^cached/swagger(?P.json|.yaml)$', SchemaView.without_ui(cache_timeout=None), name='cschema-json'), + url(r'^cached/swagger/$', SchemaView.with_ui('swagger', cache_timeout=None), name='cschema-swagger-ui'), + url(r'^cached/redoc/$', SchemaView.with_ui('redoc', cache_timeout=None), name='cschema-redoc'), ] diff --git a/mgr/mgr/urls.py b/mgr/mgr/urls.py index 84112e2..262da0b 100644 --- a/mgr/mgr/urls.py +++ b/mgr/mgr/urls.py @@ -13,38 +13,13 @@ # limitations under the License. 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 mgr.pub.config.config import REG_TO_MSB_WHEN_START, REG_TO_MSB_REG_URL, REG_TO_MSB_REG_PARAM -swagger_info = openapi.Info( - title="vnfmgr API", - default_version='v1', - description=""" - -The `swagger-ui` view can be found [here](/cached/swagger). -The `ReDoc` view can be found [here](/cached/redoc). -The swagger YAML document can be found [here](/cached/swagger.yaml).""" -) - -SchemaView = get_schema_view( - validators=['ssv', 'flex'], - public=True, - permission_classes=(permissions.AllowAny,), -) - urlpatterns = [ url(r'^', include('mgr.samples.urls')), url(r'^', include('mgr.vnfreg.urls')), url(r'^', include('mgr.swagger.urls')), - url(r'^swagger(?P.json|.yaml)$', SchemaView.without_ui(cache_timeout=0), name='schema-json'), - url(r'^swagger/$', SchemaView.with_ui('swagger', cache_timeout=0), name='schema-swagger-ui'), - url(r'^redoc/$', SchemaView.with_ui('redoc', cache_timeout=0), name='schema-redoc'), - url(r'^cached/swagger(?P.json|.yaml)$', SchemaView.without_ui(cache_timeout=None), name='cschema-json'), - url(r'^cached/swagger/$', SchemaView.with_ui('swagger', cache_timeout=None), name='cschema-swagger-ui'), - url(r'^cached/redoc/$', SchemaView.with_ui('redoc', cache_timeout=None), name='cschema-redoc'), ] # regist to MSB when startup