diff --git a/pydantic/_internal/_std_types_schema.py b/pydantic/_internal/_std_types_schema.py index 6f3c86cedc..389c470d99 100644 --- a/pydantic/_internal/_std_types_schema.py +++ b/pydantic/_internal/_std_types_schema.py @@ -33,7 +33,7 @@ from pydantic.types import Strict from ..config import ConfigDict -from ..json_schema import JsonSchemaValue, update_json_schema +from ..json_schema import JsonSchemaValue from . import _known_annotated_metadata, _typing_extra, _validators from ._core_utils import get_type_ref from ._internal_dataclass import slots_true @@ -87,7 +87,7 @@ def get_enum_core_schema(enum_type: type[Enum], config: ConfigDict) -> CoreSchem def get_json_schema(schema: CoreSchema, handler: GetJsonSchemaHandler) -> JsonSchemaValue: json_schema = handler(schema) original_schema = handler.resolve_ref_schema(json_schema) - update_json_schema(original_schema, js_updates) + original_schema.update(js_updates) return json_schema # we don't want to add the missing to the schema if it's the default one @@ -113,7 +113,7 @@ def get_json_schema(schema: CoreSchema, handler: GetJsonSchemaHandler) -> JsonSc def get_json_schema_no_cases(_, handler: GetJsonSchemaHandler) -> JsonSchemaValue: json_schema = handler(core_schema.enum_schema(enum_type, cases, sub_type=sub_type, ref=enum_ref)) original_schema = handler.resolve_ref_schema(json_schema) - update_json_schema(original_schema, js_updates) + original_schema.update(js_updates) return json_schema # Use an isinstance check for enums with no cases. diff --git a/pydantic/json_schema.py b/pydantic/json_schema.py index 8dfde7f985..9f0ceb3e36 100644 --- a/pydantic/json_schema.py +++ b/pydantic/json_schema.py @@ -89,6 +89,10 @@ _MODE_TITLE_MAPPING: dict[JsonSchemaMode, str] = {'validation': 'Input', 'serialization': 'Output'} +@deprecated( + '`update_json_schema` is deprecated, use a simple `my_dict.update(update_dict)` call instead.', + category=None, +) def update_json_schema(schema: JsonSchemaValue, updates: dict[str, Any]) -> JsonSchemaValue: """Update a JSON schema in-place by providing a dictionary of updates.