-
-
Notifications
You must be signed in to change notification settings - Fork 215
Update the test schema to Draft 2020, and fix a bug in it. #565
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
Conversation
"type": "string" | ||
}, | ||
"schema": { | ||
"description": "This should be a valid schema. This should be a ref to a meta-schema if schema keywords need testing." | ||
"description": "A valid JSON Schema (one written for the corresponding version directory that the file sits within)." |
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 add an enum property to the test files, we could probably key off of that and enforce a specific metaschema here. (Idea for separate PR)
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 in provide some other mechanism for indicating a metaschema test? We could, but each of these changes is delicate, since someone's existing test runner still may not be expecting that. Obviously we're going to need to do something like breaking our informal backwards compatibility anyhow to resolve the optional/
folder situation, so we could in theory do so for that too, but lemme know if I misunderstood the idea entirely.
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.
No, I mean actually validate the schemas in the test files. If the test file specifies what version schemas its for (because JSON Schema does see the file path) then we can use that to select a metaschema to validate the test schema against.
I was thinking something like the below, but then I realized the test file is an array, and you'd have to specify the version on every test... Might be more headache than it's worth now that I see it.
Leaving for posterity
In the test file
{
"version": "2020-12",
... // the rest of the test file
}
In the above schema:
{
...
"oneOf": [
{
"properties": {
"version": { "const": "2020-12" },
"schema": { "$ref": "<2020-12 metaschema>" }
},
... // more for other versions
]
...
}
`minItems` was placed inside `items` in the root schema, meaning it was not checking that each file contained at least one test case. Now it does, and does so using draft 2020. Also tidied a few descriptions, removed two "dead properties" (id, output) which we added in prep for enriching the suite but haven't yet added concrete examples of. We can re-add when we do add some.
43ca443
to
2b536c0
Compare
Thanks again for the review! |
minItems
was placed insideitems
in the root schema, meaning it wasnot checking that each file contained at least one test case. Now it
does, and does so using draft 2020.
Also tidied a few descriptions, removed a "dead property" (id) which we
added in prep for adding IDs to test cases but can revisit if/when we
get to that.