summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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)