diff --git a/rest_framework/pagination.py b/rest_framework/pagination.py index 7303890b0..2b20e76af 100644 --- a/rest_framework/pagination.py +++ b/rest_framework/pagination.py @@ -239,6 +239,7 @@ class PageNumberPagination(BasePagination): def get_paginated_response_schema(self, schema): return { 'type': 'object', + 'required': ['count', 'results'], 'properties': { 'count': { 'type': 'integer', @@ -411,6 +412,7 @@ class LimitOffsetPagination(BasePagination): def get_paginated_response_schema(self, schema): return { 'type': 'object', + 'required': ['count', 'results'], 'properties': { 'count': { 'type': 'integer', @@ -906,6 +908,7 @@ class CursorPagination(BasePagination): def get_paginated_response_schema(self, schema): return { 'type': 'object', + 'required': ['results'], 'properties': { 'next': { 'type': 'string', diff --git a/tests/test_pagination.py b/tests/test_pagination.py index d606986ab..090eb0d81 100644 --- a/tests/test_pagination.py +++ b/tests/test_pagination.py @@ -274,6 +274,7 @@ class TestPageNumberPagination: assert self.pagination.get_paginated_response_schema(unpaginated_schema) == { 'type': 'object', + 'required': ['count', 'results'], 'properties': { 'count': { 'type': 'integer', @@ -585,6 +586,7 @@ class TestLimitOffset: assert self.pagination.get_paginated_response_schema(unpaginated_schema) == { 'type': 'object', + 'required': ['count', 'results'], 'properties': { 'count': { 'type': 'integer', @@ -937,6 +939,7 @@ class CursorPaginationTestsMixin: assert self.pagination.get_paginated_response_schema(unpaginated_schema) == { 'type': 'object', + 'required': ['results'], 'properties': { 'next': { 'type': 'string',