'Subschema validation with combined oneOf + allOf fails with ajv
At the moment I am programmatically transforming my spec so it can be read by ajv.
Without any changes I get errors.
For example, the additionalProperties: false from the first and third allOf fields are conflicting
and seeing the properties of the other as additional properties.
Is there a way to use ajv to validate against the input without needing to transform it?
Full Schema:
{
"allOf": [
{
"type": "object",
"additionalProperties": false,
"required": [
"id"
],
"properties": {
"id": {
"type": "string"
}
}
},
{
"oneOf": [
{
"type": "object",
"additionalProperties": false,
"properties": {
"oneOfProperty1": {
"type": "string"
}
}
},
{
"type": "object",
"additionalProperties": false,
"properties": {
"oneOfProperty2": {
"type": "number"
}
}
}
]
},
{
"type": "object",
"additionalProperties": false,
"properties": {
"property1": {
"type": "string"
},
"property2": {
"type": "string"
},
"property3": {
"type": "object",
"additionalProperties": false,
"properties": {
"nestedProperty1": {
"type": "string"
},
"nestedProperty2": {
"type": "string"
}
}
}
}
}
]
}
Both of these should be valid in the end:
{
"id": "someId",
"oneOfProperty1": "someValue",
"property1": "someValue",
"property2": "someValue",
"property3": {
"nestedProperty1": "someValue",
"nestedProperty2": "someValue"
}
}
and
{
"id": "someId",
"oneOfProperty2": 123,
"property1": "someValue",
"property2": "someValue",
"property3": {
"nestedProperty1": "someValue",
"nestedProperty2": "someValue"
}
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
