Skip to content

Commit 7658ffd

Browse files
Fix: Pagination response schemas. (#9049)
1 parent 66d86d0 commit 7658ffd

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

rest_framework/pagination.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,7 @@ def get_paginated_response(self, data):
239239
def get_paginated_response_schema(self, schema):
240240
return {
241241
'type': 'object',
242+
'required': ['count', 'results'],
242243
'properties': {
243244
'count': {
244245
'type': 'integer',
@@ -411,6 +412,7 @@ def get_paginated_response(self, data):
411412
def get_paginated_response_schema(self, schema):
412413
return {
413414
'type': 'object',
415+
'required': ['count', 'results'],
414416
'properties': {
415417
'count': {
416418
'type': 'integer',
@@ -906,6 +908,7 @@ def get_paginated_response(self, data):
906908
def get_paginated_response_schema(self, schema):
907909
return {
908910
'type': 'object',
911+
'required': ['results'],
909912
'properties': {
910913
'next': {
911914
'type': 'string',

tests/test_pagination.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,7 @@ def test_get_paginated_response_schema(self):
274274

275275
assert self.pagination.get_paginated_response_schema(unpaginated_schema) == {
276276
'type': 'object',
277+
'required': ['count', 'results'],
277278
'properties': {
278279
'count': {
279280
'type': 'integer',
@@ -585,6 +586,7 @@ def test_get_paginated_response_schema(self):
585586

586587
assert self.pagination.get_paginated_response_schema(unpaginated_schema) == {
587588
'type': 'object',
589+
'required': ['count', 'results'],
588590
'properties': {
589591
'count': {
590592
'type': 'integer',
@@ -937,6 +939,7 @@ def test_get_paginated_response_schema(self):
937939

938940
assert self.pagination.get_paginated_response_schema(unpaginated_schema) == {
939941
'type': 'object',
942+
'required': ['results'],
940943
'properties': {
941944
'next': {
942945
'type': 'string',

0 commit comments

Comments
 (0)