oxan/djangorestframework-dataclasses

[Question]: Nested serializer with Union

felippemr opened this issue ยท 2 comments

๐Ÿ‘‹ I have a dataclass that look like this:

@dc
class Document:
    id: UUID
    details: Union[ComplianceDoc, SignatureDoc]
    ...

@dc
class ComplianceDoc:
    ...

@dc
class SignatureDoc:
    ...

What is the expected behavior if I give this to a serializer? Currently it is just getting the first type within the Union.

oxan commented

From the README:

Type unions are not supported yet.

Expected behavior is that you don't do that ;-)

I'm honestly not sure how type unions should work, though, particularly for deserialization. How should it know which type to expect?

oxan commented

Closing as not an actionable issue.