From 7a4f8ca675c4ee5bbde2ba8076e4e068a7266517 Mon Sep 17 00:00:00 2001 From: Yurii Motov Date: Wed, 10 Dec 2025 18:15:10 +0100 Subject: [PATCH] Only check computed fields if separate_input_output_schemas is False --- fastapi/_compat/v2.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/fastapi/_compat/v2.py b/fastapi/_compat/v2.py index dbdcdd382..b5e6e8983 100644 --- a/fastapi/_compat/v2.py +++ b/fastapi/_compat/v2.py @@ -200,11 +200,13 @@ def get_schema_from_model_field( ], separate_input_output_schemas: bool = True, ) -> Dict[str, Any]: - override_mode: Union[Literal["validation"], None] = ( - None - if (separate_input_output_schemas or _has_computed_fields(field)) - else "validation" - ) + override_mode: Union[Literal["validation"], None] = None + if not separate_input_output_schemas: + override_mode = ( + None + if (separate_input_output_schemas or _has_computed_fields(field)) + else "validation" + ) # This expects that GenerateJsonSchema was already used to generate the definitions json_schema = field_mapping[(field, override_mode or field.mode)] if "$ref" not in json_schema: