Coverage for docs_src / path_params_numeric_validations / tutorial006_py310.py: 100%

10 statements  

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

1from fastapi import FastAPI, Path, Query 1ijklmno

2 

3app = FastAPI() 1ijklmno

4 

5 

6@app.get("/items/{item_id}") 1ijklmno

7async def read_items( 1ijklmno

8 *, 

9 item_id: int = Path(title="The ID of the item to get", ge=0, le=1000), 

10 q: str, 

11 size: float = Query(gt=0, lt=10.5), 

12): 

13 results = {"item_id": item_id} 1eafbgchd

14 if q: 1eafbgchd

15 results.update({"q": q}) 1abcd

16 if size: 1eafbgchd

17 results.update({"size": size}) 1eafbgchd

18 return results 1eafbgchd