summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHuang Haibin <haibin.huang@intel.com>2018-10-15 16:00:02 +0800
committerHuang Haibin <haibin.huang@intel.com>2018-10-15 16:00:02 +0800
commit5d2f73da3eb6af9abe95e7419890ebc2572d3481 (patch)
treee2794b9c6bea498c0e2594ff48120234f907c98a
parent71b8c29154397657dd45c0eb83f0da0507b38e4f (diff)
Upgrade swagger v1 for pike
Change-Id: Ia925c22e1a1516de54875c1a2386ae73ed7843f6 Issue-ID: MULTICLOUD-377 Signed-off-by: Huang Haibin <haibin.huang@intel.com>
-rw-r--r--pike/pike/swagger/urls.py2
-rw-r--r--pike/pike/swagger/views.py16
2 files changed, 18 insertions, 0 deletions
diff --git a/pike/pike/swagger/urls.py b/pike/pike/swagger/urls.py
index c06f7b49..60771f42 100644
--- a/pike/pike/swagger/urls.py
+++ b/pike/pike/swagger/urls.py
@@ -16,9 +16,11 @@ from django.conf.urls import patterns, url
from rest_framework.urlpatterns import format_suffix_patterns
from pike.swagger.views import SwaggerJsonView
+from pike.swagger.views import APIv1SwaggerJsonView
urlpatterns = [
url(r'^api/multicloud-pike/v0/swagger.json$', SwaggerJsonView.as_view()),
+ url(r'^api/multicloud-pike/v1/swagger.json$', APIv1SwaggerJsonView.as_view()),
]
urlpatterns = format_suffix_patterns(urlpatterns)
diff --git a/pike/pike/swagger/views.py b/pike/pike/swagger/views.py
index ddf34731..92c6a700 100644
--- a/pike/pike/swagger/views.py
+++ b/pike/pike/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-pike/v1/"
+ json_data["info"]["title"] = "Service NBI v1 of MultiCloud plugin for Pike"
+ return Response(data=json_data, status=200)
+ else:
+ return Response(data={'error':'internal error'}, status=500)