Skip to main content

get_body_field

Get a ModelField representing the request body for a path operation, combining all body parameters into a single field if necessary. Used to check if it's form data (with isinstance(body_field, params.Form)) or JSON and to generate the JSON Schema for a request body. This is not used to validate/parse the request body, that's done with each individual body parameter.

def get_body_field(
flat_dependant: Dependant,
name: str,
embed_body_fields: bool
) - > ModelField | None

Get a ModelField representing the request body for a path operation, combining all body parameters into a single field if necessary. Used to check if it's form data (with isinstance(body_field, params.Form)) or JSON and to generate the JSON Schema for a request body.

Parameters

NameTypeDescription
flat_dependantDependantThe dependency object containing the flattened list of body parameters for the path operation.
namestrThe name of the path operation function, used to generate a unique name for the internal body model.
embed_body_fieldsboolA flag indicating whether to wrap multiple body parameters into a single embedded model or return the first parameter directly.

Returns

TypeDescription
`ModelFieldNone`