-
-
Notifications
You must be signed in to change notification settings - Fork 216
Tests for propertyNames with additionalProperties/unevaluatedProperties #733
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
Changes from 1 commit
99864ff
f08b884
964efb8
c5f3e4e
616240b
3e0139a
6aa79c0
2480edb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
[ | ||
{ | ||
"description": "propertyNames validation", | ||
"specification": [ { "core": "10.3.2.4" } ], | ||
"schema": { | ||
"$schema": "https://json-schema.org/draft/2020-12/schema", | ||
"propertyNames": {"maxLength": 3} | ||
|
@@ -46,6 +47,7 @@ | |
}, | ||
{ | ||
"description": "propertyNames with boolean schema true", | ||
"specification": [ { "core": "10.3.2.4", "quote": "The value of \"propertyNames\" MUST be a valid JSON Schema." } ], | ||
"schema": { | ||
"$schema": "https://json-schema.org/draft/2020-12/schema", | ||
"propertyNames": true | ||
|
@@ -65,6 +67,7 @@ | |
}, | ||
{ | ||
"description": "propertyNames with boolean schema false", | ||
"specification": [ { "core": "10.3.2.4", "quote": "The value of \"propertyNames\" MUST be a valid JSON Schema." } ], | ||
"schema": { | ||
"$schema": "https://json-schema.org/draft/2020-12/schema", | ||
"propertyNames": false | ||
|
@@ -81,5 +84,60 @@ | |
"valid": true | ||
} | ||
] | ||
}, | ||
{ | ||
"description": "propertyNames with additionalProperties", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These test cases aren't actually testing whether additional properties are allowed. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This test is to actually check if There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "In this test case, the validation of data fails. For example: {
"description": "property name is invalid",
"data": { "watermelon": 6 },
"valid": false
} This failure occurs due to the exceeded property length in the validation of propertyName, rather than due to unevaluated properties. Therefore, this test does not actually determine whether additional properties are allowed or not." There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So, " There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
No, that's backward. There's no reason For example, your first test case with "apple" should be invalid because the property isn't allowed. The tests are about There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So, we should be checking whether There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There's no need. There's nothing in the spec that suggests There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see. I get it! so tests are written when the information in ambiguous, especially in spec.. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, that and explicit requirements. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Cool cool! Can you review the latest changes... |
||
"specification": [ { "core": "10.3.2.4" }, { "core": "10.3.2.3", "quote": "The validation of propertyNames remains unaffected by the presence or absence of additionalProperties. \"propertyNames\" are validated independently, regardless of other sibling keywords" } ], | ||
"schema": { | ||
"$schema": "https://json-schema.org/draft/2020-12/schema", | ||
"additionalProperties":{ | ||
"type": "number" | ||
}, | ||
"propertyNames": { | ||
"maxLength": 5 | ||
} | ||
}, | ||
"tests": [ | ||
{ | ||
"description": "property names with the given pattern are valid", | ||
"data": {"apple": 4}, | ||
"valid": true | ||
}, | ||
{ | ||
"description": "property name is invalid", | ||
"data": { "watermelon": 6 }, | ||
"valid": false | ||
} | ||
] | ||
}, | ||
{ | ||
"description": "propertyNames with unevaluatedProperties", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These aren't testing whether unevaluated properties are allowed. |
||
"specification": [ { "core": "10.3.2.4" }, { "core":"11.3", "quote": "The validation of propertyNames remains unaffected by the presence or absence of unevaluatedProperties. \"propertyNames\" are validated independently, regardless of other sibling keywords" } ], | ||
"schema": { | ||
"$schema": "https://json-schema.org/draft/2020-12/schema", | ||
"properties":{ | ||
"banana":{ | ||
"const": "available" | ||
} | ||
}, | ||
"unevaluatedProperties":{ | ||
"type": "number" | ||
}, | ||
"propertyNames": { | ||
"pattern": "^[a-b]" | ||
} | ||
}, | ||
"tests": [ | ||
{ | ||
"description": "property names with the given pattern are valid", | ||
"data": { "banana": "available", "apple": 4 }, | ||
"valid": true | ||
}, | ||
{ | ||
"description": "property name chickoo is invalid", | ||
"data": { "banana": "available", "chickoo": 10 }, | ||
"valid": false | ||
} | ||
] | ||
} | ||
] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we haven't finalized these additions (the discussion for which is elsewhere), we should hold off adding them here. Please remove until that discussion had come to a final decision.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, cool with that 👍