drf-spectacular does not show parameters in swagger-ui if they are optional

Viewed 68

I am trying to implement some API by using GenericViewSet. I have also some FilterSet class with some custom optional fields. My issue is the generation of these custom fields in swagger-ui endpoint documentation. Generated schema just does not includes all these filtering parameters. Is there any method to solve this problem without using @extend_schema decorator with viewset actions? Here is my FilterSet class:

Class MyFilter(filters.FilterSet):
    number_field = filters.NumberFilter(required=False)
     
    class Meta:
        model = MyModel
        fields = ('number_field', )

ViewSet class:

class MyViewSet(viewsets.mixins.ListModelMixin, viewsets.GenericViewSet):
    filter_backends = [DjangoFilterBackend]
    filterset_class = MyFilter
    
    def get_queryset(self):
        return MyModel.objects.all()
0 Answers
Related