8000 minProperties constraint ignored when using definitions/references in JSON schema · Issue #21 · everit-org/json-schema · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
minProperties constraint ignored when using definitions/references in JSON schema #21
Closed
@Antares42

Description

@Antares42

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0