Debian Codegraph @

docs_src/dependencies/tutorial001_an_py310.py

raw
1 from typing import Annotated
2
3 from fastapi import Depends, FastAPI
4
5 app = FastAPI()
6
7
8 async def common_parameters(q: str | None = None, skip: int = 0, limit: int = 100):
9 return {"q": q, "skip": skip, "limit": limit}
10
11
12 @app.get("/items/")
13 async def read_items(commons: Annotated[dict, Depends(common_parameters)]):
14 return commons
15
16
17 @app.get("/users/")
18 async def read_users(commons: Annotated[dict, Depends(common_parameters)]):
19 return commons