Here's a self-contained, minimal, reproducible, example with my use case:
from fastapi import FastAPI, File, UploadFile
app = FastAPI()
@app.get("/")
def file_upload(file: UploadFile = File(..., media_type='text/xml')):
return {"Hello": "World"}
The schema created for this file doesn't mention the specified media type. (see: OpenAPI 'Specifying Content-Type')
How is a application supposed to know what kind of files it can send?
I'd expect something like
encoding: {
"file": {"contentType": "text/xml"}
}
See similar #1018. Looks interesting, down to work on a fix for this!
Most helpful comment
See similar #1018. Looks interesting, down to work on a fix for this!