We are using the following schema. In the following schema we have
- OuterObject with innerObject as a property.
- InnerObject is marked as oneOf String or Object with required properties.
{ "$schema": "http://json-schema.org/draft-07/schema#", "$id": "https://example.com/issue-470.json", "title": "OneOf validation message", "description": "Test description", "type": "object", "properties": { "outerObject": { "type": "object", "properties": { "innerObject": { "oneOf": [ { "type": "string" }, { "type": "object", "properties": { "value": { "type": "string" }, "unit": { "type": "string" } }, "additionalProperties": false, "required": [ "value", "unit" ] } ] } } } }, "additionalProperties": false }
the above schema was validated with below json data.
{ "outerObject": { "innerObject": {} } }
The errors given by oneOfValidator are
$.letterSpacing.wide: object found, string expected
The expected one was
$.outerObject.innerObject: object found, string expected
$.outerObject.innerObject.value: is missing but it is required
$.outerObject.innerObject.unit: is missing but it is required
After Inspecting the oneOfValidator code we figured out that
- we are filtering the required error deliberately in the oneOfValidator. Any Known reason for the same?