mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-08-04 12:30:11 +03:00
Move get_pagination_fields
to descriptor
This commit is contained in:
parent
0a173efac2
commit
1d6562e6ad
|
@ -279,9 +279,9 @@ class APIViewSchemaDescriptor(object):
|
||||||
|
|
||||||
fields = self.get_path_fields(path, method)
|
fields = self.get_path_fields(path, method)
|
||||||
fields += self.get_serializer_fields(path, method)
|
fields += self.get_serializer_fields(path, method)
|
||||||
|
fields += self.get_pagination_fields(path, method)
|
||||||
|
|
||||||
# TEMP: now we proxy back to the generator
|
# TEMP: now we proxy back to the generator
|
||||||
fields += generator.get_pagination_fields(path, method, view)
|
|
||||||
fields += generator.get_filter_fields(path, method, view)
|
fields += generator.get_filter_fields(path, method, view)
|
||||||
|
|
||||||
if fields and any([field.location in ('form', 'body') for field in fields]):
|
if fields and any([field.location in ('form', 'body') for field in fields]):
|
||||||
|
@ -429,6 +429,19 @@ class APIViewSchemaDescriptor(object):
|
||||||
|
|
||||||
return fields
|
return fields
|
||||||
|
|
||||||
|
def get_pagination_fields(self, path, method):
|
||||||
|
view = self.view
|
||||||
|
|
||||||
|
if not is_list_view(path, method, view):
|
||||||
|
return []
|
||||||
|
|
||||||
|
pagination = getattr(view, 'pagination_class', None)
|
||||||
|
if not pagination:
|
||||||
|
return []
|
||||||
|
|
||||||
|
paginator = view.pagination_class()
|
||||||
|
return paginator.get_schema_fields(view)
|
||||||
|
|
||||||
|
|
||||||
# TODO: Where should this live?
|
# TODO: Where should this live?
|
||||||
# - We import APIView here. So we can't import the descriptor into `views`
|
# - We import APIView here. So we can't import the descriptor into `views`
|
||||||
|
@ -637,17 +650,6 @@ class SchemaGenerator(object):
|
||||||
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def get_pagination_fields(self, path, method, view):
|
|
||||||
if not is_list_view(path, method, view):
|
|
||||||
return []
|
|
||||||
|
|
||||||
pagination = getattr(view, 'pagination_class', None)
|
|
||||||
if not pagination:
|
|
||||||
return []
|
|
||||||
|
|
||||||
paginator = view.pagination_class()
|
|
||||||
return paginator.get_schema_fields(view)
|
|
||||||
|
|
||||||
def get_filter_fields(self, path, method, view):
|
def get_filter_fields(self, path, method, view):
|
||||||
if not is_list_view(path, method, view):
|
if not is_list_view(path, method, view):
|
||||||
return []
|
return []
|
||||||
|
|
Loading…
Reference in New Issue
Block a user