-
Notifications
You must be signed in to change notification settings - Fork 271
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to document ModelViewSet methods? #182
Comments
Hi @tonioo, we don't do interpretation of the docstring. what we do support is having a docstring on the view class that gets propagated to each endpoint in that view.
by that you mean it is not split up? the whole docstring should show up in i'm but hesitant about introducing docstring processing. |
@tfranzel yes, I mean it is not split up but it's the expected behavior according to what you say. I can indeed use the |
yes, that is the expected behaviour currently.
in comparison docstring parsing would probably be the solution with the least amount of surprises. its not an ideal situation. |
i figured out a way to resolve the above mentioned "override mechanics" problem. after we fix that, the path is open to add this functionality via view decoration. |
@tfranzel Good news. What's your idea? |
something in the direction of @extend_schem_view(
retrieve=extend_schema(request=Foo, response=Foo)
custom_action=extend_schema(request=Foo, response=Foo)
)
class YourModelViewset(viewsets.ModelViewSet)
queryset = M.objects.none() |
@tfranzel Makes sense. |
@tonioo You can also use @method_decorator(extend_schema(operation_id='patchPost'), name='partial_update')
@method_decorator(extend_schema(operation_id='deletePost'), name='destroy')
class PostViewSet(viewsets.ModelViewSet):
serializer_class = PostSerializer
queryset = Post.objects.all() @tfranzel This however, doesn't seem to work with custom actions. Custom actions have to be decorated explicitly while defining. |
~~@v1k45 a good idea currently working on Edit: it turns out it's not as bad as i thought. DRF and the method_decorator are doing something smarter, but i have not completetly understood how. a quick test did not produce the problem is was expecting. anyway, i would be cautious. |
@v1k45 as it turns out, @tonioo i added the new |
|
Works for me as well. |
Hi,
is there a way to document ModelViewSet default methods (list, retrieve, etc.) without overloading them? I've tried to put some documentation in the class level docstring but it's not working:
The text was updated successfully, but these errors were encountered: