mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-02-20 13:30:59 +03:00
Fix schema generation with custom page_size pagination param (#4567)
This commit is contained in:
parent
5677d063d8
commit
2519ce9128
|
@ -290,9 +290,9 @@ class PageNumberPagination(BasePagination):
|
||||||
coreapi.Field(name=self.page_query_param, required=False, location='query')
|
coreapi.Field(name=self.page_query_param, required=False, location='query')
|
||||||
]
|
]
|
||||||
if self.page_size_query_param is not None:
|
if self.page_size_query_param is not None:
|
||||||
fields.append([
|
fields.append(
|
||||||
coreapi.Field(name=self.page_size_query_param, required=False, location='query')
|
coreapi.Field(name=self.page_size_query_param, required=False, location='query')
|
||||||
])
|
)
|
||||||
return fields
|
return fields
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,7 @@ class MockUser(object):
|
||||||
|
|
||||||
class ExamplePagination(pagination.PageNumberPagination):
|
class ExamplePagination(pagination.PageNumberPagination):
|
||||||
page_size = 100
|
page_size = 100
|
||||||
|
page_size_query_param = 'page_size'
|
||||||
|
|
||||||
|
|
||||||
class EmptySerializer(serializers.Serializer):
|
class EmptySerializer(serializers.Serializer):
|
||||||
|
@ -64,7 +65,6 @@ class ExampleViewSet(ModelViewSet):
|
||||||
assert self.action
|
assert self.action
|
||||||
return super(ExampleViewSet, self).get_serializer(*args, **kwargs)
|
return super(ExampleViewSet, self).get_serializer(*args, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
if coreapi:
|
if coreapi:
|
||||||
schema_view = get_schema_view(title='Example API')
|
schema_view = get_schema_view(title='Example API')
|
||||||
else:
|
else:
|
||||||
|
@ -96,6 +96,7 @@ class TestRouterGeneratedSchema(TestCase):
|
||||||
action='get',
|
action='get',
|
||||||
fields=[
|
fields=[
|
||||||
coreapi.Field('page', required=False, location='query'),
|
coreapi.Field('page', required=False, location='query'),
|
||||||
|
coreapi.Field('page_size', required=False, location='query'),
|
||||||
coreapi.Field('ordering', required=False, location='query')
|
coreapi.Field('ordering', required=False, location='query')
|
||||||
]
|
]
|
||||||
),
|
),
|
||||||
|
@ -136,6 +137,7 @@ class TestRouterGeneratedSchema(TestCase):
|
||||||
action='get',
|
action='get',
|
||||||
fields=[
|
fields=[
|
||||||
coreapi.Field('page', required=False, location='query'),
|
coreapi.Field('page', required=False, location='query'),
|
||||||
|
coreapi.Field('page_size', required=False, location='query'),
|
||||||
coreapi.Field('ordering', required=False, location='query')
|
coreapi.Field('ordering', required=False, location='query')
|
||||||
]
|
]
|
||||||
),
|
),
|
||||||
|
|
Loading…
Reference in New Issue
Block a user