JSON-Schema-Test-Suite icon indicating copy to clipboard operation
JSON-Schema-Test-Suite copied to clipboard

test needed to show that transclusion of $ref into allOf changes the evaluation outcome

Open karenetheridge opened this issue 5 years ago • 3 comments
trafficstars

see https://json-schema.slack.com/archives/CT7FF623C/p1603727881177900?thread_ts=1603504778.173300&cid=CT7FF623C

Basically, we need a test to show that changing this:

{
  "$ref": "some subschema that generates annotations",
  "unevaluatedProperties": { ... },
}

to this:

{
  "allOf": [
    < that same subschema that generates annotations, included directly here... >,
    "unevaluatedProperties": { ... }
  ],
 
}

...does not always yield the same result, sibling keywords in a subschema can see annotations produced by earlier-evaluating siblings, but subchemas under allOf siblings cannot see each other's annotation results.

Therefore, this is not a reliable mechanism of transcluding/bundling referenced subschemas into the same schema.

cc @Relequestual

karenetheridge avatar Oct 26 '20 18:10 karenetheridge

~You need to move the unevalated* out of the allOf to make that work right.~

Oh, I see. You're saying these are not the same, which is correct. But if you move the unevaluated* out of the allOf, then they become semantically the same.

gregsdennis avatar Oct 26 '20 19:10 gregsdennis

I don't follow.. if unevaluatedProperties is the consumer of the annotations, it doesn't matter if the keywords are siblings or underneath an allOf. In both cases, the other keywords run first and unevaluatedProperties runs later.

If unevaluatedProperties is the producer of the annotations for some other keyword to consume, then that would be different, but the only keyword that consumes the unevaluatedProperties annotation is unevaluatedProperties itself, so I doubt that's what was intended here.

handrews avatar Aug 11 '22 19:08 handrews

Hey! I am writing an example below, tell me if this matches what is expected:

{
  "properties":{
    "foo": { "const": 11}
  },
  "allOf":[
    {
      "properties":{
        "baz": {"type": "string"}
      },
      "unevaluatedProperties": false
    }
  ]
}

--- this produces validation false

{
  "properties":{
    "foo": { "const": 11}
  },
  "$ref": "#/$defs/bar",
  "unevaluatedProperties": false,
  "$defs":{
    "bar":{
      "properties":{
        "baz": {"type": "string"}
      }
    }
  }
}

--- and this produces true result.

for the instance: {"foo":11, "baz": "hello"} @gregsdennis @jdesrosiers @Julian

suprith-hub avatar Apr 11 '24 08:04 suprith-hub