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-05-05 00:03 +0000
« prev ^ index » next coverage.py v7.6.1, created at 2025-05-05 00:03 +0000
1from typing import Union 1abcdef
3from fastapi import FastAPI, Query 1abcdef
4from typing_extensions import Annotated 1abcdef
6app = FastAPI() 1abcdef
9@app.get("/items/") 1abcdef
10async def read_items( 1abcdef
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"}]} 1gmnhopiqrjstkuvlwx
25 if q: 1gmnhopiqrjstkuvlwx
26 results.update({"q": q}) 1ghijkl
27 return results 1gmnhopiqrjstkuvlwx