analyze_param
Parses and validates a function parameter's metadata to determine its FastAPI-specific configuration, such as whether it is a dependency, a path parameter, or a body field. It extracts type annotations and default values to construct a model field while enforcing strict validation rules for parameter definitions.
def analyze_param(
param_name: str,
annotation: Any,
value: Any,
is_path_param: bool
) - > ParamDetails
Parses and validates a function parameter to determine its FastAPI-specific metadata, such as whether it is a dependency, a path parameter, or a body field. This function resolves type annotations, handles Annotated metadata, and assigns appropriate FieldInfo or Depends objects based on the parameter's default value and type.
Parameters
| Name | Type | Description |
|---|---|---|
| param_name | str | The name of the parameter as defined in the function signature. |
| annotation | Any | The type hint or annotation associated with the parameter, used to infer the data type and validation rules. |
| value | Any | The default value assigned to the parameter in the function signature, which may contain FastAPI metadata like Query() or Depends(). |
| is_path_param | bool | A flag indicating whether this parameter is part of the URL path template. |
Returns
| Type | Description |
|---|---|
ParamDetails | An object containing the resolved type annotation, the dependency information if applicable, and the constructed model field for the parameter. |