mirror of https://github.com/tiangolo/fastapi.git
docs: finalize Required, can be None example with test verification
This commit is contained in:
parent
a28557e0c1
commit
9b8beb4700
|
|
@ -1,12 +1,11 @@
|
|||
from typing import Annotated
|
||||
|
||||
from fastapi import FastAPI, Query
|
||||
from typing import Annotated, Optional
|
||||
|
||||
app = FastAPI()
|
||||
|
||||
|
||||
@app.get("/items/")
|
||||
async def read_items(q: Annotated[str | None, Query()] = ...):
|
||||
async def read_items(q: Annotated[Optional[str], Query()] = ...):
|
||||
if q in ("None", "", "null"):
|
||||
q = None
|
||||
return {"q": q}
|
||||
|
|
|
|||
Loading…
Reference in New Issue