Debian Codegraph @

docs/examples/dependency_injection/dependency_skip_validation.py

raw
1 from typing import Any, Dict
2
3 from litestar import Litestar, get
4 from litestar.di import NamedDependency
5 from litestar.params import SkipValidation
6
7
8 async def provide_str() -> str:
9 """Returns a string."""
10 return "whoops"
11
12
13 @get("/", dependencies={"injected": provide_str})
14 async def hello_world(injected: NamedDependency[SkipValidation[int]]) -> Dict[str, Any]:
15 """Handler expects an `int`, but we've provided a `str`."""
16 return {"hello": injected}
17
18
19 app = Litestar(route_handlers=[hello_world])