@@ -99,6 +99,26 @@ def paginate_queryset(self, items, pagination: Input, request, **params):
9999 }
100100
101101
102+ class CustomItemsLimitOffsetPagination (LimitOffsetPagination ):
103+ """Minimal LimitOffsetPagination with custom items_attribute."""
104+
105+ items_attribute = "results"
106+
107+ class Output (Schema ):
108+ results : List [int ]
109+ count : int
110+
111+
112+ class CustomItemsPageNumberPagination (PageNumberPagination ):
113+ """Minimal PageNumberPagination with custom items_attribute."""
114+
115+ items_attribute = "results"
116+
117+ class Output (Schema ):
118+ results : List [int ]
119+ count : int
120+
121+
102122class NoPagination (PaginationBase ):
103123 """
104124 Pagination class that returns all records without slicing.
@@ -174,6 +194,18 @@ def items_10(request):
174194 return ITEMS
175195
176196
197+ @api .get ("/items_11" , response = List [int ])
198+ @paginate (CustomItemsLimitOffsetPagination )
199+ def items_11 (request ):
200+ return list (range (100 ))
201+
202+
203+ @api .get ("/items_12" , response = List [int ])
204+ @paginate (CustomItemsPageNumberPagination )
205+ def items_12 (request ):
206+ return list (range (100 ))
207+
208+
177209@api .get ("/items_no_pagination" , response = List [int ])
178210@paginate (NoPagination )
179211def items_no_pagination (request ):
@@ -583,6 +615,16 @@ def items_11(request, **kwargs):
583615 }
584616
585617
618+ def test_case11 ():
619+ response = client .get ("/items_11" ).json ()
620+ assert response == {"results" : list (range (100 )), "count" : 100 }
621+
622+
623+ def test_case12 ():
624+ response = client .get ("/items_12" ).json ()
625+ assert response == {"results" : list (range (100 )), "count" : 100 }
626+
627+
586628def test_config_error_None ():
587629 with pytest .raises (ConfigError ):
588630
0 commit comments