The fastapi_utils.py module#

Summary#

extract_field_type

Extract the field type from a given schema field information.

extract_fields_from_schema

Extract fields and their types from a schema.

get_parameters_info

Get parameter information from function parameters.

get_return_type_info

Get return type information from the function’s return type.

extract_definitions_from_schema

Extract definitions from a schema.

get_definitions_from_params

Get definitions from function parameters.

get_definitions_from_return_type

Get definitions from the function’s return type.

extract_endpoint_info

Extract endpoint information from the given routes.

Description#

Utils module for FastAPI related operations.

Module detail#

fastapi_utils.extract_field_type(field_info: dict)#

Extract the field type from a given schema field information.

Parameters:
field_infodict

The field information from the schema.

Returns:
str

The extracted field type.

fastapi_utils.extract_fields_from_schema(schema: dict)#

Extract fields and their types from a schema.

Parameters:
schemadict

The schema dictionary.

Returns:
list

A list of ParameterInfo objects representing the fields.

fastapi_utils.get_parameters_info(params: dict)#

Get parameter information from function parameters.

Parameters:
paramsdict

A dictionary of function parameters.

Returns:
list

A list of ParameterInfo objects representing the parameters.

fastapi_utils.get_return_type_info(return_type: type[pydantic.BaseModel])#

Get return type information from the function’s return type.

Parameters:
return_typetype[BaseModel]

The return type of the function.

Returns:
list

A list of ParameterInfo objects representing the return type fields.

fastapi_utils.extract_definitions_from_schema(schema: dict) dict[str, Any]#

Extract definitions from a schema.

Parameters:
schemadict

The schema dictionary.

Returns:
dict

A dictionary of definitions.

fastapi_utils.get_definitions_from_params(params: dict) dict[str, Any]#

Get definitions from function parameters.

Parameters:
paramsdict

A dictionary of function parameters.

Returns:
dict

A dictionary of definitions extracted from the parameters.

fastapi_utils.get_definitions_from_return_type(return_type: type[pydantic.BaseModel]) dict[str, Any]#

Get definitions from the function’s return type.

Parameters:
return_typetype[BaseModel]

The return type of the function.

Returns:
dict

A dictionary of definitions extracted from the return type.

fastapi_utils.extract_endpoint_info(function_map: dict[str, Any], routes: list[fastapi.routing.APIRoute]) list[allie.flowkit.models.functions.EndpointInfo]#

Extract endpoint information from the given routes.

Parameters:
function_mapdict[str, Any]

A dictionary mapping function names to their implementations.

routeslist[APIRoute]

A list of APIRoute objects representing the API routes.

Returns:
list

A list of EndpointInfo objects representing the endpoints.