-
-
Notifications
You must be signed in to change notification settings - Fork 210
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
Tests for propertyNames with additionalProperties/unevaluatedProperties #733
Conversation
…operties, also with specification property
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.
As I described in #732, were testing additionalProperties
and unevaluatedProperties
here, not propertyNames
. These tests need to be moved to the appropriate files.
@@ -1,6 +1,7 @@ | |||
[ | |||
{ | |||
"description": "propertyNames validation", | |||
"specification": [ { "core": "10.3.2.4" } ], |
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 👍
@@ -81,5 +84,60 @@ | |||
"valid": true | |||
} | |||
] | |||
}, | |||
{ | |||
"description": "propertyNames with additionalProperties", |
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.
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 comment
The reason will be displayed to describe this comment to others. Learn more.
This test is to actually check if additionalProperties
affect propertyNames
.. so can you please recheck according to the requirement of the issue #305 @gregsdennis
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.
"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 comment
The reason will be displayed to describe this comment to others. Learn more.
So, "propertyNames
doesn't interact with other keywords." addressed in #305 this issue. This statement means that these test cases I have written should be included under additional/unevaluated Properties and not propertyNames??
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.
This test is to actually check if additionalProperties affect propertyNames
No, that's backward. There's no reason additionalProperties
would influence propertyNames
, but the spec could be misread that propertyNames
defines properties that additionalProperties
would then skip. That's what the issue is about.
For example, your first test case with "apple" should be invalid because the property isn't allowed.
The tests are about additionalProperties
.
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.
So, we should be checking whether propertyNames
affect adiditionalProperties
. Got it, I feel we can go both the way on the tests if its ok.
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.
I feel we can go both the way on the tests if its ok.
There's no need. There's nothing in the spec that suggests additionalProperties
could affect propertyNames
. We don't have tests that ensure maxLength
and items
are independent because nothing implies that they're connected.
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.
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 comment
The 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 comment
The reason will be displayed to describe this comment to others. Learn more.
Cool cool! Can you review the latest changes...
] | ||
}, | ||
{ | ||
"description": "propertyNames with unevaluatedProperties", |
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.
These aren't testing whether unevaluated properties are allowed.
H.. Actually
Huh.. this PR is related to a different issue than issue #626. The issue #305 description says:
|
@Era-cell, |
No. There is no change in behavior. The tests are to verify that. |
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.
These look good. Please add them to 2019 and "next".
…y for unevaluatedProps
I saw just now, that the tests are present already for unevaluatedProperties from 2019 - draft-next, already. So, I have considered to add tests only for additionalProperties |
So for this schema {"propertyNames": {
"maxLength": 5
},
"additionalProperties": false
} Should the data { apple: "apple" } be considered valid or not? because It appears we don't have tests for this specific case also. |
Correct, We do have that test with the latest update: see line 175 in the first file. |
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.
Asked for another pair of eyes.
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.
lgtm, but needs a little code style cleanup. I left suggestions inline.
Co-authored-by: Jason Desrosiers <[email protected]>
Co-authored-by: Jason Desrosiers <[email protected]>
Co-authored-by: Jason Desrosiers <[email protected]>
I have updated the changes, and Thank you |
"valid": true | ||
}, | ||
{ | ||
"description": "Valid against propertyNames, but not unevaluatedProperties", |
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.
this says unevaluatedProperties
, should say additionalProperties
I think.
same for the other two.
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.
Yeah! let me just correct it and raise the pull request again.
I will have to be more careful... Thank you
Addressing the issue: 305. Also inculded "specification" property,
I have added it such a way that property names cover pattern and length constraints too.
Please review my PR