graph LR
Page["Page"]
Params["Params"]
connect_page_and_params["connect_page_and_params"]
customize_page_ns["customize_page_ns"]
new_page_cls["new_page_cls"]
InternalCustomizationHelpers["InternalCustomizationHelpers"]
connect_page_and_params -- "links" --> Page
connect_page_and_params -- "links" --> Params
customize_page_ns -- "operates on" --> Page
customize_page_ns -- "operates on" --> Params
customize_page_ns -- "delegates to" --> InternalCustomizationHelpers
customize_page_ns -- "utilizes" --> new_page_cls
The fastapi-pagination core subsystem is built around two fundamental Pydantic models: Page for representing paginated responses and Params for defining pagination requests. The connect_page_and_params utility ensures the consistent alignment and bidirectional relationship between these two models. A key architectural pattern is the dynamic customization of these pagination schemas, primarily orchestrated by the customize_page_ns function. This function leverages new_page_cls to dynamically generate modified Page classes and delegates granular schema alterations to a set of InternalCustomizationHelpers. This design allows for flexible and powerful runtime modification of pagination behavior without requiring manual class redefinition, making the subsystem highly adaptable to diverse pagination requirements.
The foundational Pydantic model representing a paginated response. It encapsulates the list of items for the current page, the total number of items, and other pagination metadata.
Related Classes/Methods:
The foundational Pydantic model defining the request parameters for pagination, such as page number and size (items per page).
Related Classes/Methods:
A crucial utility function that establishes and maintains the bidirectional relationship and consistency between the Page and Params models. This ensures that pagination responses and requests are correctly aligned.
Related Classes/Methods:
The primary public API function within the subsystem for applying various customization options (e.g., renaming fields, making fields optional) to the Pydantic schemas of both Page and Params models. It orchestrates the entire customization process.
Related Classes/Methods:
A function responsible for dynamically generating new Page Pydantic classes. This is a key mechanism for implementing the customizations defined by customize_page_ns, allowing for flexible schema modifications without direct manual class definition.
Related Classes/Methods:
A conceptual grouping of internal helper functions (e.g., _make_field_optional, _get_model_fields) that perform the low-level, granular modifications on Pydantic model schemas. These functions are not directly exposed but are crucial for the internal workings of customize_page_ns.
Related Classes/Methods: