Skip to content

anyOf in oneOf doesn't work correctly #606

@sgerke-1L

Description

@sgerke-1L

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.

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