Skip to content

Items Transformer

If you want to transform items before passing it to schema validation stage, you can use transformer argument of paginate function.

from fastapi import FastAPI

from fastapi_pagination import Page, add_pagination, paginate

app = FastAPI()

def get_double_nums() -> Page[int]:
    return paginate(
        transformer=lambda x: [i * 2 for i in x],

transformer argument is a function that accepts a list of items and returns a list of items that will be passed to page schema validation stage.