Coverage for docs_src / query_params_str_validations / tutorial010_py310.py: 100%

8 statements  

« prev     ^ index     » next       coverage.py v7.13.3, created at 2026-04-06 01:24 +0000

1from fastapi import FastAPI, Query 1abcdefghi

2 

3app = FastAPI() 1abcdefghi

4 

5 

6@app.get("/items/") 1abcdefghi

7async def read_items( 1abcdefghi

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"}]} 1jnokplqrmst

20 if q: 1jnokplqrmst

21 results.update({"q": q}) 1jklm

22 return results 1jnokplqrmst