Here is my code snippet:
from fastapi_pagination import Page, add_pagination
from fastapi_pagination.ext.sqlalchemy import paginate
@app.get("/clients", response_model=Page[PydanticModel])
def get_items(
db: Session = Depends(get_db) ) -> Any:
items = paginate(
db.query(Model)
.filter(...)
)
...
# do some extra manipulations ..
...
items.items = new_items
return items
When I specify Page[PydenticModel]
in the response_model
it generates an issue with paginte()
because it's not the final response type.
The PydenticModel
correspond to new_items
and not items
(returned from paginate()
),
pydantic.error_wrappers.ValidationError: validation errors for
Page[PydanticModel]
Note: I don't want to use Page[Any] in order to keep a good a Swagger docs