Skip to content

Commit ceea9ab

Browse files
committed
Move get_filter_fields to descriptor
1 parent 099c8ba commit ceea9ab

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

rest_framework/schemas.py

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -280,9 +280,9 @@ def get_link(self, path, method, generator):
280280
fields = self.get_path_fields(path, method)
281281
fields += self.get_serializer_fields(path, method)
282282
fields += self.get_pagination_fields(path, method)
283+
fields += self.get_filter_fields(path, method)
283284

284285
# TEMP: now we proxy back to the generator
285-
fields += generator.get_filter_fields(path, method, view)
286286

287287
if fields and any([field.location in ('form', 'body') for field in fields]):
288288
encoding = generator.get_encoding(path, method, view)
@@ -442,6 +442,19 @@ def get_pagination_fields(self, path, method):
442442
paginator = view.pagination_class()
443443
return paginator.get_schema_fields(view)
444444

445+
def get_filter_fields(self, path, method):
446+
view = self.view
447+
448+
if not is_list_view(path, method, view):
449+
return []
450+
451+
if not getattr(view, 'filter_backends', None):
452+
return []
453+
454+
fields = []
455+
for filter_backend in view.filter_backends:
456+
fields += filter_backend().get_schema_fields(view)
457+
return fields
445458

446459
# TODO: Where should this live?
447460
# - We import APIView here. So we can't import the descriptor into `views`
@@ -650,18 +663,6 @@ def get_encoding(self, path, method, view):
650663

651664
return None
652665

653-
def get_filter_fields(self, path, method, view):
654-
if not is_list_view(path, method, view):
655-
return []
656-
657-
if not getattr(view, 'filter_backends', None):
658-
return []
659-
660-
fields = []
661-
for filter_backend in view.filter_backends:
662-
fields += filter_backend().get_schema_fields(view)
663-
return fields
664-
665666
# Method for generating the link layout....
666667

667668
def get_keys(self, subpath, method, view):

0 commit comments

Comments
 (0)