mirror of
https://github.com/fastapi/fastapi.git
synced 2026-03-28 11:45:33 -04:00
🐛 Remove Required shadowing from fastapi using Pydantic v2 (#12197)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Sofie Van Landeghem <svlandeg@users.noreply.github.com>
This commit is contained in:
@@ -1,11 +1,10 @@
|
||||
from fastapi import FastAPI, Query
|
||||
from pydantic import Required
|
||||
|
||||
app = FastAPI()
|
||||
|
||||
|
||||
@app.get("/items/")
|
||||
async def read_items(q: str = Query(default=Required, min_length=3)):
|
||||
async def read_items(q: str = Query(default=..., min_length=3)):
|
||||
results = {"items": [{"item_id": "Foo"}, {"item_id": "Bar"}]}
|
||||
if q:
|
||||
results.update({"q": q})
|
||||
|
||||
Reference in New Issue
Block a user