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
| Name | Type | Description |
|---|---|---|
| param_name | str | The name of the parameter being analyzed. |
| annotation | Any | The type annotation of the parameter, which may include Annotated types or other special FastAPI annotations. |
| value | Any | The default value assigned to the parameter, if any. This can also be a Depends object or a FieldInfo instance. |
| is_path_param | bool | A boolean indicating whether the parameter is part of the URL path. |
Returns
| Type | Description |
|---|---|
ParamDetails | An object containing the extracted type annotation, any detected dependency, and field information for the parameter. |