Description
I have a JSON schema that defines a type language_object
with some properties and then uses that on one of the fields, along with a minProperties
constraint.
However, when validating against this schema, submitting an empty object in said field does not raise a ValidationException
. It appears that the minProperties
constraint is ignored when it is placed alongside $ref
I have prepared a schema that defines my field once as name
using references and once as nameEx
with explicit properties. As far as I can tell these should be equivalent:
{
"type":"object",
"$schema":"http://json-schema.org/draft-04/schema#",
"definitions":{
"language_object":{
"type":"object",
"additionalProperties":false,
"patternProperties":{
"^[a-z]{2}$":{
"type":"string"
}
}
}
},
"properties":{
"name":{
"$ref":"#/definitions/language_object",
"minProperties":1
},
"nameEx":{
"type":"object",
"patternProperties":{
"^[a-z]{2}$":{
"type":"string"
}
},
"additionalProperties":false,
"minProperties":1
},
"date":{
"type":"string",
"format":"date-time"
}
}
}
When I validate the following JSON
{
"name":{},
"nameEx":{}
}
I only get #/nameEx: minimum size: [1], found: [0]
, not both. Other situations, like this disallowed key/property work fine on both:
{
"name":{"nbb":"bla"},
"nameEx":{"nbb":"bla"}
}
Returns
#: 2 schema violations found
#/nameEx: extraneous key [nbb] is not permitted
#/name: extraneous key [nbb] is not permitted
Thank you for your patience!