Skip to content

Not proper "oneOf" handling #76

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
antonCPU opened this issue Oct 10, 2013 · 2 comments
Closed

Not proper "oneOf" handling #76

antonCPU opened this issue Oct 10, 2013 · 2 comments

Comments

@antonCPU
Copy link

{
    "oneOf": [
        {
            "type": "object",
            "properties": {
                "key": {
                    "type": "string"
                },
                "test1": {
                    "type": "string"
                }
            },
            "required": ["key", "test1"]
        },
        {
            "type": "object",
            "properties": {
                "key": {
                    "type": "string"
                },
                "test2": {
                    "type": "string"
                }
            },
            "required": ["key", "test2"]
        }
    ]
}

This schema will pass for:

{
     "test2" : "ok"
}

Because of array_unique() usage in JsonSchema\Constraints\Constraint::getErrors().
When the second schema will be checked a list of errors will contain "key" and "test1" errors. During checking will be added another error with "key" required, but array_unique() will erase it, so this schema will pass a criteria in JsonSchema\Constraints\Underfined::validateOfProperties() as a result.

alexmmm added a commit to alexmmm/json-schema that referenced this issue May 1, 2014
alexmmm added a commit to alexmmm/json-schema that referenced this issue May 2, 2014
hakre pushed a commit to hakre/json-schema that referenced this issue Mar 26, 2015
siwinski pushed a commit to siwinski/json-schema that referenced this issue Apr 20, 2015
@jojo1981
Copy link

Tested this issue with version: 2.0.0 and it works like supposed.

[
    {
        "property": "key",
        "message": "The property key is required",
        "constraint": "required"
    },
    {
        "property": "test1",
        "message": "The property test1 is required",
        "constraint": "required"
    },
    {
        "property": "",
        "message": "Failed to match exactly one schema",
        "constraint": "oneOf"
    }
]

@bighappyface I think this one can also be closed?

@bighappyface
Copy link
Collaborator

@jojo1981 thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants