55from itertools import groupby
66from typing import List , Optional , Union
77
8- import marshmallow_union
98from marshmallow import Schema , fields
109from marshmallow_enum import EnumField
10+ from marshmallow_oneofschema import OneOfSchema
1111
1212
1313def full_icon_path (path ):
@@ -183,7 +183,7 @@ class SocketResponseSchema(JSONSchema):
183183 icon_path = fields .Str ()
184184 plug_set_hash = fields .Str ()
185185 socket_item_type_hash = fields .Str ()
186- current_plug = marshmallow_union . Union ([ fields .Nested (PlugResponseSchema ), None ] )
186+ current_plug = fields .Nested (PlugResponseSchema )
187187
188188
189189class SocketedItem (ABC ):
@@ -617,9 +617,7 @@ class AspectSubclassAspectSocket:
617617class AspectSubclassAspectSocketSchema (JSONSchema ):
618618 display_name = fields .Str ()
619619 icon_path = fields .Str ()
620- current_aspect : marshmallow_union .Union (
621- [fields .Nested (AspectSubclassAspectSchema ), None ]
622- )
620+ current_aspect : fields .Nested (AspectSubclassAspectSchema )
623621
624622
625623@dataclass
@@ -645,9 +643,7 @@ class AspectSubclassFragmentSocket:
645643class AspectSubclassFragmentSocketSchema (JSONSchema ):
646644 display_name = fields .Str ()
647645 icon_path = fields .Str ()
648- current_fragment : marshmallow_union .Union (
649- [fields .Nested (AspectSubclassFragmentSchema ), None ]
650- )
646+ current_fragment : fields .Nested (AspectSubclassFragmentSchema )
651647
652648
653649@dataclass
@@ -767,6 +763,13 @@ class AspectSubclassSchema(JSONSchema):
767763 fragments = fields .List (fields .Nested (AspectSubclassFragmentSocketSchema ))
768764
769765
766+ class SubclassSchema (OneOfSchema ):
767+ type_schemas = {
768+ "TreeStyleSubclass" : TreeStyleSubclassSchema ,
769+ "AspectSubclass" : AspectSubclassSchema ,
770+ }
771+
772+
770773@dataclass
771774class FullCharacterData :
772775 character : Character
@@ -777,6 +780,4 @@ class FullCharacterData:
777780class FullCharacterDataSchema (JSONSchema ):
778781 character = fields .Nested (CharacterSchema )
779782 armor = fields .List (fields .Nested (ArmorPieceSchema ))
780- subclass = marshmallow_union .Union (
781- [fields .Nested (TreeStyleSubclassSchema ), fields .Nested (AspectSubclassSchema )]
782- )
783+ subclass = fields .Nested (SubclassSchema )
0 commit comments