Coverage for docs_src/query_params_str_validations/tutorial010_an.py: 100%
10 statements
« prev ^ index » next coverage.py v7.6.1, created at 2024-08-08 03:53 +0000
« prev ^ index » next coverage.py v7.6.1, created at 2024-08-08 03:53 +0000
1from typing import Union 1abcde
3from fastapi import FastAPI, Query 1abcde
4from typing_extensions import Annotated 1abcde
6app = FastAPI() 1abcde
9@app.get("/items/") 1abcde
10async def read_items( 1abcde
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"}]} 1abcde
25 if q: 1abcde
26 results.update({"q": q}) 1abcde
27 return results 1abcde