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

Description and test case contradiction: unevaluatedProperties #723

Open
AgniveshChaubey opened this issue Mar 14, 2024 · 3 comments
Open
Labels
bug A test is wrong, or tooling is broken or buggy.

Comments

@AgniveshChaubey
Copy link

Reference:

"description": "when if is true and has no unevaluated properties",

Schema:

{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "if": {
      "properties": {
          "foo": { "const": "then" }
      },
      "required": ["foo"]
  },
  "else": {
      "properties": {
          "baz": { "type": "string" }
      },
      "required": ["baz"]
  },
  "unevaluatedProperties": false
}

Instance:

"tests": [
    {
        "description": "when if is true and has no unevaluated properties",
        "data": {
            "foo": "then",
            "bar": "bar"
        },
        "valid": false
    },
    ...
]

The description of the above test states that it has no unevaluated properties, but isn't the bar property here unevaluated?

@AgniveshChaubey AgniveshChaubey changed the title Description and test case contradiction Description and test case contradiction: unevaluatedProperties Mar 14, 2024
@jdesrosiers
Copy link
Member

I agree that it's wrong, but I think the test is wrong, not the description. The test should be updated to match the description.

@gregsdennis
Copy link
Member

gregsdennis commented Mar 18, 2024

The test case is right, technically (but there may also be an error in expressing the intent).

bar is never defined, so in that regard, the test is correct.

However, the test might have meant baz instead of bar. In that case, /else is skipped when /if is true. Because baz is defined only in the else subschema (which isn't evaluated), it remains unevaluated.

@jdesrosiers
Copy link
Member

You're right, but that's not what I meant. Look at all the descriptions for all the tests. It's a matrix of the possibilities of two variables: (1) if result (2) unevaluated properties result.

  • when if is true and has no unevaluated properties
  • when if is true and has unevaluated properties
  • when if is false and has no unevaluated properties
  • when if is false and has unevaluated properties

The test should be changed to actually test what the description says otherwise it's just a another test for "when if is true and has unevaluated properties", which is already covered.

@Julian Julian added the bug A test is wrong, or tooling is broken or buggy. label Apr 6, 2024
MeastroZI added a commit to MeastroZI/JSON-Schema-Test-Suite_MY that referenced this issue Apr 26, 2024
json-schema-org#723

 think removing the bar matches the test with the description, as foo itself is evaluated.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A test is wrong, or tooling is broken or buggy.
Projects
None yet
Development

No branches or pull requests

4 participants