Module aws_lambda_powertools.event_handler.openapi.dependant
Functions
def add_param_to_fields(*, field: pydantic.fields.ModelField, dependant: Dependant) ‑> None
-
Adds a parameter to the list of parameters in the dependant model.
Parameters
field
:ModelField
- The field to add
dependant
:Dependant
- The dependant model to add the field to
def get_body_field(*, dependant: Dependant, name: str) ‑> Optional[pydantic.fields.ModelField]
-
Get the Body field for a given Dependant object.
def get_body_field_info(*, body_model: Type[pydantic.main.BaseModel], flat_dependant: Dependant, required: bool) ‑> Tuple[Type[Body], Dict[str, Any]]
-
Get the Body field info and kwargs for a given body model.
def get_dependant(*, path: str, call: Callable[..., Any], name: Optional[str] = None, responses: Optional[Dict[int, OpenAPIResponse]] = None) ‑> Dependant
-
Returns a dependant model for a handler function. A dependant model is a model that contains the parameters and return value of a handler function.
Parameters
path
:str
- The path template
call
:Callable[…, Any]
- The handler function
name
:str
, optional- The name of the handler function
responses
:List[Dict[int, OpenAPIResponse]]
, optional- The list of extra responses for the handler function
Returns
Dependant
- The dependant model for the handler function
def get_flat_params(dependant: Dependant) ‑> List[pydantic.fields.ModelField]
-
Get a list of all the parameters from a Dependant object.
Parameters
dependant
:Dependant
- The Dependant object containing the parameters.
Returns
List[ModelField]
- A list of ModelField objects containing the flat parameters from the Dependant object.
def get_path_param_names(path: str) ‑> Set[str]
-
Returns the path parameter names from a path template. Those are the strings between { and }.
Parameters
path
:str
- The path template
Returns
Set[str]
- The path parameter names
def get_typed_annotation(annotation: Any, globalns: Dict[str, Any]) ‑> Any
-
Evaluates a type annotation, which can be a string or a ForwardRef.
def get_typed_signature(call: Callable[..., Any]) ‑> inspect.Signature
-
Returns a typed signature for a callable, resolving forward references.
Parameters
call
:Callable[…, Any]
- The callable to get the signature for
Returns
inspect.Signature
- The typed signature
def is_body_param(*, param_field: pydantic.fields.ModelField, is_path_param: bool) ‑> bool
-
Returns whether a parameter is a request body parameter, by checking if it is a scalar field or a body field.
Parameters
param_field
:ModelField
- The parameter field
is_path_param
:bool
- Whether the parameter is a path parameter
Returns
bool
- Whether the parameter is a request body parameter