-
-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Open
Description
Thank you for all the work you have done. I have initiated the discussion as requested, but I think this issue is quite important. Initiating this issue is just to prevent the discussion from being drowned out, and I apologize for any offense.
Example Code
import uvicorn
from typing import Literal
from fastapi import FastAPI, Query
from pydantic import BaseModel, ConfigDict, Field
from pydantic.alias_generators import to_camel
app = FastAPI()
class FilterParams(BaseModel):
model_config = ConfigDict(alias_generator=to_camel)
limit: int = Field(100, gt=0, le=100)
offset: int = Field(0, ge=0)
order_by: Literal['created_at', 'updated_at'] = 'created_at'
tags: list[str] = []
@app.get('/items/')
async def read_items(filter_query: FilterParams = Query()):
return filter_query
if __name__ == '__main__':
uvicorn.run(app='app:app')
Description
Running the code in the example above, I encountered an incorrect result when accessing http://127.0.0.1:8000/items/?offset=1&orderBy=updated_at in the browser, orderBy did not receive successfully.
{
"limit": 100,
"offset": 1,
"orderBy": "created_at",
"tags": []
}
The correct result should be as follows
{
"limit": 100,
"offset": 1,
"orderBy": "updated_at",
"tags": []
}
Operating System
Windows
Operating System Details
No response
FastAPI Version
0.115.0
Pydantic Version
2.9.2
Python Version
3.9.19
Additional Context
No response
jd-solanki, JoseKilo, potapov-ev, tschiolborg, mtvx and 1 more
Metadata
Metadata
Assignees
Labels
No labels