JSON-Schema-Test-Suite: Test that oneOf handles missing optional property

This shouldn’t really be necessary, but at least one validation library fails this test.

{
  "description": "oneOf complex types",
  "schema": {
    "oneOf": [
      {
        "properties": {
          "bar": {"type": "integer"}
         /* , "baz": {"type": "boolean"} <-- new optional propery, not in data */
        },
        "required": ["bar"]
      },
      {
        "properties": {
          "foo": {"type": "string"}
        },
        "required": ["foo"]
      }
    ]
  },
  "tests": [
    {
      "description": "first oneOf valid (complex)",
      "data": {"bar": 2},
      "valid": true
    },
    {
      "description": "second oneOf valid (complex)",
      "data": {"foo": "baz"},
      "valid": true
    },
    {
      "description": "both oneOf valid (complex)",
      "data": {"foo": "baz", "bar": 2},
      "valid": false
    },
    {
      "description": "neither oneOf valid (complex)",
      "data": {"foo": 2, "bar": "quux"},
      "valid": false
    }
  ]
}

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 17 (10 by maintainers)

Commits related to this issue

Most upvoted comments

@aznan2 Julian said what I was trying to allude to. The location of a subschema should not change the validation result of that subschema by itself. The combination of an array of subschema validation results should be collected and modified by the encasing applicator keyword, if any, such as *Of and not for example.