Closed geny200 closed 4 months ago
Hi! Thanks for reporting. This is actually the case for all codecs configured with usingElementNamesAsDiscriminator
if the @default
annotation is not used for parameter with such codec.
It's certainly a flaw, but it's caused by decoder derivation design. Derivation compares XML element name and case class parameter name to select which decoder to use. This cannot be applied for decoders with usingElementNamesAsDiscriminator
, because in this case XML element name does not match the parameter name. The @default
annotation is required to solve this problem. Fixing this flaw requires a complete redesign of Phobos interfaces, and so far I don't have ideas how to do it.
I suppose, the best thing we can do for now is enhance usingElementNamesAsDiscriminator
documentation. The need for @default
annotation must be described there. I can do it in near future, you may also contribute, if you wish
The
@default
annotation is required to solve this problem
Actually, in general, this won't help
Hi!
Actually, in general, this won't help
Field kek: Foo
in Bar
does not have the @default
annotation, so still it's the same case. If a case class has two fields using element names as a discriminator, Phobos won't understand which field it should use for decoding. A solution for this case is to use List
: @default foo: List[Foo]
Merged #20 with documentation update, so closing this issue
Hi, I found a case where the law
x == decode(encode(x))
is not fulfilled.Example: