-
-
Notifications
You must be signed in to change notification settings - Fork 8.8k
Description
Privileged issue
- I'm @tiangolo or he asked me directly to create an issue here.
Issue Content
I have a POST method with FastAPI which has 2 params with UploadFile type. But one of them is required and one of them is Optional. When I send required param with None value, I got 422 error relating to "Field required". But if I send Optional param with None value, it's acceptable.
When I use:
from fastapi import Request
And add:
request: Request as extra param, then log request.form(), I don't see Optional param.
It seems to FastAPI ignored it?
My code is below:
from fastapi import File, Request, UploadFile
from typing import Annatoted
app: FastAPI = FastAPI()
@app.post(/test)
async def test(
request: Request,
firstFile: Annatoted[UploadFile, File(...)],
secondFile: Annatoted[UploadFile | None, File(...)] = None):
logger.debug(await request.form())