I am trying to return a pdf file as
return StreamingResponse(generator, headers={"Content-Disposition": filename}, media_type="application/pdf")
Also, I raise an error if the file is not found
raise HTTPException(HTTP_404_NOT_FOUND, "File not found")
The problem is that redoc shows
RESPONSE SCHEMA: application/json
I need the response schema to be application/pdf when successful, and application/json when error occurs.
I tried using response_class and responses in the decorator @router.get(), but neither of them worked :(