I am now using DRS for my simple django REST APIs and although its not perfect, it has been a great library so far. But having a few issues
I am using
django-rest-swagger==2.0.3
And my api-doc looks like this
Issue #1: I can't find a way to add some documentation, I tried putting YAML under my class based viewset action methods, not working. Put docstring under ViewSet class directly, no luck. Then I saw that in the latest DRS release, 2.0 change mentioned YAML docstring has been deprecated.
So how do I provide something like 1. Endpoint short description 2. parameter description and probably a sample format
Issue #2: How do I specify which parameter is mandatory.
For example, I have an action in my UserViewSet
@detail_route(methods=['post'], url_path='set-password')
@AssertInRequestBody(['password'])
def set_password(self, request, pk):
"""
set user password
"""
user = User.objects.get(pk=pk)
json_data = get_json_data(request)
user.set_password(json_data['password'])
user.save()
return DefaultResponse(_('Successfully set password for user %s'
% user.email), status.HTTP_200_OK)
And I want it to be a POST operation and there will be a password in the request body. I can't figure out a way to document that.
This applies to other operations, I guess right now DRS is simply looking at the model definition and serializer definition to determine which parameter is mandatory, which doesn't quite make sense to me.
I feel that DRS should provide some sort of decorators so that we can easily add corresponding documentation to an action method.
But maybe I am wrong, please help if DRS does provide such functionalities.
Thanks,