[Django]-Drf-yasg/drf-spectacular – description for filter parameters

5👍

This answer is for spectacular. The help text has to be attached somewhere. If you want to have it on the filter you would need to set the filter field explicitly in order to attach a help text:

class ProductFilter(FilterSet):
    number_id = NumberFilter(help_text='some injected help text')

    class Meta:
        model = Product

alternatively you can override the detected parameter with

@extend_schema_view(
    list=extend_schema(parameters=[
        OpenApiParameter(name='name__icontains', description="some help text")
    ])
)
class AddressCountyAutocompleteView(ListAPIView):

first choice would be more robust imho.

👤Insa

Leave a comment