I am struggling to define a JSON schema to require one parameter and, at most one of the two optional parameters. In other words, the following should be legal:
{
"a_req" : "foo"
}
{
"a_req" : "foo",
"b_opt" : "bar"
}
{
"a_req" : "foo",
"c_opt" : "baz"
}
But the following should be illegal
{
"a_req" : "foo",
"b_opt" : "bar",
"c_opt" : "baz"
}
I've tried many permutations of the following, but it doesn't seem to work.
"oneOf" : [
{
"required": ["a_req"],
"not" : {"required" : ["b_opt", "c_opt"]}
},
{
"required": ["a_req", "b_opt"],
"not" : {"required" : ["c_opt"]}
},
{
"required": ["a_req", "c_opt"],
"not" : {"required" : ["b_opt"]}
},
]