summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfengyuanxing <feng.yuanxing@zte.com.cn>2018-01-29 10:28:09 +0800
committerfengyuanxing <feng.yuanxing@zte.com.cn>2018-01-29 10:28:09 +0800
commit901d33ba737224ceba2784ace54c26b4ebb57f92 (patch)
tree7c2ed67f6623d43a368839ece63dddec0601faa9
parentca977b3bfaa4dfb1672155d447ff456f2a374944 (diff)
Modify incorrect schema of internal error
Change-Id: I1bc0922a5d363e1da19f2f16695d0a22e01718ea Issue-ID: VFC-685 Signed-off-by: fengyuanxing <feng.yuanxing@zte.com.cn>
-rw-r--r--catalog/packages/views.py31
-rw-r--r--catalog/serializers.py5
2 files changed, 12 insertions, 24 deletions
diff --git a/catalog/packages/views.py b/catalog/packages/views.py
index 78ba4a49..a3b5c1e3 100644
--- a/catalog/packages/views.py
+++ b/catalog/packages/views.py
@@ -27,6 +27,7 @@ from catalog.serializers import NfPackageDistributeRequestSerializer
from catalog.serializers import PostJobResponseSerializer
from catalog.serializers import ParseModelRequestSerializer
from catalog.serializers import ParseModelResponseSerializer
+from catalog.serializers import InternalErrorRequestSerializer
from drf_yasg import openapi
from drf_yasg.utils import no_body, swagger_auto_schema
@@ -45,20 +46,14 @@ logger = logging.getLogger(__name__)
openapi.Schema(
type=openapi.TYPE_STRING,
pattern='CSAR(\w+) distributed successfully.')),
- status.HTTP_500_INTERNAL_SERVER_ERROR: openapi.Response(
- 'error',
- openapi.Schema(
- type=openapi.TYPE_STRING))})
+ status.HTTP_500_INTERNAL_SERVER_ERROR: InternalErrorRequestSerializer})
@swagger_auto_schema(
method='GET',
operation_description="Query NS packages",
request_body=no_body,
responses={
status.HTTP_200_OK: NsPackagesSerializer,
- status.HTTP_500_INTERNAL_SERVER_ERROR: openapi.Response(
- 'error',
- openapi.Schema(
- type=openapi.TYPE_STRING))})
+ status.HTTP_500_INTERNAL_SERVER_ERROR: InternalErrorRequestSerializer})
@api_view(http_method_names=['POST', 'GET'])
def nspackages_rc(request, *args, **kwargs):
logger.debug("Enter %s, method is %s", fun_name(), request.method)
@@ -98,20 +93,14 @@ def nspackages_rc(request, *args, **kwargs):
request_body=NfPackageDistributeRequestSerializer(),
responses={
status.HTTP_202_ACCEPTED: PostJobResponseSerializer,
- status.HTTP_500_INTERNAL_SERVER_ERROR: openapi.Response(
- 'error',
- openapi.Schema(
- type=openapi.TYPE_STRING))})
+ status.HTTP_500_INTERNAL_SERVER_ERROR: InternalErrorRequestSerializer})
@swagger_auto_schema(
method='GET',
operation_description="Query Nf packages",
request_body=no_body,
responses={
status.HTTP_200_OK: NfPackagesSerializer,
- status.HTTP_500_INTERNAL_SERVER_ERROR: openapi.Response(
- 'error',
- openapi.Schema(
- type=openapi.TYPE_STRING))})
+ status.HTTP_500_INTERNAL_SERVER_ERROR: InternalErrorRequestSerializer})
@api_view(http_method_names=['POST', 'GET'])
def nfpackages_rc(request, *args, **kwargs):
logger.debug(
@@ -209,10 +198,7 @@ def nf_rd_csar(request, *args, **kwargs):
request_body=ParseModelRequestSerializer,
responses={
status.HTTP_202_ACCEPTED: ParseModelResponseSerializer,
- status.HTTP_500_INTERNAL_SERVER_ERROR: openapi.Response(
- 'error',
- openapi.Schema(
- type=openapi.TYPE_STRING))})
+ status.HTTP_500_INTERNAL_SERVER_ERROR: InternalErrorRequestSerializer})
@api_view(http_method_names=['POST'])
def ns_model_parser(request, *args, **kwargs):
csar_id = ignore_case_get(request.data, "csarId")
@@ -238,10 +224,7 @@ def ns_model_parser(request, *args, **kwargs):
request_body=ParseModelRequestSerializer,
responses={
status.HTTP_202_ACCEPTED: ParseModelResponseSerializer,
- status.HTTP_500_INTERNAL_SERVER_ERROR: openapi.Response(
- 'error',
- openapi.Schema(
- type=openapi.TYPE_STRING))})
+ status.HTTP_500_INTERNAL_SERVER_ERROR: InternalErrorRequestSerializer})
@api_view(http_method_names=['POST'])
def vnf_model_parser(request, *args, **kwargs):
csar_id = ignore_case_get(request.data, "csarId")
diff --git a/catalog/serializers.py b/catalog/serializers.py
index 820dc003..24362f2d 100644
--- a/catalog/serializers.py
+++ b/catalog/serializers.py
@@ -57,6 +57,11 @@ class GetJobResponseResultSerializer(serializers.Serializer):
msg = serializers.CharField(help_text="Message", required=False)
+class InternalErrorRequestSerializer(serializers.Serializer):
+ error = serializers.CharField(help_text="Error", required=True)
+ errorMessage = serializers.CharField(help_text="Error Message", required=False)
+
+
class NsPackageDistributeRequestSerializer(serializers.Serializer):
csarId = serializers.CharField(help_text="csarId", required=True)