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.

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. This is not used to validate/parse the request body, that's done with each individual body parameter.

Parameters

NameTypeDescription
flat_dependantDependantThe Dependant object containing information about the path operation's dependencies, including body parameters.
namestrThe name of the path operation, used to construct the name of the combined body model.
embed_body_fieldsboolA boolean indicating whether to combine multiple body parameters into a single embedded ModelField.

Returns

TypeDescription
`ModelFieldNone`