lovasoa / marshmallow_dataclass

Automatic generation of marshmallow schemas from dataclasses.
https://lovasoa.github.io/marshmallow_dataclass/html/marshmallow_dataclass.html
MIT License
456 stars 78 forks source link

add support for union with metadata #166 #231

Open AnkurDedania opened 1 year ago

AnkurDedania commented 1 year ago

An approach to fix issues described in #166 where metadata configuration needs to be passed

dairiki commented 1 year ago

Thank you for the PR.

I’m not convinced that this is the correct solution to the issue. When constructing a schema for:

@dataclass
class X
    y: Union[SomeType, OtherType] = field(metadata=some_metadata)

we need to construct three schema fields: one for SomeType, one for OtherType, and finally one for the Union. In the general case, it seems unreasonable to assume that we want to pass exactly the same custom metadata to all three of those fields.

I've just left a comment on #166 with more on this.