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

Improper error message for "unevaluatedProperties": false schema always fails #32

Open
FloriNNic opened this issue Nov 27, 2023 · 1 comment

Comments

@FloriNNic
Copy link

Hi,

I am trying to validate against a schema that does not allow unevaluated properties and I'm getting the following error every single time: false schema always fails. I managed to reproduce the behavior on a smaller schema:

  • Schema: { "$schema": "http://json-schema.org/draft/2020-12/schema#", "type": "object", "properties": { "key2": { "type": "string" } }, "unevaluatedProperties": false }

  • Document to validate: { "key": "val" }

Any thoughts on this?

Thanks in advance,
Florin

@erosb
Copy link
Owner

erosb commented Nov 27, 2023

Hello Florin,

AFAIR this is a known issue also highlighted by a failing test from the failing test suite. The problem is that in the "unevaluatedProperties" implementation only the properties which are one nesting level deeper are marked as evaluated, not by adjacent keywords. By "one nesting level deeper" I mean nested by allOf/anyOf/oneOf/if-then-else.

As a quick workaround I suggest writing your schema as

{
  "$schema": "http://json-schema.org/draft/2020-12/schema#",
  "allOf": [
    {
      "type": "object",
      "properties": { "key2": { "type": "string" } }
    }
  ]
  "unevaluatedProperties": false
}

Hope it helps.

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