Replies: 2 comments 7 replies
-
Use Annotated like from fastapi import FastAPI, Query
from typing import Annotated
app = FastAPI()
@app.get("/")
def root(q: Annotated[int, Query()] = None):
return q |
Beta Was this translation helpful? Give feedback.
7 replies
-
@tiangolo https://json-schema.org/understanding-json-schema/reference/null
I don't think FastAPI(or maybe OpenAPI) has a way to accept null in queries. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
First Check
Commit to Help
Example Code
Description
Open
/docs
in browser. I expect optional query parameter with integer type, but there is just common text optional query parampydantic v2
pydantic v1
Operating System
Linux
Operating System Details
No response
FastAPI Version
0.105.0
Pydantic Version
2.5.3
Python Version
3.11.7
Additional Context
No response
Beta Was this translation helpful? Give feedback.
All reactions