You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Given a class hierarchy as generated by xsdata, I'd like to use mashumaro to (de)serialize it.
I can not inject the DataClass...Mixins, the class hierarchy is "as-is". however the class hierarchy is plain and simple and stand-alone python.
The solution I'd like
I'd love to see a mashumaro "visitor" which given an arbitrary @dataclass C recursively walks the fields fields(C) and uses that information to compile a serializer and a deserializer.
Alternatives I've considered
I've tried to find ways to inject one of the mixins into the generated classes. however that xsdata strongly opines against modifying the generated model in any shape or form.
Additional context
I think having the possibility to pass mashumaro any dataclass and have it examine the class and it's fields recursively without the need for mixins would be amazing. It would also open the door to serialize and deserialize into different formats. I love the idea of mashumaro to precompile the parser and the serializer.
The text was updated successfully, but these errors were encountered:
Thanks for opening this issue and for a good use case.
The reason why we currently check the mixin subclassing is the dependence on the presence of from_* / to_* methods in nested dataclasses. If we were using is_dataclass for nested dataclasses we wouldn't deserialize them because we need from_dict method which will be missing. On the other hand, I understand the importance of supporting dataclasses without the mixin, so I was thinking of injecting __mashumaro_from_* / __mashumaro_to_* methods to the nested dataclasses by the visitor and use them appropriately. The visitor is already doing this with the from_* / to_* methods if it sees a nested DataClassDictMixin subclass without an appropriate method for the first time. I'm going to make this improvement in one of the next releases.
Given a class hierarchy as generated by xsdata, I'd like to use mashumaro to (de)serialize it.
I can not inject the DataClass...Mixins, the class hierarchy is "as-is". however the class hierarchy is plain and simple and stand-alone python.
The solution I'd like
I'd love to see a mashumaro "visitor" which given an arbitrary
@dataclass
C recursively walks the fieldsfields(C)
and uses that information to compile a serializer and a deserializer.Alternatives I've considered
I've tried to find ways to inject one of the mixins into the generated classes. however that xsdata strongly opines against modifying the generated model in any shape or form.
Additional context
I think having the possibility to pass mashumaro any dataclass and have it examine the class and it's fields recursively without the need for mixins would be amazing. It would also open the door to serialize and deserialize into different formats. I love the idea of mashumaro to precompile the parser and the serializer.
The text was updated successfully, but these errors were encountered: