From 3e13be321ffd2b9c4d6421ee2478ada8e18e3ece Mon Sep 17 00:00:00 2001 From: Rohit Reddy Abbadi Date: Sun, 26 Sep 2021 02:14:00 +0530 Subject: [PATCH] add required fields on paginator schemas `required: [count, responses]` or `required: [responses]` added to schema returned by pagination classes to specify which fields are required on a paginated response so that client code generators can add necessary validations/enable null-safe implementations. --- rest_framework/pagination.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/rest_framework/pagination.py b/rest_framework/pagination.py index dc120d8e8..081b97756 100644 --- a/rest_framework/pagination.py +++ b/rest_framework/pagination.py @@ -253,6 +253,10 @@ class PageNumberPagination(BasePagination): }, 'results': schema, }, + 'required': [ + 'count', + 'results', + ], } def get_page_size(self, request): @@ -426,6 +430,10 @@ class LimitOffsetPagination(BasePagination): }, 'results': schema, }, + 'required': [ + 'count', + 'results', + ], } def get_limit(self, request): @@ -911,7 +919,10 @@ class CursorPagination(BasePagination): 'nullable': True, }, 'results': schema, - }, + },, + 'required': [ + 'results', + ], } def get_html_context(self):