-
-
Notifications
You must be signed in to change notification settings - Fork 8.9k
Closed
Labels
Description
First Check
- I added a very descriptive title to this issue.
- I used the GitHub search to find a similar issue and didn't find it.
- I searched the FastAPI documentation, with the integrated search.
- I already searched in Google "How to X in FastAPI" and didn't find any information.
- I already read and followed all the tutorial in the docs and didn't find an answer.
- I already checked if it is not related to FastAPI but to Pydantic.
- I already checked if it is not related to FastAPI but to Swagger UI.
- I already checked if it is not related to FastAPI but to ReDoc.
Commit to Help
- I commit to help with one of those options 👆
Example Code
from typing import Optional
from fastapi import FastAPI
app = FastAPI()
@app.get("/")
def home(q: Optional[bool] = True):
return {"Hello": q}
import uvicorn
uvicorn.run(app, host="127.0.0.1", port=5001)Description
I have a simple FastAPI route with an Optional[bool] query parameter.
I would like to pass None as the value to the parameter.
I've tried all the following but in every case it is rejected with the messager {"detail":[{"loc":["query","q"],"msg":"value could not be parsed to a boolean","type":"type_error.bool"}]}
GET /q=GET /qGET /q=nullGET /q=none
Is there any way to pass None other that setting it as the default value?
Operating System
macOS
Operating System Details
No response
FastAPI Version
0.73.0
Python Version
Python 3.9.7
Additional Context
No response
Reactions are currently unavailable