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
20 from rest_framework import permissions
21 from drf_yasg.views import get_schema_view
23 logger = logging.getLogger(__name__)
26 SchemaView = get_schema_view(
27 validators=['ssv', 'flex'],
29 permission_classes=(permissions.AllowAny,),
33 class SwaggerJsonView(APIView):
35 def get(self, request):
36 json_file = os.path.join(os.path.dirname(__file__), 'vfc.nslcm.swagger.json')
38 json_data = json.JSONDecoder().decode(f.read())
41 json_file = os.path.join(os.path.dirname(__file__), 'vfc.vnflcm.swagger.json')
43 json_data_temp = json.JSONDecoder().decode(f.read())
46 json_data["paths"].update(json_data_temp["paths"])
47 json_data["definitions"].update(json_data_temp["definitions"])
49 json_file = os.path.join(os.path.dirname(__file__), 'vfc.vllcm.swagger.json')
51 json_data_temp = json.JSONDecoder().decode(f.read())
54 json_data["paths"].update(json_data_temp["paths"])
55 json_data["definitions"].update(json_data_temp["definitions"])
57 json_file = os.path.join(os.path.dirname(__file__), 'vfc.sfclcm.swagger.json')
59 json_data_temp = json.JSONDecoder().decode(f.read())
62 json_data["paths"].update(json_data_temp["paths"])
63 json_data["definitions"].update(json_data_temp["definitions"])
65 json_file = os.path.join(os.path.dirname(__file__), 'vfc.db.swagger.json')
67 json_data_temp = json.JSONDecoder().decode(f.read())
70 json_data["paths"].update(json_data_temp["paths"])
71 json_data["definitions"].update(json_data_temp["definitions"])
73 json_file = os.path.join(os.path.dirname(__file__), 'vfc.others.swagger.json')
75 json_data_temp = json.JSONDecoder().decode(f.read())
78 json_data_jobtemp = json_data["paths"]["/jobs/{jobId}"]
79 json_data["paths"].update(json_data_temp["paths"])
80 json_data["paths"]["/jobs/{jobId}"].update(json_data_jobtemp)
81 json_data["definitions"].update(json_data_temp["definitions"])
82 return Response(json_data)