Move swagger func to swagger dir 97/29297/3
authorying.yunlong <ying.yunlong@zte.com.cn>
Fri, 26 Jan 2018 09:23:40 +0000 (17:23 +0800)
committeryunlong ying <ying.yunlong@zte.com.cn>
Sat, 27 Jan 2018 06:11:13 +0000 (06:11 +0000)
Change-Id: I63456c17f40bba6fbcde28e5d000e61db4b5021d
Issue-ID: VFC-679
Signed-off-by: ying.yunlong <ying.yunlong@zte.com.cn>
res/res/settings.py
res/res/swagger/tests.py
res/res/swagger/urls.py
res/res/urls.py

index a6cca4b..e8da4e0 100644 (file)
@@ -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 = {
index 03bb77f..01eae5a 100644 (file)
@@ -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)
index 3cfa7a6..0cc9043 100644 (file)
 # 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'),
 ]
index 83bbdaf..895cc25 100644 (file)
 # 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