From 848c3f762b90a456d7b838681cbdc5c18175fb85 Mon Sep 17 00:00:00 2001 From: Sergey Klyuykov Date: Thu, 13 Jul 2023 22:32:29 -0700 Subject: [PATCH] Fix: Pagination response schemas. --- rest_framework/pagination.py | 3 +++ tests/test_pagination.py | 3 +++ 2 files changed, 6 insertions(+) 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',