Skip to main content

analyze_param

Analyzes a function parameter to extract its type annotation, FastAPI dependencies, and field information, handling various ways parameters can be defined (e.g., Annotated, default values, path parameters).

def analyze_param(
param_name: str,
annotation: Any,
value: Any,
is_path_param: bool
) - > ParamDetails

Analyzes a function parameter to determine its type, dependencies, and field information for FastAPI. This function is used internally by FastAPI to process route parameters, handling various annotations and default values to correctly interpret how a parameter should be handled (e.g., as a query parameter, path parameter, request body, or dependency).

Parameters

NameTypeDescription
param_namestrThe name of the parameter being analyzed.
annotationAnyThe type annotation of the parameter, which may include Annotated types or other special FastAPI annotations.
valueAnyThe default value assigned to the parameter, if any. This can also be a Depends object or a FieldInfo instance.
is_path_paramboolA boolean indicating whether the parameter is part of the URL path.

Returns

TypeDescription
ParamDetailsAn object containing the extracted type annotation, any detected dependency, and field information for the parameter.