From 98c1a277e28beed12e3291ec48cd95bba8a37b19 Mon Sep 17 00:00:00 2001 From: Alexander Tikhonov Date: Sat, 23 Nov 2024 15:48:50 +0300 Subject: [PATCH] Add a temporary workaround to get original type despite custom serialization --- mashumaro/jsonschema/schema.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/mashumaro/jsonschema/schema.py b/mashumaro/jsonschema/schema.py index 1145216..dfe6bde 100644 --- a/mashumaro/jsonschema/schema.py +++ b/mashumaro/jsonschema/schema.py @@ -105,6 +105,9 @@ class Instance: __owner_builder: Optional[CodeBuilder] = None __self_builder: Optional[CodeBuilder] = None + # Original type despite custom serialization. To be revised. + _original_type: Type = field(init=False) + origin_type: Type = field(init=False) annotations: list[Annotation] = field(init=False, default_factory=list) @@ -150,6 +153,7 @@ def derive(self, **changes: Any) -> "Instance": return new_instance def __post_init__(self) -> None: + self._original_type = self.type self.update_type(self.type) if is_annotated(self.type): self.annotations = getattr(self.type, "__metadata__", [])