-
Notifications
You must be signed in to change notification settings - Fork 281
Closed
Description
I've got a JSON Schema. One of property of this schema is referenced, and the problem is, that this reference is not included in validation.
This is my Schema (taken from http://json-schema.org/learn/miscellaneous-examples.html)
{
"id": "https://example.com/arrays.schema.json",
"$schema": "http://json-schema.org/draft-07/schema#",
"description": "A representation of a person, company, organization, or place",
"type": "object",
"properties": {
"fruits": {
"type": "array",
"items": {
"type": "string"
}
},
"vegetables": {
"type": "array",
"items": { "$ref": "#/definitions/veggie" }
}
},
"definitions": {
"veggie": {
"type": "object",
"required": [ "veggieName", "veggieLike" ],
"properties": {
"veggieName": {
"type": "string",
"description": "The name of the vegetable."
},
"veggieLike": {
"type": "boolean",
"description": "Do I like this vegetable?"
}
}
}
}
}
and this is example of wrong validated JSON.
{
"fruits": [ "apple", "orange", "pear" ],
"vegetables": [
{
"veggieName": "potato"
},
{
"veggieName": "broccoli",
"veggieLike": false
}
]
}
I'm expecting ValidationException, because property "veggieLike" is missing in first vegetable object, but actually there is no error.
This is my JAVA code
Schema schema = SchemaLoader.builder().schemaJson(new JSONObject(new JSONTokener(rawSchema))).build().load().build();
schema.validate(new JSONObject(json));
Metadata
Metadata
Assignees
Labels
No labels