protoc-gen-jsonschema
protoc-gen-jsonschema copied to clipboard
Multiple allowed in oneOf?
Kia Ora, I have a question: why does each member of the generated oneOf specify only what's required -- doesn't it mean that multiple members are allowed (one is required but multiple allowed) which runs counter to the semantics of oneof?
For example it's generating this:
"properties": {
"event_a": {
"$ref": "#/definitions/EventA",
},
"event_b": {
"$ref": "#/definitions/EventB",
}
},
"oneOf": [
{
"required": [
"event_a"
]
},
{
"required": [
"event_b"
]
}
],
... but I would have expected it to generate the following instead, so that only one of event_a or event_b can be present:
"oneOf": [
{
"properties": {
"event_a": {
"$ref": "#/definitions/EventA",
},
},
"required": ["event_a"]
},
{
"properties": {
"event_b": {
"$ref": "#/definitions/EventB",
}
},
"required": ["event_b"]
}
],
Hi @jscheid, thanks for your question. I've just merged a PR which changes the behaviour of "oneOf". Would you be able to have a go with the laster master and let me know if it addresses your concerns?
Thanks, I'll take a look today or tomorrow!