Module aws_lambda_powertools.event_handler.openapi.dependant

Functions

def add_param_to_fields(*, field: 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) ‑> ModelField | None

Get the Body field for a given Dependant object.

def get_body_field_info(*, body_model: type[BaseModel], flat_dependant: Dependant, required: bool)

Get the Body field info and kwargs for a given body model.

def get_dependant(*, path: str, call: Callable[..., Any], name: str | None = None, responses: dict[int, OpenAPIResponse] | None = 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[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: 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