Fix vfc-vnfres auto-swagger bugs. 95/29295/2
authorying.yunlong <ying.yunlong@zte.com.cn>
Fri, 26 Jan 2018 09:16:54 +0000 (17:16 +0800)
committeryunlong ying <ying.yunlong@zte.com.cn>
Fri, 26 Jan 2018 09:38:00 +0000 (09:38 +0000)
SwaggerGenerationError at /cached/swagger/
request_body can only be applied to PUT, PATCH or POST views

Change-Id: If3024f9ad11449ad23af30bb6f334f0ac617d5ad
Issue-ID: VFC-679
Signed-off-by: ying.yunlong <ying.yunlong@zte.com.cn>
res/res/resources/serializers.py
res/res/resources/views.py

index 774d62c..aaf7598 100644 (file)
 from rest_framework import serializers
 
 
-class NoneSerializer(serializers.Serializer):
-    pass
-
-
-# {
-#     "resp_data": [{
-#         "cpinstanceid": "cp0",
-#         "cpdid": "cpd0",
-#         "cpinstancename": "cpinstname0",
-#         "vlinstanceid": "vlinst0",
-#         "ownertype": 0,
-#         "ownerid": "01",
-#         "relatedtype": 0
-#     }]
-# }
 class CpsResponseSerializer(serializers.Serializer):
     cpinstanceid = serializers.CharField(help_text="the cp instance id", required=True)
     cpdid = serializers.CharField(help_text="the cpd id", required=True)
@@ -44,17 +29,6 @@ class CpsInfoSerializer(serializers.Serializer):
     resp_data = CpsResponseSerializer(help_text="the response data", many=True)
 
 
-# {
-#     "resp_data": [{
-#         "storageid": "st0",
-#         "vimid": "vim0",
-#         "resouceid": "res0",
-#         "insttype": 0,
-#         "instid": "01",
-#         "storagetype": "stype0",
-#         "size": "0"
-#     }]
-# }
 class VolumeResponseSerializer(serializers.Serializer):
     storageid = serializers.CharField(help_text="the storage id", required=True)
     vimid = serializers.CharField(help_text="the vim id", required=True)
index 70c38b3..dfecd87 100644 (file)
@@ -26,7 +26,7 @@ from res.pub.database.models import NfInstModel, StorageInstModel, NetworkInstMo
 from res.pub.exceptions import VNFRESException
 from res.pub.utils.syscomm import fun_name
 from res.pub.utils.values import ignore_case_get
-from res.resources.serializers import VolumeInfoSerializer, NoneSerializer, CpsInfoSerializer
+from res.resources.serializers import VolumeInfoSerializer, CpsInfoSerializer
 
 logger = logging.getLogger(__name__)
 
@@ -309,11 +309,11 @@ def fill_subnets_data(subnet):
 
 
 class getCps(APIView):
-    @swagger_auto_schema(request_body=NoneSerializer(),
-                         responses={
-                             status.HTTP_200_OK: CpsInfoSerializer(),
-                             status.HTTP_404_NOT_FOUND: 'Cps does not exist',
-                             status.HTTP_500_INTERNAL_SERVER_ERROR: 'internal error'})
+    @swagger_auto_schema(
+        responses={
+            status.HTTP_200_OK: CpsInfoSerializer(),
+            status.HTTP_404_NOT_FOUND: 'Cps does not exist',
+            status.HTTP_500_INTERNAL_SERVER_ERROR: 'internal error'})
     def get(self, request, vnfInstanceId):
         logger.debug("Query all the cps by vnfInstanceId[%s]", fun_name())
         try:
@@ -349,11 +349,11 @@ def fill_cps_data(cp):
 
 
 class getVolumes(APIView):
-    @swagger_auto_schema(request_body=NoneSerializer(),
-                         responses={
-                             status.HTTP_200_OK: VolumeInfoSerializer(),
-                             status.HTTP_404_NOT_FOUND: 'Volumes does not exist',
-                             status.HTTP_500_INTERNAL_SERVER_ERROR: 'internal error'})
+    @swagger_auto_schema(
+        responses={
+            status.HTTP_200_OK: VolumeInfoSerializer(),
+            status.HTTP_404_NOT_FOUND: 'Volumes does not exist',
+            status.HTTP_500_INTERNAL_SERVER_ERROR: 'internal error'})
     def get(self, request, vnfInstanceId):
         logger.debug("Query all the volumes by vnfInstanceId[%s]", fun_name())
         try: