UsePydanticV1 is a customizer that allows you to convert Pydantic v2 models to Pydantic v1 models
for compatibility purposes. This is useful when you still have parts of your codebase that rely on Pydantic v1
and you want to use FastAPI Pagination without migrating everything to Pydantic v2 at once
fromrandomimportrandomfromtypingimportTypeVarfromfastapiimportFastAPIfromfastapi_paginationimportPage,add_pagination,paginatefromfastapi_pagination.customizationimportCustomizedPage,UsePydanticV1frompydantic.v1importBaseModelclassItem(BaseModel):id:intscore:float=0.0app=FastAPI()add_pagination(app)T=TypeVar("T")CustomPage=CustomizedPage[Page[T],UsePydanticV1(),]# req: GET /items?size=5&page=2@app.get("/items")asyncdefget_items()->CustomPage[Item]:returnpaginate([Item(id=id_,score=random())forid_inrange(1_000)])