uriyyo / fastapi-pagination

FastAPI pagination 📖
https://uriyyo-fastapi-pagination.netlify.app/
MIT License
1.1k stars 126 forks source link

DeprecationWarning: `with_custom_options` method is deprecated, please use `fastapi_pagination.customization.CustomizePage` instead. This method will be removed in the next major release (0.13.0). #1115

Closed damilareisaac closed 2 months ago

damilareisaac commented 2 months ago

Page = Page.with_custom_options(cls_name= "Paginated", size=Query(20, ge=1, le=50))

I have the code above which was currently working but got a depreciation warning

DeprecationWarning: `with_custom_options` method is deprecated, please use `fastapi_pagination.customization.CustomizePage` instead. This method will be removed in the next major release (0.13.0).
    Page = Page.with_custom_options(cls_name= "Paginated", size=Query(20, ge=1, le=50))

I am trying to get a direct equivalent of this using the new CustomiizedPage but to no avail

uriyyo commented 2 months ago

Hi @damilareisaac,

Sorry for long response.

It will look like this:

from fastapi_pagination.customization import CustomizedPage, UseParamsFields, UseName

MyPage = CustomizedPage[
    Page,
    UseName("Paginated"),
    UseParamsFields(size=Query(20, ge=1, le=50)),
]