I made an API and want to make swagger doc. I don\'t develop any Serializes for that.
Views.py
class DeliveryView(APIVie
Consider using the GenericAPIView
instead as this will generate the documentation. It is a bit of a hack using this when the endpoint does not relate to a model, but it does work.
As an example, the following code will create an endpoint that only accepts post requests and is documented within swagger using the seralizer.
class SomeThing(GenericAPIView):
serializer_class = MySerializer
def post(self, request, *args, **kwargs):
serializer = MySerializer(data=request.data)
if serializer.is_valid() is False:
return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
res = do_magic(**serializer.data)
return Response(res)