SchemaGenerator.get_filter_fields is inconsistent with GenericAPIView.get_object · Issue #5237 · encode/django-rest-framework (original) (raw)

Hello devs,

In SchemaGenerator.get_filter_fields, there's a default path for non-list actions that returns an empty list.

I believe this is inconsistent with the behavior of GenericAPIView.get_object which will use filter_queryset.
The related documentation tends to confirm that this behavior is legitimate :

Note that if a filter backend is configured for a view, then as well as being used to filter list views, it will also be used to filter the querysets used for returning a single object.

For instance, given the previous example, and a product with an id of 4675, the following URL would either return the corresponding object, or return a 404 response, depending on if the filtering conditions were met by the given product instance:

The schema generated by SchemaGenerator will not reflect that filter fields are available for object-lookup actions, this is especially annoying when filter fields expect a mandatory parameter (filtering objects against a required client_id parameter for example).

Steps to reproduce

Expected behavior

Actual behavior