-
-
Notifications
You must be signed in to change notification settings - Fork 29
Adding support for dataclass Union field #63
Copy link
Copy link
Closed
Description
Hi there!
We are starting using this package a lot in our product and it's great!
One gap we reached into is support for dataclass union (typing.Union[dataclass1, dataclass2, ...]) as one of the dataclass fields.
Example case:
@dataclass
class A:
a: int
@dataclass
class B:
b: int
@dataclass
class Response:
obj: A | B
class ResponseSerializer(DataclassSerializer)
class Meta:
dataclass = ResponseI solved this by extending DataclassSerializer and add support using rest-polymorphic.
We also use drf-spectacular for openapi scheme and it also supports rest-polymorphic, so all good!
Before I open PR I wanted to check that this feature is useful, I would be happy to get a feedback :)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels