aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhongyuzhao <zhao.hongyu@zte.com.cn>2019-11-29 16:58:52 +0800
committerhongyuzhao <zhao.hongyu@zte.com.cn>2019-11-30 11:21:02 +0800
commit06bfcce3f57176e6b428e43e8e411e245a5fa75e (patch)
tree68e15b2e0948251b6955e5e95ba6fab57c2bb4b7
parent24ea7e1390912ba99304085c249e17dce46b047a (diff)
Swagger issue fixes from the Ericsson team:content-type extends the "application / octet-stream"
Change-Id: Ib516dadf8430e5b4230ac1d51d936517e9cec8ba Issue-ID: MODELING-288 Signed-off-by: hongyuzhao <zhao.hongyu@zte.com.cn>
-rw-r--r--catalog/packages/views/pnf_descriptor_views.py3
-rw-r--r--catalog/packages/views/vnf_package_artifact_views.py2
-rw-r--r--catalog/packages/views/vnf_package_subscription_views.py7
-rw-r--r--catalog/packages/views/vnf_package_views.py4
-rw-r--r--catalog/swagger/views.py7
5 files changed, 18 insertions, 5 deletions
diff --git a/catalog/packages/views/pnf_descriptor_views.py b/catalog/packages/views/pnf_descriptor_views.py
index 1fa03dc..4051e56 100644
--- a/catalog/packages/views/pnf_descriptor_views.py
+++ b/catalog/packages/views/pnf_descriptor_views.py
@@ -34,6 +34,7 @@ from catalog.packages.views.common import validate_data
from catalog.pub.utils.syscomm import fun_name
from catalog.pub.utils.values import ignore_case_get
from .common import view_safe_call_with_log
+from catalog.swagger.views import EtsiCatalogFileAutoSchema
logger = logging.getLogger(__name__)
@@ -121,6 +122,7 @@ def pnf_descriptors_rc(request):
}
)
@swagger_auto_schema(
+ auto_schema=EtsiCatalogFileAutoSchema,
method='GET',
operation_description="Fetch PNFD content",
tags=[TAG_PNFD_API],
@@ -131,7 +133,6 @@ def pnf_descriptors_rc(request):
status.HTTP_404_NOT_FOUND: ProblemDetailsSerializer(),
status.HTTP_500_INTERNAL_SERVER_ERROR: ProblemDetailsSerializer()
},
- produces='application/octet-stream',
operation_id='Fetch PNFD content'
)
@api_view(http_method_names=['PUT', 'GET'])
diff --git a/catalog/packages/views/vnf_package_artifact_views.py b/catalog/packages/views/vnf_package_artifact_views.py
index 56f3f2f..dde7585 100644
--- a/catalog/packages/views/vnf_package_artifact_views.py
+++ b/catalog/packages/views/vnf_package_artifact_views.py
@@ -23,6 +23,7 @@ from rest_framework.views import APIView
from catalog.packages.biz.vnf_pkg_artifacts import FetchVnfPkgArtifact
from catalog.packages.const import TAG_VNF_PACKAGE_API
from .common import view_safe_call_with_log
+from catalog.swagger.views import EtsiCatalogFileAutoSchema
logger = logging.getLogger(__name__)
@@ -39,6 +40,7 @@ VALID_FILTERS = [
class FetchVnfPkgmArtifactsView(APIView):
@swagger_auto_schema(
+ auto_schema=EtsiCatalogFileAutoSchema,
tags=[TAG_VNF_PACKAGE_API],
responses={
status.HTTP_200_OK: openapi.Response("Return the artifact file",
diff --git a/catalog/packages/views/vnf_package_subscription_views.py b/catalog/packages/views/vnf_package_subscription_views.py
index 8289275..7bf29de 100644
--- a/catalog/packages/views/vnf_package_subscription_views.py
+++ b/catalog/packages/views/vnf_package_subscription_views.py
@@ -27,7 +27,7 @@ from catalog.packages.serializers.response import ProblemDetailsSerializer
from catalog.packages.serializers.vnf_pkg_subscription import PkgmSubscriptionRequestSerializer
from catalog.packages.serializers.vnf_pkg_subscription import PkgmSubscriptionSerializer
from catalog.packages.serializers.vnf_pkg_subscription import PkgmSubscriptionsSerializer
-from catalog.packages.views.common import validate_data
+from catalog.packages.views.common import validate_data, validate_req_data
from catalog.pub.exceptions import BadRequestException
from catalog.pub.exceptions import VnfPkgSubscriptionException
from .common import view_safe_call_with_log
@@ -51,14 +51,15 @@ class CreateQuerySubscriptionView(APIView):
request_body=PkgmSubscriptionRequestSerializer,
responses={
status.HTTP_201_CREATED: PkgmSubscriptionSerializer(),
- status.HTTP_500_INTERNAL_SERVER_ERROR: "Internal error"
+ status.HTTP_400_BAD_REQUEST: ProblemDetailsSerializer(),
+ status.HTTP_500_INTERNAL_SERVER_ERROR: ProblemDetailsSerializer()
}
)
@view_safe_call_with_log(logger=logger)
def post(self, request):
logger.debug("Create VNF package Subscription> %s" % request.data)
- vnf_pkg_subscription_request = validate_data(request.data, PkgmSubscriptionRequestSerializer)
+ vnf_pkg_subscription_request = validate_req_data(request.data, PkgmSubscriptionRequestSerializer)
data = CreateSubscription(vnf_pkg_subscription_request.data).do_biz()
subscription_info = validate_data(data, PkgmSubscriptionSerializer)
return Response(data=subscription_info.data, status=status.HTTP_201_CREATED)
diff --git a/catalog/packages/views/vnf_package_views.py b/catalog/packages/views/vnf_package_views.py
index 2156e7b..6ff4f9f 100644
--- a/catalog/packages/views/vnf_package_views.py
+++ b/catalog/packages/views/vnf_package_views.py
@@ -32,6 +32,7 @@ from catalog.packages.serializers.vnf_pkg_info import VnfPkgInfoSerializer
from catalog.packages.serializers.vnf_pkg_infos import VnfPkgInfosSerializer
from .common import validate_data, validate_req_data
from .common import view_safe_call_with_log
+from catalog.swagger.views import EtsiCatalogFileAutoSchema
logger = logging.getLogger(__name__)
@@ -77,6 +78,7 @@ def vnf_packages_rc(request):
@swagger_auto_schema(
+ auto_schema=EtsiCatalogFileAutoSchema,
method="GET",
operation_description="Read VNFD of an on-boarded VNF package",
tags=[TAG_VNF_PACKAGE_API],
@@ -90,7 +92,6 @@ def vnf_packages_rc(request):
status.HTTP_500_INTERNAL_SERVER_ERROR: openapi.Response("Internal error",
schema=openapi.Schema(type=openapi.TYPE_STRING))
},
- produces='application/octet-stream',
operation_id='VNFD of an on-boarded VNF package'
)
@api_view(http_method_names=["GET"])
@@ -118,6 +119,7 @@ def vnfd_rd(request, **kwargs):
}
)
@swagger_auto_schema(
+ auto_schema=EtsiCatalogFileAutoSchema,
method="GET",
operation_description="Fetch VNF package content",
tags=[TAG_VNF_PACKAGE_API],
diff --git a/catalog/swagger/views.py b/catalog/swagger/views.py
index 4739188..93be679 100644
--- a/catalog/swagger/views.py
+++ b/catalog/swagger/views.py
@@ -17,6 +17,7 @@ import os
from rest_framework.response import Response
from rest_framework.views import APIView
+from drf_yasg.inspectors import SwaggerAutoSchema
class SwaggerJsonView(APIView):
@@ -26,3 +27,9 @@ class SwaggerJsonView(APIView):
json_data = json.JSONDecoder().decode(f.read())
f.close()
return Response(json_data)
+
+
+class EtsiCatalogFileAutoSchema(SwaggerAutoSchema):
+ def get_produces(self):
+ super(EtsiCatalogFileAutoSchema, self).get_produces()
+ return ["application/octet-stream", "application/json"]