Error when validating Json against a schema defining oneOf
alvaroacev opened this issue · comments
Hi,
The method validate from com.fasterxml.jackson.databind.JsonNode
is returning following error:
com.github.fge.jsonschema.core.report.ListProcessingReport: failure
--- BEGIN MESSAGES ---
error: object instance has properties which are not allowed by the schema: ["postal_code","street"]
level: "error"
schema: {"loadingURI":"#","pointer":"/properties/address"}
instance: {"pointer":"/address"}
domain: "validation"
keyword: "additionalProperties"
unwanted: ["postal_code","street"]
--- END MESSAGES ---
When validating what it seems a valid schema and test
Schema:
"schemas": {
"Legal": {
"title": "Legal",
"type": "object",
"properties": {
"id": {
"type": "integer"
},
"solicitor": {
"type": "string"
},
"address": {
"oneOf": [
{
"properties": {
"street": {
"type": "string"
},
"postal_code": {
"type": "string"
}
},
"required": [
"street"
]
},
{
"properties": {
"email": {
"type": "string",
"format": "email"
}
},
"required": [
"email"
]
}
],
"type": "object"
}
},
"required": [
"id"
]
}
}
}
Test:
{
"id": 1,
"solicitor": "My solicitor",
"address": {
"street": "Mark Lane 55",
"postal_code": "NE1 3DQ"
}
}
Please can you have a look at it?
Many thanks