From 01ace5b7cc1974a5652fbf5a03acdeaa60ab0b03 Mon Sep 17 00:00:00 2001 From: Christoph Eder Date: Sat, 13 Dec 2025 18:26:36 +0100 Subject: [PATCH] Changes in symbol.py Adopted changes from embedding.py --- anansyTypes/structures/symbol.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/anansyTypes/structures/symbol.py b/anansyTypes/structures/symbol.py index c412b52..abe2a27 100644 --- a/anansyTypes/structures/symbol.py +++ b/anansyTypes/structures/symbol.py @@ -40,7 +40,7 @@ class Symbol: return cls.from_dict(value) raise ValueError(f"Cannot convert {type(value)} to Symbol") - return core_schema.with_info_plain_validator_function( + python_schema = core_schema.with_info_plain_validator_function( lambda value, _: validate_symbol(value), serialization=core_schema.plain_serializer_function_ser_schema( lambda x: { @@ -53,3 +53,14 @@ class Symbol: when_used="json", ), ) + + return core_schema.json_or_python_schema( + json_schema=core_schema.typed_dict_schema( + { + "id": core_schema.typed_dict_field(core_schema.int_schema()), + "label": core_schema.typed_dict_field(core_schema.str_schema()), + "image": core_schema.typed_dict_field(core_schema.str_schema()), + } + ), + python_schema=python_schema, + )