diff options
Diffstat (limited to 'pike')
-rw-r--r-- | pike/pike/swagger/urls.py | 2 | ||||
-rw-r--r-- | pike/pike/swagger/views.py | 16 |
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) |