1 # Copyright 2016-2017 ZTE Corporation.
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
7 # http://www.apache.org/licenses/LICENSE-2.0
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
19 from rest_framework import status
20 from rest_framework.response import Response
21 from rest_framework.views import APIView
24 logger = logging.getLogger(__name__)
27 class SwaggerJsonView(APIView):
29 def get(self, request):
31 json_file = os.path.join(os.path.dirname(__file__), 'vfc.nslcm.swagger.json')
33 json_data = json.JSONDecoder().decode(f.read())
36 json_file = os.path.join(os.path.dirname(__file__), 'vfc.vnflcm.swagger.json')
38 json_data_temp = json.JSONDecoder().decode(f.read())
41 json_data["paths"].update(json_data_temp["paths"])
42 json_data["definitions"].update(json_data_temp["definitions"])
44 json_file = os.path.join(os.path.dirname(__file__), 'vfc.vllcm.swagger.json')
46 json_data_temp = json.JSONDecoder().decode(f.read())
49 json_data["paths"].update(json_data_temp["paths"])
50 json_data["definitions"].update(json_data_temp["definitions"])
53 json_file = os.path.join(os.path.dirname(__file__), 'vfc.sfclcm.swagger.json')
55 json_data_temp = json.JSONDecoder().decode(f.read())
58 json_data["paths"].update(json_data_temp["paths"])
59 json_data["definitions"].update(json_data_temp["definitions"])
62 json_file = os.path.join(os.path.dirname(__file__), 'vfc.others.swagger.json')
64 json_data_temp = json.JSONDecoder().decode(f.read())
67 json_data_jobtemp=json_data["paths"]["/jobs/{jobId}"]
68 json_data["paths"].update(json_data_temp["paths"])
69 json_data["paths"]["/jobs/{jobId}"].update(json_data_jobtemp)
70 json_data["definitions"].update(json_data_temp["definitions"])
72 return Response(json_data)