From 513fdb2e75d36ffc0976fcc7c3de93761567f82f Mon Sep 17 00:00:00 2001 From: Rohit Reddy Abbadi Date: Tue, 22 Mar 2022 23:39:37 +0530 Subject: [PATCH] Improve pagination openapi schema * add all properties on pagination class schemas to `required` attribute This helps the client code generators can add necessary validations/enable null-safe implementations. --- rest_framework/pagination.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/rest_framework/pagination.py b/rest_framework/pagination.py index e815d8d5c..cfccbc4db 100644 --- a/rest_framework/pagination.py +++ b/rest_framework/pagination.py @@ -253,6 +253,12 @@ class PageNumberPagination(BasePagination): }, 'results': schema, }, + 'required': [ + 'count', + 'next', + 'previous', + 'results', + ], } def get_page_size(self, request): @@ -426,6 +432,12 @@ class LimitOffsetPagination(BasePagination): }, 'results': schema, }, + 'required': [ + 'count', + 'next', + 'previous', + 'results', + ], } def get_limit(self, request): @@ -912,6 +924,11 @@ class CursorPagination(BasePagination): }, 'results': schema, }, + 'required': [ + 'next', + 'previous', + 'results', + ], } def get_html_context(self):