Commit 2519ce91 by Alexey Evseev Committed by Tom Christie

Fix schema generation with custom page_size pagination param (#4567)

parent 5677d063
...@@ -290,9 +290,9 @@ class PageNumberPagination(BasePagination): ...@@ -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): ...@@ -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): ...@@ -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): ...@@ -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): ...@@ -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')
] ]
), ),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment