json-schema-validator
json-schema-validator copied to clipboard
anyOf fails when config enabled but discriminator not defined
I am looking to add discriminators to my new schemas. The old schemas will not continue to not include them. If I enable openAPI3StyleDiscriminators, my old schemas which contain anyOf then fail validation.
Is it expected behaviour that if discriminator use is configured that discriminators must be used in schemas?
This may be replicated by appending the following to discriminator.json then running OpenAPI30JsonSchemaTest:
{
"description": "absent discriminator definition - anyOf integer/string",
"schema": {
"type": "object",
"properties": {
"intOrStringType": {
"anyOf": [
{
"type": "integer"
},
{
"type": "string"
}
]
}
}
},
"tests": [
{
"description": "does not fallback to default anyOf behaviour - 'should be valid to any of the schemas string'",
"data": {
"intOrStringType": 4
},
"valid": true
}
]
}
@FWiesner perhaps you may be able to advise whether I am misusing the feature?
Thank you.