Coverage for docs_src/query_params_str_validations/tutorial010_py310.py: 100%
8 statements
« prev ^ index » next coverage.py v7.6.1, created at 2025-05-05 00:03 +0000
« prev ^ index » next coverage.py v7.6.1, created at 2025-05-05 00:03 +0000
1from fastapi import FastAPI, Query 1abcd
3app = FastAPI() 1abcd
6@app.get("/items/") 1abcd
7async def read_items( 1abcd
8 q: str | None = Query(
9 default=None,
10 alias="item-query",
11 title="Query string",
12 description="Query string for the items to search in the database that have a good match",
13 min_length=3,
14 max_length=50,
15 pattern="^fixedquery$",
16 deprecated=True,
17 ),
18):
19 results = {"items": [{"item_id": "Foo"}, {"item_id": "Bar"}]} 1eijfklgmnhop
20 if q: 1eijfklgmnhop
21 results.update({"q": q}) 1efgh
22 return results 1eijfklgmnhop