From 863f9e0fab249845fd9ab299885f670e24f60258 Mon Sep 17 00:00:00 2001 From: Dan Bate Date: Mon, 8 Oct 2018 12:57:12 +0100 Subject: [PATCH] added docs for custom action documentation --- docs/topics/documenting-your-api.md | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/docs/topics/documenting-your-api.md b/docs/topics/documenting-your-api.md index d57f9d6e4..574d50ad7 100644 --- a/docs/topics/documenting-your-api.md +++ b/docs/topics/documenting-your-api.md @@ -90,6 +90,28 @@ When using viewsets, you should use the relevant action names as delimiters. Create a new user instance. """ +Custom actions on viewsets can also be documented in a similar way using the method names +as delimiters or by attaching the documentation to action mapping methods. + + class UserViewSet(viewsets.ModelViewset): + ... + + @action(detail=False, methods=['get', 'post']) + def some_action(self, request, *args, **kwargs): + """ + get: + A description of the get method on the custom action. + + post: + A description of the post method on the custom action. + """ + + @some_action.mapping.put + def put_some_action(): + """ + A description of the put method on the custom action. + """ + ### `documentation` API Reference