'How to document individual actions of a ViewSet using `drf-spectacular`?

Using DRF's built-in way of documenting the API, I was able to write a docstring like the following and each action was documented by its corresponding line:

"""
list:    The list action returns all available objects.
retrieve:The retrieve action returns a single object selected by `id`.
create:  The create action expects the fields `name`, creates a new object and returns it.
"""

I am in the middle of switching to the library drf-spectacular, which allows for an easy generation of OpenAPI conforming schemes. However, the same docstring is now rendered for every action, which makes my documentation really long and redundant.

Is there a way that only the relevant part of the docstring is rendered for each action?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source