Coverage for fastapi/dependencies/models.py: 100%
28 statements
« prev ^ index » next coverage.py v7.6.1, created at 2024-08-08 03:53 +0000
« prev ^ index » next coverage.py v7.6.1, created at 2024-08-08 03:53 +0000
1from typing import Any, Callable, List, Optional, Sequence 1abcde
3from fastapi._compat import ModelField 1abcde
4from fastapi.security.base import SecurityBase 1abcde
7class SecurityRequirement: 1abcde
8 def __init__( 1abcde
9 self, security_scheme: SecurityBase, scopes: Optional[Sequence[str]] = None
10 ):
11 self.security_scheme = security_scheme 1abcde
12 self.scopes = scopes 1abcde
15class Dependant: 1abcde
16 def __init__( 1abcde
17 self,
18 *,
19 path_params: Optional[List[ModelField]] = None,
20 query_params: Optional[List[ModelField]] = None,
21 header_params: Optional[List[ModelField]] = None,
22 cookie_params: Optional[List[ModelField]] = None,
23 body_params: Optional[List[ModelField]] = None,
24 dependencies: Optional[List["Dependant"]] = None,
25 security_schemes: Optional[List[SecurityRequirement]] = None,
26 name: Optional[str] = None,
27 call: Optional[Callable[..., Any]] = None,
28 request_param_name: Optional[str] = None,
29 websocket_param_name: Optional[str] = None,
30 http_connection_param_name: Optional[str] = None,
31 response_param_name: Optional[str] = None,
32 background_tasks_param_name: Optional[str] = None,
33 security_scopes_param_name: Optional[str] = None,
34 security_scopes: Optional[List[str]] = None,
35 use_cache: bool = True,
36 path: Optional[str] = None,
37 ) -> None:
38 self.path_params = path_params or [] 1abcde
39 self.query_params = query_params or [] 1abcde
40 self.header_params = header_params or [] 1abcde
41 self.cookie_params = cookie_params or [] 1abcde
42 self.body_params = body_params or [] 1abcde
43 self.dependencies = dependencies or [] 1abcde
44 self.security_requirements = security_schemes or [] 1abcde
45 self.request_param_name = request_param_name 1abcde
46 self.websocket_param_name = websocket_param_name 1abcde
47 self.http_connection_param_name = http_connection_param_name 1abcde
48 self.response_param_name = response_param_name 1abcde
49 self.background_tasks_param_name = background_tasks_param_name 1abcde
50 self.security_scopes = security_scopes 1abcde
51 self.security_scopes_param_name = security_scopes_param_name 1abcde
52 self.name = name 1abcde
53 self.call = call 1abcde
54 self.use_cache = use_cache 1abcde
55 # Store the path to be able to re-generate a dependable from it in overrides
56 self.path = path 1abcde
57 # Save the cache key at creation to optimize performance
58 self.cache_key = (self.call, tuple(sorted(set(self.security_scopes or [])))) 1abcde