from django.utils.decorators import method_decorator
from drf_yasg.utils import swagger_auto_schema
from drf_yasg import openapi
class BatchTestSuiteView(CustomViewSet): """ custom batch delete or single delete with suite_ids :doc 一个用户自定义swagger参数的接口演示,不需要定义模型model和序列化器serializer penapi.TYPE Includes: TYPE_OBJECT = "object" #: TYPE_STRING = "string" #: TYPE_NUMBER = "number" #: TYPE_INTEGER = "integer" #: TYPE_BOOLEAN = "boolean" #: TYPE_ARRAY = "array" #: TYPE_FILE = "file" #: in_ includes: IN_BODY = 'body' #: IN_PATH = 'path' #: IN_QUERY = 'query' #: IN_FORM = 'formData' #: IN_HEADER = 'header' #: with swagger_auto_schema: :param str name: parameter name :param str in_: parameter location :param str description: parameter description :param bool required: whether the parameter is required for the operation :param schema: required if `in_` is ``body`` :type schema: Schema or SchemaRef :param str type: parameter type; required if `in_` is not ``body``; must not be ``object`` :param str format: value format, see OpenAPI spec :param list enum: restrict possible values :param str pattern: pattern if type is ``string`` :param .Items items: only valid if `type` is ``array`` :param default: default value if the parameter is not provided; must conform to parameter type """ lookup_field = 'id' parser_classes = [JSONParser, FormParser] serializer_class = SerialTestSuite queryset = TestSuite.objects.all() query_param = openapi.Parameter(name='suite_ids', in_=openapi.IN_QUERY, description="套件id", type=openapi.TYPE_STRING) @swagger_auto_schema(method='delete', manual_parameters=[query_param]) @action(methods=['delete'], detail=False, ) def batch_delete(self, request, *args, **kwargs): suite_ids_string = request.query_params.get('suite_ids', None) suite_ids = suite_ids_string.split(',') if not suite_ids: return CustomResponse(data=[],