Closed jalaziz closed 1 year ago
Based on https://github.com/golang/protobuf/issues/1409, looks like I need to move this to the official protobuf repo. Researching around shows a lot of heartache trying to map Any
and oneof
to JSON schema's anyOf
and oneOf
.
I apologize if this has been asked before or if what I'm asking is crazy.
When serializing the WKT
Any
to json, theTypeURL
field is required, which ultimately means we end up with the@type
field in the resulting JSON.Normally this is not a big deal, but when serializing to JSON for a customer-facing API, the
@type
field is not always the most convenient and it would be ideal if a custom type discriminator could be used or, at least,@type
could be omitted.Is there any way to accomplish this today? I realize this would make deserializing back into protos far more complicated, but custom type discriminator support is not uncommon in JSON deserialization libraries and I'd rather not link proto type information in a public API.