Skip to content

Commit 099c8ba

Browse files
committed
Move get_pagination_fields to descriptor
1 parent aa455ee commit 099c8ba

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

rest_framework/schemas.py

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -279,9 +279,9 @@ def get_link(self, path, method, generator):
279279

280280
fields = self.get_path_fields(path, method)
281281
fields += self.get_serializer_fields(path, method)
282+
fields += self.get_pagination_fields(path, method)
282283

283284
# TEMP: now we proxy back to the generator
284-
fields += generator.get_pagination_fields(path, method, view)
285285
fields += generator.get_filter_fields(path, method, view)
286286

287287
if fields and any([field.location in ('form', 'body') for field in fields]):
@@ -429,6 +429,19 @@ def get_serializer_fields(self, path, method):
429429

430430
return fields
431431

432+
def get_pagination_fields(self, path, method):
433+
view = self.view
434+
435+
if not is_list_view(path, method, view):
436+
return []
437+
438+
pagination = getattr(view, 'pagination_class', None)
439+
if not pagination:
440+
return []
441+
442+
paginator = view.pagination_class()
443+
return paginator.get_schema_fields(view)
444+
432445

433446
# TODO: Where should this live?
434447
# - We import APIView here. So we can't import the descriptor into `views`
@@ -637,17 +650,6 @@ def get_encoding(self, path, method, view):
637650

638651
return None
639652

640-
def get_pagination_fields(self, path, method, view):
641-
if not is_list_view(path, method, view):
642-
return []
643-
644-
pagination = getattr(view, 'pagination_class', None)
645-
if not pagination:
646-
return []
647-
648-
paginator = view.pagination_class()
649-
return paginator.get_schema_fields(view)
650-
651653
def get_filter_fields(self, path, method, view):
652654
if not is_list_view(path, method, view):
653655
return []

0 commit comments

Comments
 (0)