change swagger urls based on v1.2 specification 27/34527/5
authorSerenaFeng <feng.xiaowei@zte.com.cn>
Wed, 10 May 2017 02:09:21 +0000 (10:09 +0800)
committerSerenaFeng <feng.xiaowei@zte.com.cn>
Wed, 10 May 2017 03:03:34 +0000 (11:03 +0800)
According to swagger1.2 specification, The Swagger specification
is comprised of two file types: The Resources Listing and The
API Declaration.

https://github.com/OAI/OpenAPI-Specification/blob/master/versions/1.2.md

Change-Id: I8f92897e41dbf6d4d2c3b1fe64ea6729f04cf3ad
Signed-off-by: SerenaFeng <feng.xiaowei@zte.com.cn>
utils/test/testapi/opnfv_testapi/tornado_swagger/handlers.py
utils/test/testapi/opnfv_testapi/tornado_swagger/settings.py
utils/test/testapi/opnfv_testapi/tornado_swagger/views.py

index 2154b46..af0b515 100644 (file)
@@ -9,7 +9,7 @@
 from tornado.web import URLSpec, StaticFileHandler
 
 from settings import default_settings, \
-    SWAGGER_API_DOCS, SWAGGER_API_LIST, SWAGGER_API_SPEC
+    SWAGGER_API_DOCS, SWAGGER_RESOURCE_LISTING, SWAGGER_API_DECLARATION
 from views import SwaggerUIHandler, SwaggerResourcesHandler, SwaggerApiHandler
 
 
@@ -27,15 +27,15 @@ def swagger_handlers():
             default_settings,
             name=SWAGGER_API_DOCS),
         URLSpec(
-            _path(r'spec.json$'),
+            _path(r'resources.json$'),
             SwaggerResourcesHandler,
             default_settings,
-            name=SWAGGER_API_LIST),
+            name=SWAGGER_RESOURCE_LISTING),
         URLSpec(
-            _path(r'spec$'),
+            _path(r'APIs$'),
             SwaggerApiHandler,
             default_settings,
-            name=SWAGGER_API_SPEC),
+            name=SWAGGER_API_DECLARATION),
         (
             _path(r'(.*\.(css|png|gif|js))'),
             StaticFileHandler,
index 88d0d0f..7530297 100644 (file)
@@ -10,8 +10,8 @@ import os.path
 
 SWAGGER_VERSION = '1.2'
 SWAGGER_API_DOCS = 'swagger-api-docs'
-SWAGGER_API_LIST = 'swagger-api-list'
-SWAGGER_API_SPEC = 'swagger-api-spec'
+SWAGGER_RESOURCE_LISTING = 'swagger-resource-listing'
+SWAGGER_API_DECLARATION = 'swagger-api-declaration'
 STATIC_PATH = os.path.join(os.path.dirname(os.path.normpath(__file__)),
                            'static')
 
index 2508319..2168c5e 100644 (file)
@@ -12,7 +12,8 @@ import json
 import tornado.template
 import tornado.web
 
-from settings import SWAGGER_VERSION, SWAGGER_API_LIST, SWAGGER_API_SPEC
+from settings import SWAGGER_VERSION
+from settings import SWAGGER_RESOURCE_LISTING, SWAGGER_API_DECLARATION
 from settings import models, basePath
 
 
@@ -29,7 +30,7 @@ class SwaggerUIHandler(tornado.web.RequestHandler):
         return self.static_path
 
     def get(self):
-        discovery_url = basePath() + self.reverse_url(SWAGGER_API_LIST)
+        discovery_url = basePath() + self.reverse_url(SWAGGER_RESOURCE_LISTING)
         self.render('index.html', discovery_url=discovery_url)
 
 
@@ -47,7 +48,7 @@ class SwaggerResourcesHandler(tornado.web.RequestHandler):
             'produces': ["application/json"],
             'description': 'Test Api Spec',
             'apis': [{
-                'path': self.reverse_url(SWAGGER_API_SPEC),
+                'path': self.reverse_url(SWAGGER_API_DECLARATION),
                 'description': 'Test Api Spec'
             }]
         }