Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Query parameter models work incorrectly if fastapi-pagination enabled (FastAPI >= 0.115.0) #1314

Open
espdev opened this issue Sep 30, 2024 · 5 comments
Assignees
Labels
bug Something isn't working

Comments

@espdev
Copy link

espdev commented Sep 30, 2024

Hello,

In FastAPI 0.115.0 query parameter models functionality has been added. If we use fastapi-pagination (add_pagination(app)) this feature works incorrectly.

For example:

class QueryFilters(BaseModel):
    foo: int | None = None
    bar: str | None = None
    baz: str | None = None

@app.get('/api')
async def api(filters: Annotated[QueryFilters, Query()]):
    return {}

Without add_pagination:
image

With add_pagination:
image

@uriyyo uriyyo self-assigned this Oct 1, 2024
@uriyyo uriyyo added the bug Something isn't working label Oct 1, 2024
@uriyyo
Copy link
Owner

uriyyo commented Oct 4, 2024

Hi @espdev,

This is actually fastapi issue, and it's not related to fastapi-pagination. Will try to create issue on fastapi side.

@YarrikV
Copy link

YarrikV commented Nov 4, 2024

Did you end up creating an issue for this? If so, could you link it?

I had a look at the fastapi repo, and couldn't find an issue for this with you as an author.

Either way, I'm having the same problem. However, the problem appears when I change the return model of the specific endpoint I'm using the query parameter model. And not just because of add_pagination. If I remove the pagination from the return type, the query parameter model works fine.

@wu-clan
Copy link

wu-clan commented Nov 11, 2024

Hi, @uriyyo

Is there any progress on this issue?

@uriyyo
Copy link
Owner

uriyyo commented Nov 16, 2024

@wu-clan I have opened PR with proposed fix - fastapi/fastapi#12944

@uriyyo
Copy link
Owner

uriyyo commented Nov 16, 2024

@YarrikV Sorry, I had no time to create issue.

I opened PR with proposed fix, you can take a look here - fastapi/fastapi#12944

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants