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

8 statements  

« prev     ^ index     » next       coverage.py v7.6.1, created at 2024-08-08 03:53 +0000

1from fastapi import FastAPI, Query 1abc

2 

3app = FastAPI() 1abc

4 

5 

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

7async def read_items( 1abc

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

20 if q: 1abc

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

22 return results 1abc