summaryrefslogtreecommitdiffstats
path: root/res
diff options
context:
space:
mode:
authorying.yunlong <ying.yunlong@zte.com.cn>2018-01-26 17:23:40 +0800
committeryunlong ying <ying.yunlong@zte.com.cn>2018-01-27 06:11:13 +0000
commit4dcbca178280845675c092db9ba90fc590902fde (patch)
tree63021e41cd460a1a3e731b953a7f1699311b04b4 /res
parent03ddcb24a50bb596a399670a5cc3b2319d59e29e (diff)
Move swagger func to swagger dir
Change-Id: I63456c17f40bba6fbcde28e5d000e61db4b5021d Issue-ID: VFC-679 Signed-off-by: ying.yunlong <ying.yunlong@zte.com.cn>
Diffstat (limited to 'res')
-rw-r--r--res/res/settings.py2
-rw-r--r--res/res/swagger/tests.py2
-rw-r--r--res/res/swagger/urls.py27
-rw-r--r--res/res/urls.py25
4 files changed, 27 insertions, 29 deletions
diff --git a/res/res/settings.py b/res/res/settings.py
index a6cca4b..e8da4e0 100644
--- a/res/res/settings.py
+++ b/res/res/settings.py
@@ -98,7 +98,7 @@ SWAGGER_SETTINGS = {
'LOGIN_URL': '/admin/login',
'LOGOUT_URL': '/admin/logout',
- 'DEFAULT_INFO': 'res.urls.swagger_info'
+ 'DEFAULT_INFO': 'res.swagger.urls.swagger_info'
}
DATABASES = {
diff --git a/res/res/swagger/tests.py b/res/res/swagger/tests.py
index 03bb77f..01eae5a 100644
--- a/res/res/swagger/tests.py
+++ b/res/res/swagger/tests.py
@@ -25,5 +25,5 @@ class SwaggerViewTest(unittest.TestCase):
pass
def test_swagger_ok(self):
- resp = self.client.get("/api/vnfres/v1/swagger.json", format="json")
+ resp = self.client.get("/swagger.json", format="json")
self.assertEqual(resp.status_code, status.HTTP_200_OK, resp.content)
diff --git a/res/res/swagger/urls.py b/res/res/swagger/urls.py
index 3cfa7a6..0cc9043 100644
--- a/res/res/swagger/urls.py
+++ b/res/res/swagger/urls.py
@@ -12,9 +12,32 @@
# See the License for the specific language governing permissions and
# 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 res.swagger.views import SwaggerJsonView
+swagger_info = openapi.Info(
+ title="vnfres 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/vnfres/v1/swagger.json$', SwaggerJsonView.as_view()),
+ # url(r'^api/vnfres/v1/swagger.json$', SwaggerJsonView.as_view()),
+ url(r'^swagger(?P<format>.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<format>.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/res/res/urls.py b/res/res/urls.py
index 83bbdaf..895cc25 100644
--- a/res/res/urls.py
+++ b/res/res/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 res.pub.config.config import REG_TO_MSB_WHEN_START, REG_TO_MSB_REG_URL, REG_TO_MSB_REG_PARAM
-swagger_info = openapi.Info(
- title="vnfres 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('res.samples.urls')),
url(r'^', include('res.swagger.urls')),
url(r'^', include('res.resources.urls')),
- url(r'^swagger(?P<format>.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<format>.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