Skip to content
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

anyOf in oneOf doesn't work correctly #606

Closed
sgerke-1L opened this issue Sep 7, 2022 · 3 comments
Closed

anyOf in oneOf doesn't work correctly #606

sgerke-1L opened this issue Sep 7, 2022 · 3 comments

Comments

@sgerke-1L
Copy link
Contributor

Consider the following schema:

{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "type": "object",
  "properties": {
    "V": {
      "type": "array",
      "items": {
        "oneOf": [
          {
            "type": "object",
            "properties": {
              "X": {
                "type": "string"
              }
            },
            "required": [
              "X"
            ],
            "additionalProperties": false
          },
          {
            "type": "object",
            "properties": {
              "A": {
                "type": "string"
              },
              "B": {
                "type": "string"
              },
              "C": {
                "type": "string"
              }
            },
            "anyOf": [
              {
                "properties": {
                  "origin": {
                    "const": "not-present"
                  }
                },
                "required": [
                  "A",
                  "C"
                ]
              },
              {
                "properties": {
                  "origin": {
                    "const": "not-present-either"
                  }
                },
                "required": [
                  "A",
                  "B"
                ]
              }
            ],
            "additionalProperties": false,
            "required": [
              "A"
            ],
            "not": {
              "type": "object",
              "required": [
                "X"
              ]
            }
          }
        ]
      }
    }
  }
}

This should match the following object:

{
    "V": [
        {
            "A": "foo",
            "B": "bar"
        }
    ]
}

but it doesn't. The problem seems to be that the AnyOfValidator doesn't set the setMatchedNode/hasMatchedNode properties correctly.

@sgerke-1L
Copy link
Contributor Author

See PR #607

@sgerke-1L
Copy link
Contributor Author

@stevehu now that this can be closed, would it be possible to make a release? This would make it easier for us to integrate the fix downstream.

@stevehu
Copy link
Contributor

stevehu commented Sep 16, 2022

I will have a release this weekend. Thanks.

@stevehu stevehu closed this as completed Sep 16, 2022
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

2 participants