2222MINIMUM_NUMBER_OF_ITEMS_PER_PAGE : Final [int ] = 1
2323MAXIMUM_NUMBER_OF_ITEMS_PER_PAGE : Final [int ] = 50
2424
25-
2625PageLimitInt : TypeAlias = Annotated [
2726 int ,
2827 Field (
2928 ge = MINIMUM_NUMBER_OF_ITEMS_PER_PAGE ,
3029 le = MAXIMUM_NUMBER_OF_ITEMS_PER_PAGE ,
30+ description = "The maximum number of items to return in a single page." ,
31+ ),
32+ ]
33+ PageOffsetInt : TypeAlias = Annotated [
34+ int ,
35+ Field (
36+ ge = 0 ,
37+ description = "The number of items to skip before starting to collect the items for the current pag" ,
3138 ),
3239]
33-
34- PageOffsetInt : TypeAlias = NonNegativeInt
35-
3640PageTotalCount : TypeAlias = NonNegativeInt
3741
42+
3843DEFAULT_NUMBER_OF_ITEMS_PER_PAGE : Final [PageLimitInt ] = TypeAdapter (
3944 PageLimitInt
4045).validate_python (20 )
4146
4247
4348class CursorQueryParameters (RequestParameters ):
44- """Use as pagination options in query parameters"""
49+ """Query parameters for Cursor-Based Pagination
50+
51+ SEE https://uriyyo-fastapi-pagination.netlify.app/learn/pagination/techniques/#cursor-based-pagination
52+ """
4553
4654 size : PageLimitInt = Field (
47- default = TypeAdapter (PageLimitInt ).validate_python (
48- DEFAULT_NUMBER_OF_ITEMS_PER_PAGE
49- ),
55+ default = DEFAULT_NUMBER_OF_ITEMS_PER_PAGE ,
5056 description = "maximum number of items to return (pagination)" ,
5157 )
5258 cursor : Annotated [
@@ -58,21 +64,13 @@ class CursorQueryParameters(RequestParameters):
5864
5965
6066class PageQueryParameters (RequestParameters ):
61- """Use as pagination options in query parameters"""
67+ """Query parameters for Limit-Offset Pagination
6268
63- limit : Annotated [
64- PageLimitInt ,
65- Field (
66- default = TypeAdapter (PageLimitInt ).validate_python (
67- DEFAULT_NUMBER_OF_ITEMS_PER_PAGE
68- ),
69- description = "maximum number of items to return (pagination)" ,
70- ),
71- ]
72- offset : Annotated [
73- PageOffsetInt ,
74- Field (default = 0 , description = "index to the first item to return (pagination)" ),
75- ]
69+ SEE https://uriyyo-fastapi-pagination.netlify.app/learn/pagination/techniques/#limit-offset-pagination
70+ """
71+
72+ limit : PageLimitInt = DEFAULT_NUMBER_OF_ITEMS_PER_PAGE
73+ offset : PageOffsetInt = 0
7674
7775
7876class PageMetaInfoLimitOffset (BaseModel ):
0 commit comments