_extract_form_body() — fastapi Function Reference
Architecture documentation for the _extract_form_body() function in utils.py from the fastapi codebase.
Entity Profile
Dependency Diagram
graph TD 5ea666fe_6840_7f7c_f45d_e67adf31134b["_extract_form_body()"] 9e602cbf_3139_86ae_5666_97b8806942de["utils.py"] 5ea666fe_6840_7f7c_f45d_e67adf31134b -->|defined in| 9e602cbf_3139_86ae_5666_97b8806942de b8125a22_3ce8_c209_1d2b_1aaf5de6f8b2["request_body_to_args()"] b8125a22_3ce8_c209_1d2b_1aaf5de6f8b2 -->|calls| 5ea666fe_6840_7f7c_f45d_e67adf31134b cd9f411c_484c_7d25_1807_29f71d341257["_get_multidict_value()"] 5ea666fe_6840_7f7c_f45d_e67adf31134b -->|calls| cd9f411c_484c_7d25_1807_29f71d341257 0f3cd5cf_3aea_6cfe_477e_4813f1243d25["get_validation_alias()"] 5ea666fe_6840_7f7c_f45d_e67adf31134b -->|calls| 0f3cd5cf_3aea_6cfe_477e_4813f1243d25 style 5ea666fe_6840_7f7c_f45d_e67adf31134b fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
fastapi/dependencies/utils.py lines 882–918
async def _extract_form_body(
body_fields: list[ModelField],
received_body: FormData,
) -> dict[str, Any]:
values = {}
for field in body_fields:
value = _get_multidict_value(field, received_body)
field_info = field.field_info
if (
isinstance(field_info, params.File)
and is_bytes_or_nonable_bytes_annotation(field.field_info.annotation)
and isinstance(value, UploadFile)
):
value = await value.read()
elif (
is_bytes_sequence_annotation(field.field_info.annotation)
and isinstance(field_info, params.File)
and value_is_sequence(value)
):
# For types
assert isinstance(value, sequence_types)
results: list[Union[bytes, str]] = []
for sub_value in value:
results.append(await sub_value.read())
value = serialize_sequence_value(field=field, value=results)
if value is not None:
values[get_validation_alias(field)] = value
field_aliases = {get_validation_alias(field) for field in body_fields}
for key in received_body.keys():
if key not in field_aliases:
param_values = received_body.getlist(key)
if len(param_values) == 1:
values[key] = param_values[0]
else:
values[key] = param_values
return values
Domain
Subdomains
Defined In
Called By
Source
Frequently Asked Questions
What does _extract_form_body() do?
_extract_form_body() is a function in the fastapi codebase, defined in fastapi/dependencies/utils.py.
Where is _extract_form_body() defined?
_extract_form_body() is defined in fastapi/dependencies/utils.py at line 882.
What does _extract_form_body() call?
_extract_form_body() calls 2 function(s): _get_multidict_value, get_validation_alias.
What calls _extract_form_body()?
_extract_form_body() is called by 1 function(s): request_body_to_args.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free