-
-
Notifications
You must be signed in to change notification settings - Fork 207
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 format should make better use of vocabularies and optional/ is too overloaded with meaning #495
Comments
In draft2019-09 this was a little fuzzy because we didn't have any in-schema way of stating that formats should be treated as assertions, so putting the tests in optional/formats was the best we could do to indicate "if your implementation treats these as assertions, these tests apply". Now in draft2020-12 we have a mechanism, via $schema and $vocabulary, to assert this, so we need to move (or copy?) these tests into the main area and write a custom metaschema for them. That simply hasn't happened yet due to lack of tuits (indeed you will see that we have no tests at all yet of the $vocabulary keyword, or the $schema keyword using anything but the draft metaschema for each version). |
Hmm. Makes sense. How about a value in the test json files, along side "valid", for enabling annotations as assertions? Since the specification does define two possible ways to configure annotations as assertions: $vocabulary, and "whatever configuration method the implementation wants"; this new property could be referring to the later. Example, very bad one:
|
To quote from the spec:
So, some new in-test value can signal to implementations to enable this required feature, outside of the usage of in-schema vocabulary settings. |
I'd have to check the spec to make sure we didn't miss something, but the intention isn't that there are two ways to indicate whether format is an assertion or an annotation. Each draft should only have one method. Those methods are just different between the two drafts.
I don't think it's required to support format as assertions, so I think it still belongs in "optional". |
(https://json-schema.org/draft/2020-12/json-schema-validation.html#rfc.section.7.1)
(https://json-schema.org/draft/2020-12/json-schema-validation.html#rfc.section.7.2.1) |
CREF2 in the validation spec is the following quote, located at https://json-schema.org/draft/2020-12/json-schema-validation.html#rfc.section.7.2.1
The intent of saying that an implementation MAY still treat "format" as an assertion is in line with anntoation processing. We're making a suggestion on the likely use of that annotation, additionally specifying that this must not be the default behaviour to keep interoperability for regular users. The validation that is to be done when "format" is an annotation but treated as an assertion is implementation defined. As such, we should not provide any tests for such possible configuration modes. The optional tests we provide for "format" should only be those associated with the "format-assertion vocabulary" and not the "format-annotation vocabulary". I agree, we could make this a little clearer. I'd like to keep this open so we can reference it in relation issues we should consider when creating new test structures. |
@karenetheridge, thanks for looking that up. Did we leave the implementation defined option in place on purpose, or did that slip through the cracks? I thought the point of splitting "format" into two vocabs was to get rid of this special-case vocabulary behavior. |
It was definitely on purpose. There was a concern about backward compatibility for implementations that supported validating For reference, here are the PRs that updated that section. There was a lot of discussion, especially in the closed ones. json-schema-org/json-schema-spec#1023 |
Rereading the relevant issues and PRs, it seems we decided this exactly how I remembered, but it was written up differently and we just went with it instead of going back to discussions. json-schema-org/json-schema-spec#1027 (comment) I'm not mad at how it ended up, just surprised. I'll have to update the release notes, because I wrote that the configuration option was removed. |
Yikes. I'll have to go read. |
@jdesrosiers I'm not sure what you mean. How was it written up differently to what we decided? The comment you linked to has follow-up conversation that we should leave it as is for historical reasons. |
@gregsdennis I'm sorry I brought it up. It's really not important. I'm fine with how it is and I'm not even arguing for a change. I could quote a bunch of posts from the issue and PR to show what I see, but I feel like that would just fuel conflict for no benefit. The way it reads to me is that Henry gave historical context for why there was a config option in the first place, but left the decision up to us. No one favored supporting partial Ultimately, the only problem here is with me not paying enough attention and not knowing what was actually in the spec. That's been corrected and I don't wish to burn any more of anyone's time on this. |
This table (from a comment in the 1027 PR) sums up the behavior that should be described in the text.
There are four degrees of freedom here:
|
The draft2019-09 and draft2020-12 directories contain various tests for 'format'. The ones located in format.json document the results of everything (even bad formats) as valid: true. This is because of the movement of format to annotations by default. That's fine. So, these tests should all return valid for these schema versions.
However, the tests in the optional/format directory are setup with
'valid: false'
. As if the results of the tests should be an assertion. But there isn't any data that determines this distinction other than their location. When evaluating the files in optional/format, the test suite should consider format failures as assertions. When evaluating the tests outside of optional/format, it should consider format failures as annotations.Makes it a bit hard to auto generate test implementations given the test suite JSON files.
It would be nice if there was some distinction in the test suite. Perhaps actually including
$vocabulary: { "...format": true }
in theschema
node within the tests. Since this should be the thing that governs the behavior.The text was updated successfully, but these errors were encountered: