`ProtobufConverter`: representing `oneof` fields as unions is inconsistent with other implementations
mdub opened this issue · 3 comments
When faced with a Protobuf schema that uses oneof
fields, such as:
message SampleMessage {
oneof test_oneof {
string name = 4;
SubMessage sub_message = 9;
}
}
the ProtobufConverter
generates a union struct. When the resulting SchemaAndValue
is serialized, e.g. to JSON, the "oneof
field" will be represented in the structure, e.g.
{
"test_oneof": {
"name": "Bob Dobbs"
}
}
This is inconsistent with most other implementations of Protobuf → JSON serialization, which do not "box" oneof
field-sets in this way. For example, println(sampleMessage.toJson())
would typically yield simply:
{
"name": "Bob Dobbs"
}
I'm wondering whether the "boxing" behaviour (i.e. generation of a union struct per oneof
) could be made configurable, so that we could opt out.
Hi @rayokota. I notice this issue has been closed, but your PR to fix it has not yet been merged. Any update on when it might be merged, and released?
Sorry, closed prematurely, it will be merged toward the end of Sept