Swagger issue fixes from the Ericsson team 71/98871/1
authorhongyuzhao <zhao.hongyu@zte.com.cn>
Wed, 27 Nov 2019 02:49:38 +0000 (10:49 +0800)
committerhongyuzhao <zhao.hongyu@zte.com.cn>
Wed, 27 Nov 2019 02:55:14 +0000 (10:55 +0800)
Change-Id: I4fb7609292101e9c0c44b38ec8d40657bd340460
Issue-ID: MODELING-288
Signed-off-by: hongyuzhao <zhao.hongyu@zte.com.cn>
catalog/packages/serializers/link.py
catalog/packages/serializers/nsd_info.py
catalog/packages/serializers/nsdm_subscription.py
catalog/packages/serializers/pnfd_info.py
catalog/packages/serializers/vnf_pkg_info.py
catalog/packages/views/pnf_descriptor_views.py
catalog/packages/views/vnf_package_views.py

index a6a503c..b33ad93 100644 (file)
@@ -15,7 +15,7 @@
 from rest_framework import serializers
 
 
-class LinkSerializer(serializers.Serializer):
+class UriLinkSerializer(serializers.Serializer):
     href = serializers.CharField(
         help_text='URI of the referenced resource',
         required=True,
index 9450582..7ca72be 100644 (file)
 
 from rest_framework import serializers
 from .problem_details import ProblemDetailsSerializer
-from .link import LinkSerializer
+from .link import UriLinkSerializer
 
 
 class _LinkSerializer(serializers.Serializer):
-    self = LinkSerializer(
+    self = UriLinkSerializer(
         help_text="URI of this resource.",
         required=True,
         allow_null=False
     )
-    nsd_content = LinkSerializer(
+    nsd_content = UriLinkSerializer(
         help_text="Link to the NSD content resource.",
         required=True,
         allow_null=False
index 87aa48d..140e549 100644 (file)
 
 from rest_framework import serializers
 
-from .link import LinkSerializer
+from .link import UriLinkSerializer
 from .subscription_auth_data import SubscriptionAuthenticationSerializer
 from .nsdm_filter_data import NsdmNotificationsFilter
 
 
 class NsdmSubscriptionLinkSerializer(serializers.Serializer):
-    self = LinkSerializer(
+    self = UriLinkSerializer(
         help_text="Links to resources related to this resource.",
         required=True
     )
 
+    class Meta:
+        ref_name = "NSDM_SUB_LinkSerializer"
+
 
 class NsdmSubscriptionSerializer(serializers.Serializer):
     id = serializers.CharField(
index f9f4b6b..4502dc3 100644 (file)
 
 from rest_framework import serializers
 from .problem_details import ProblemDetailsSerializer
-from .link import LinkSerializer
+from .link import UriLinkSerializer
 
 
-class _LinkSerializer(serializers.Serializer):
-    self = LinkSerializer(
+class PnfdInfoLinksSerializer(serializers.Serializer):
+    self = UriLinkSerializer(
         help_text='URI of this resource.',
         required=True,
         allow_null=False
     )
-    pnfd_content = LinkSerializer(
+    pnfd_content = UriLinkSerializer(
         help_text='Link to the PNFD content resource.',
         required=True,
         allow_null=False
     )
 
+    class Meta:
+        ref_name = "PNFD_LinkSerializer"
+
 
 class PnfdInfoSerializer(serializers.Serializer):
     id = serializers.CharField(
@@ -100,7 +103,7 @@ class PnfdInfoSerializer(serializers.Serializer):
         required=False,
         allow_null=True
     )
-    _links = _LinkSerializer(
+    _links = PnfdInfoLinksSerializer(
         help_text='Links to resources related to this resource.',
         required=True,
         allow_null=True  # TODO: supposed to be False
index 3fa4b17..1e3c556 100644 (file)
@@ -16,21 +16,21 @@ from rest_framework import serializers
 from .checksum import ChecksumSerializer
 from .vnf_pkg_software_image_info import VnfPackageSoftwareImageInfoSerializer
 from .vnf_pkg_artifact_info import VnfPackageArtifactInfoSerializer
-from .link import LinkSerializer
+from .link import UriLinkSerializer
 
 
-class _LinkSerializer(serializers.Serializer):
-    self = LinkSerializer(
+class VnfPkgInfoLinkSerializer(serializers.Serializer):
+    self = UriLinkSerializer(
         help_text='URI of this resource.',
         required=True,
         allow_null=False
     )
-    vnfd = LinkSerializer(
+    vnfd = UriLinkSerializer(
         help_text='Link to the VNFD resource.',
         required=False,
         allow_null=False
     )
-    packageContent = LinkSerializer(
+    packageContent = UriLinkSerializer(
         help_text='Link to the "VNF package content resource.',
         required=True,
         allow_null=False
@@ -120,7 +120,7 @@ class VnfPkgInfoSerializer(serializers.Serializer):
         required=False,
         allow_null=True
     )
-    _links = _LinkSerializer(
+    _links = VnfPkgInfoLinkSerializer(
         help_text='Links to resources related to this resource.',
         required=True,
         allow_null=True  # TODO supposed to be False
index 9e7a2c4..1fa03dc 100644 (file)
@@ -19,6 +19,7 @@ from drf_yasg.utils import no_body, swagger_auto_schema
 from rest_framework import status
 from rest_framework.decorators import api_view
 from rest_framework.response import Response
+from drf_yasg import openapi
 
 from catalog.packages.biz.pnf_descriptor import PnfDescriptor
 from catalog.packages.const import TAG_PNFD_API, TAG_PARSER_API
@@ -125,10 +126,13 @@ def pnf_descriptors_rc(request):
     tags=[TAG_PNFD_API],
     request_body=no_body,
     responses={
-        status.HTTP_204_NO_CONTENT: 'PNFD file',
+        status.HTTP_200_OK: openapi.Response('PNFD file', schema=openapi.Schema(format=openapi.FORMAT_BINARY,
+                                                                                type=openapi.TYPE_STRING)),
         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'])
 @view_safe_call_with_log(logger=logger)
index 6747269..5fca931 100644 (file)
@@ -16,6 +16,7 @@ import logging
 
 from django.http import StreamingHttpResponse
 from drf_yasg.utils import swagger_auto_schema, no_body
+from drf_yasg import openapi
 from rest_framework import status
 from rest_framework.decorators import api_view
 from rest_framework.response import Response
@@ -79,10 +80,14 @@ def vnf_packages_rc(request):
     tags=[TAG_VNF_PACKAGE_API],
     request_body=no_body,
     responses={
-        status.HTTP_200_OK: VnfPkgInfosSerializer(),
+        status.HTTP_200_OK: openapi.Response('VNFD of an on-boarded VNF package',
+                                             schema=openapi.Schema(format=openapi.FORMAT_BINARY,
+                                                                   type=openapi.TYPE_STRING)),
         status.HTTP_404_NOT_FOUND: "VNF package does not exist",
         status.HTTP_500_INTERNAL_SERVER_ERROR: "Internal error"
-    }
+    },
+    produces='application/octet-stream',
+    operation_id='VNFD of an on-boarded VNF package'
 )
 @api_view(http_method_names=["GET"])
 @view_safe_call_with_log(logger=logger)
@@ -113,7 +118,9 @@ def vnfd_rd(request, **kwargs):
     tags=[TAG_VNF_PACKAGE_API],
     request_body=no_body,
     responses={
-        status.HTTP_200_OK: "Return csar file of VNF package",
+        status.HTTP_200_OK: openapi.Response('VNF package file',
+                                             schema=openapi.Schema(format=openapi.FORMAT_BINARY,
+                                                                   type=openapi.TYPE_STRING)),
         status.HTTP_404_NOT_FOUND: "VNF package does not exist",
         status.HTTP_500_INTERNAL_SERVER_ERROR: "Internal error"
     }