I have a route to which I need to send a request in MyRequest
scheme, as well as a list of files:
@router.post("/myEndpoint", response_model=MyResponse)
async def my_endpoint(my_request: MyRequest,
db: AsyncSession = Depends(get_async_session)):
...
class MyRequest(BaseModel):
userId: str
language: str
files: list[UploadFile] = File(...)
But when I make a request, I get a ValidationError:
{
"detail": [
{
"loc": [
"body"
],
"msg": "value is not a valid dict",
"type": "type_error.dict"
}
]
}
I tried to remove files from the schema, passing them as an argument along with it:
@router.post("/myEndpoint", response_model=MyResponse)
async def my_endpoint(my_request: MyRequest,
files: list[UploadFile] = File(...),
db: AsyncSession = Depends(get_async_session)):
...
class MyRequest(BaseModel):
userId: str
language: str
But there was no effect:
{
"detail": [
{
"loc": [
"body",
"my_request"
],
"msg": "value is not a valid dict",
"type": "type_error.dict"
}
]
}