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-12-04 08:29 +0000
« prev ^ index » next coverage.py v7.6.1, created at 2025-12-04 08:29 +0000
1from fastapi import FastAPI, Query 1abcde
3app = FastAPI() 1abcde
6@app.get("/items/") 1abcde
7async def read_items( 1abcde
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"}]} 1fklgmnhopiqrjst
20 if q: 1fklgmnhopiqrjst
21 results.update({"q": q}) 1fghij
22 return results 1fklgmnhopiqrjst