I want to document my API using swagger generator tool django-rest-swagger in DRF
right now I am writing views by inheriting rest_framework.views.APIView
I don't want to write views using viewsets nor serializer.
Here is the view code sample
from rest_framework.views import APIView
class SomeView(APIView):
'''
get:
some description
post:
some other description
'''
def get(self, request, format=None):
a = self.request.query_params.get('a',None)
b = self.request.query_params.get('b',None)
c = self.request.query_params.get('c',None)
return Response({},status='200')
def post(self, request, format=None):
a = self.request.data.get('a',None)
b = self.request.data.get('b',None)
c = self.request.data.get('c',None)
return Response({},status='201')
Right now I am able to add description for each endpoint.
and I want to add request & response schema like below
and I am wondering, how to achieve this without using serializers & viewsets.
I know that i'm not answering directly to your question, but i would like to suggest you to try an awesome package that is customizable in every direction:
drf-yasg
. You are not obligated to use generic rest_framework stuff nor serializers.You can jump directly to Custom schema generation