As explained in this Stack Overflow post, the current documentation does not explain how to specify input parameters for non generic API Views, in order to be provided in the new DRF 3.6 doc.
I don't know if it's possible actually.
You'll need to put a serializer_class on the view if you want the API documentation to be able to introspect that.
We could do a better job of documenting that.
In my case, even with the serializer_class provided, no input parameter is detected in the doc.
Is it a bug or am I missing something?
Here is the code:
views.py
class ActivateCustomerView(APIView):
"""
put: View dedicated to activating a pre-recorded customer
"""
permission_classes = (AllowAny,)
serializer_class = ActivateCustomerSerializer
def put(self, request):
serializer = ActivateCustomerSerializer(data=request.data)
serializer.is_valid(raise_exception=True)
return Response(status=HTTP_200_OK)
serializers.py
class ActivateCustomerSerializer(serializers.Serializer):
email = EmailField()
signup_code = CharField()
raw_password = CharField()
def validate(self, data):
# some stuff..
return data
Any idea @tomchristie ?
Actually I mis-spoke. serializer_class by itself isn't enough - the view needs to implement get_serializer, see: https://github.com/encode/django-rest-framework/blob/master/rest_framework/schemas.py#L570
Ie. the docs are only designed to be able to introspect GenericAPIView subclasses.
Most helpful comment
Actually I mis-spoke.
serializer_classby itself isn't enough - the view needs to implementget_serializer, see: https://github.com/encode/django-rest-framework/blob/master/rest_framework/schemas.py#L570Ie. the docs are only designed to be able to introspect
GenericAPIViewsubclasses.