Coverage for docs_src/query_params_str_validations/tutorial010_an.py: 100%
10 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 typing import Union 1abcdefg
3from fastapi import FastAPI, Query 1abcdefg
4from typing_extensions import Annotated 1abcdefg
6app = FastAPI() 1abcdefg
9@app.get("/items/") 1abcdefg
10async def read_items( 1abcdefg
11 q: Annotated[
12 Union[str, None],
13 Query(
14 alias="item-query",
15 title="Query string",
16 description="Query string for the items to search in the database that have a good match",
17 min_length=3,
18 max_length=50,
19 pattern="^fixedquery$",
20 deprecated=True,
21 ),
22 ] = None,
23):
24 results = {"items": [{"item_id": "Foo"}, {"item_id": "Bar"}]} 1hopiqrjstkuvlwxmyznAB
25 if q: 1hopiqrjstkuvlwxmyznAB
26 results.update({"q": q}) 1hijklmn
27 return results 1hopiqrjstkuvlwxmyznAB