I might be doing this wrong because the error message is not helpful- even though this "works"
I have an enum (field1) that can be aaa or bbb
If its aaa then field2 must be required. If its not aaa then field2 can be optional
I have this now
"anyOf": [
{
"properties": {
"field1": {
"const": "aaa"
}
},
"required": [
"field2"
]
},
{
"properties": {
"field1": {
"const": "bbb"
}
}
}
]
But this is the error I get if field1 = aaa and field2 is not specified:
E jsonschema.exceptions.ValidationError: 'bbb' was expected
E
E Failed validating 'const' in schema[1]['properties']['field1']:
E {'const': 'bbb'}
E
E On instance['httpMethod']:
E 'aaa'
I was expecting an error more like "field2" expected because schema[1]['properties']['field1'] == bbb
Am I using this incorrectly?