Skip to content

Commit 2519ce9

Browse files
st4lktomchristie
authored andcommitted
Fix schema generation with custom page_size pagination param (encode#4567)
1 parent 5677d06 commit 2519ce9

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

rest_framework/pagination.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -290,9 +290,9 @@ def get_schema_fields(self, view):
290290
coreapi.Field(name=self.page_query_param, required=False, location='query')
291291
]
292292
if self.page_size_query_param is not None:
293-
fields.append([
293+
fields.append(
294294
coreapi.Field(name=self.page_size_query_param, required=False, location='query')
295-
])
295+
)
296296
return fields
297297

298298

tests/test_schemas.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ def is_authenticated(self):
2020

2121
class ExamplePagination(pagination.PageNumberPagination):
2222
page_size = 100
23+
page_size_query_param = 'page_size'
2324

2425

2526
class EmptySerializer(serializers.Serializer):
@@ -64,7 +65,6 @@ def get_serializer(self, *args, **kwargs):
6465
assert self.action
6566
return super(ExampleViewSet, self).get_serializer(*args, **kwargs)
6667

67-
6868
if coreapi:
6969
schema_view = get_schema_view(title='Example API')
7070
else:
@@ -96,6 +96,7 @@ def test_anonymous_request(self):
9696
action='get',
9797
fields=[
9898
coreapi.Field('page', required=False, location='query'),
99+
coreapi.Field('page_size', required=False, location='query'),
99100
coreapi.Field('ordering', required=False, location='query')
100101
]
101102
),
@@ -136,6 +137,7 @@ def test_authenticated_request(self):
136137
action='get',
137138
fields=[
138139
coreapi.Field('page', required=False, location='query'),
140+
coreapi.Field('page_size', required=False, location='query'),
139141
coreapi.Field('ordering', required=False, location='query')
140142
]
141143
),

0 commit comments

Comments
 (0)