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

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

Open
karenetheridge opened this issue Oct 26, 2020 · 3 comments
Labels
missing test A request to add a test to the suite that is currently not covered elsewhere.

Comments

@karenetheridge
Copy link
Member

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 karenetheridge added the missing test A request to add a test to the suite that is currently not covered elsewhere. label Oct 26, 2020
@gregsdennis
Copy link
Member

gregsdennis commented Oct 26, 2020

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.

@handrews
Copy link
Contributor

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.

@suprith-hub
Copy link
Contributor

suprith-hub commented Apr 11, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
missing test A request to add a test to the suite that is currently not covered elsewhere.
Projects
None yet
Development

No branches or pull requests

4 participants