get_openapi_operation_request_body() — fastapi Function Reference
Architecture documentation for the get_openapi_operation_request_body() function in utils.py from the fastapi codebase.
Entity Profile
Dependency Diagram
graph TD ff359e77_eeca_c04b_bc15_0c63fc7a4e03["get_openapi_operation_request_body()"] 0dcb823f_ea0d_bd04_752b_a3a3f875bba1["utils.py"] ff359e77_eeca_c04b_bc15_0c63fc7a4e03 -->|defined in| 0dcb823f_ea0d_bd04_752b_a3a3f875bba1 200f313e_38b9_296f_f9aa_afdeacb6b8ad["get_openapi_path()"] 200f313e_38b9_296f_f9aa_afdeacb6b8ad -->|calls| ff359e77_eeca_c04b_bc15_0c63fc7a4e03 1ac1bc37_1a47_e7e2_9156_ab0473094700["jsonable_encoder()"] ff359e77_eeca_c04b_bc15_0c63fc7a4e03 -->|calls| 1ac1bc37_1a47_e7e2_9156_ab0473094700 style ff359e77_eeca_c04b_bc15_0c63fc7a4e03 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
fastapi/openapi/utils.py lines 181–213
def get_openapi_operation_request_body(
*,
body_field: Optional[ModelField],
model_name_map: ModelNameMap,
field_mapping: dict[
tuple[ModelField, Literal["validation", "serialization"]], dict[str, Any]
],
separate_input_output_schemas: bool = True,
) -> Optional[dict[str, Any]]:
if not body_field:
return None
assert isinstance(body_field, ModelField)
body_schema = get_schema_from_model_field(
field=body_field,
model_name_map=model_name_map,
field_mapping=field_mapping,
separate_input_output_schemas=separate_input_output_schemas,
)
field_info = cast(Body, body_field.field_info)
request_media_type = field_info.media_type
required = body_field.field_info.is_required()
request_body_oai: dict[str, Any] = {}
if required:
request_body_oai["required"] = required
request_media_content: dict[str, Any] = {"schema": body_schema}
if field_info.openapi_examples:
request_media_content["examples"] = jsonable_encoder(
field_info.openapi_examples
)
elif field_info.example != Undefined:
request_media_content["example"] = jsonable_encoder(field_info.example)
request_body_oai["content"] = {request_media_type: request_media_content}
return request_body_oai
Domain
Subdomains
Defined In
Calls
Called By
Source
Frequently Asked Questions
What does get_openapi_operation_request_body() do?
get_openapi_operation_request_body() is a function in the fastapi codebase, defined in fastapi/openapi/utils.py.
Where is get_openapi_operation_request_body() defined?
get_openapi_operation_request_body() is defined in fastapi/openapi/utils.py at line 181.
What does get_openapi_operation_request_body() call?
get_openapi_operation_request_body() calls 1 function(s): jsonable_encoder.
What calls get_openapi_operation_request_body()?
get_openapi_operation_request_body() is called by 1 function(s): get_openapi_path.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free