summaryrefslogtreecommitdiffstats
path: root/ocata
diff options
context:
space:
mode:
authorHuang Haibin <haibin.huang@intel.com>2018-10-15 16:31:23 +0800
committerHuang Haibin <haibin.huang@intel.com>2018-10-15 16:31:23 +0800
commit41b280c730d34738c2163c772fd1293d16799f98 (patch)
tree8f67ba2bba2affc6d9b2bca506952dc0697cfbd7 /ocata
parent5d2f73da3eb6af9abe95e7419890ebc2572d3481 (diff)
Upgrade swagger v1 for ocata
Change-Id: I658c509c2897fcdb94042fe3ef98f04e6abf092a Issue-ID: MULTICLOUD-378 Signed-off-by: Huang Haibin <haibin.huang@intel.com>
Diffstat (limited to 'ocata')
-rw-r--r--ocata/ocata/swagger/urls.py2
-rw-r--r--ocata/ocata/swagger/views.py16
2 files changed, 18 insertions, 0 deletions
diff --git a/ocata/ocata/swagger/urls.py b/ocata/ocata/swagger/urls.py
index 03dd79f7..9f12227f 100644
--- a/ocata/ocata/swagger/urls.py
+++ b/ocata/ocata/swagger/urls.py
@@ -16,9 +16,11 @@ from django.conf.urls import patterns, url
from rest_framework.urlpatterns import format_suffix_patterns
from ocata.swagger.views import SwaggerJsonView
+from ocata.swagger.views import APIv1SwaggerJsonView
urlpatterns = [
url(r'^api/multicloud-ocata/v0/swagger.json$', SwaggerJsonView.as_view()),
+ url(r'^api/multicloud-ocata/v1/swagger.json$', APIv1SwaggerJsonView.as_view()),
]
urlpatterns = format_suffix_patterns(urlpatterns)
diff --git a/ocata/ocata/swagger/views.py b/ocata/ocata/swagger/views.py
index 42f596aa..27ea3653 100644
--- a/ocata/ocata/swagger/views.py
+++ b/ocata/ocata/swagger/views.py
@@ -45,4 +45,20 @@ class SwaggerJsonView(newton_json_view.SwaggerJsonView):
else:
return Response(data={'error':'internal error'}, status=500)
+class APIv1SwaggerJsonView(newton_json_view.SwaggerJsonView):
+ def get(self, request):
+ '''
+ reuse newton code and update the basePath
+ :param request:
+ :return:
+ '''
+
+ resp = super(APIv1SwaggerJsonView,self).get(request)
+ json_data = resp.data if resp else None
+ if json_data:
+ json_data["basePath"] = "/api/multicloud-ocata/v1/"
+ json_data["info"]["title"] = "Service NBI v1 of MultiCloud plugin for Ocata"
+ return Response(data=json_data, status=200)
+ else:
+ return Response(data={'error':'internal error'}, status=500)