Modify incorrect schema of internal error 05/29405/1
authorfengyuanxing <feng.yuanxing@zte.com.cn>
Mon, 29 Jan 2018 02:28:09 +0000 (10:28 +0800)
committerfengyuanxing <feng.yuanxing@zte.com.cn>
Mon, 29 Jan 2018 02:28:09 +0000 (10:28 +0800)
Change-Id: I1bc0922a5d363e1da19f2f16695d0a22e01718ea
Issue-ID: VFC-685
Signed-off-by: fengyuanxing <feng.yuanxing@zte.com.cn>
catalog/packages/views.py
catalog/serializers.py

index 78ba4a4..a3b5c1e 100644 (file)
@@ -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")
index 820dc00..24362f2 100644 (file)
@@ -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)