How to use self in swagger_auto_schema

I want to use self to get the api version number to modify the response serializer. What’s the best way to do this?

code snippet:

@staticmethod def get_request_serializer(version):     if version == "v2":         return AdminSiteSerializer     else:         return SiteSerializer      # noinspection PyMethodMayBeStatic @swagger_auto_schema(     responses={         200: openapi.Response(             _(                 "Successfully fetched the array of all sites where the user belongs to."             ),             get_request_serializer(self.request.version),         )     }, ) def list(self, request, *args, **kwargs): 

error code:

TypeError: swagger_auto_schema() got an unexpected keyword argument 'request_body' 
Add Comment
0 Answer(s)

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.