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.
18 from rest_framework.response import Response
19 from rest_framework.views import APIView
21 logger = logging.getLogger(__name__)
24 class SwaggerJsonView(APIView):
26 def get(self, request):
27 json_file = os.path.join(os.path.dirname(__file__), 'vfc.nslcm.swagger.json')
29 json_data = json.JSONDecoder().decode(f.read())
32 json_file = os.path.join(os.path.dirname(__file__), 'vfc.vnflcm.swagger.json')
34 json_data_temp = json.JSONDecoder().decode(f.read())
37 json_data["paths"].update(json_data_temp["paths"])
38 json_data["definitions"].update(json_data_temp["definitions"])
40 json_file = os.path.join(os.path.dirname(__file__), 'vfc.vllcm.swagger.json')
42 json_data_temp = json.JSONDecoder().decode(f.read())
45 json_data["paths"].update(json_data_temp["paths"])
46 json_data["definitions"].update(json_data_temp["definitions"])
48 json_file = os.path.join(os.path.dirname(__file__), 'vfc.sfclcm.swagger.json')
50 json_data_temp = json.JSONDecoder().decode(f.read())
53 json_data["paths"].update(json_data_temp["paths"])
54 json_data["definitions"].update(json_data_temp["definitions"])
56 json_file = os.path.join(os.path.dirname(__file__), 'vfc.db.swagger.json')
58 json_data_temp = json.JSONDecoder().decode(f.read())
61 json_data["paths"].update(json_data_temp["paths"])
62 json_data["definitions"].update(json_data_temp["definitions"])
64 json_file = os.path.join(os.path.dirname(__file__), 'vfc.others.swagger.json')
66 json_data_temp = json.JSONDecoder().decode(f.read())
69 json_data_jobtemp = json_data["paths"]["/jobs/{jobId}"]
70 json_data["paths"].update(json_data_temp["paths"])
71 json_data["paths"]["/jobs/{jobId}"].update(json_data_jobtemp)
72 json_data["definitions"].update(json_data_temp["definitions"])
73 return Response(json_data)