I am using drf-yasg and django-rest-framework. I am having one common parent class which is having all http method defined, which will be inherited in sub-classes where business logic methods will be overided. I want subclass overrided method docstring in swagger api documentation
class BaseAPIView(APIView):
"""
Base API View.
"""
def get(self, request):
"""
Base API get method description.
"""
result = self.process_get() # Call the overridden method
return Response(result)
def process_get(self):
raise NotImplementedError
class DerivedAPIView(BaseAPIView):
"""
Derived API View.
"""
def process_get(self):
"""
List all items.
"""
items = [
{"name": "Item 1", "description": "Description of Item 1", "price": 10.99},
{"name": "Item 2", "description": "Description of Item 2", "price": 20.99}
]
return Response(items)
Here in swagger document for DerivedAPIView get method i want DerivedAPIView process_get method docstring as api documentation.