Skip to content

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

Merged
merged 1 commit into from
Jun 30, 2022

Conversation

Julian
Copy link
Member

@Julian Julian commented Jun 29, 2022

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 a "dead property" (id) which we
added in prep for adding IDs to test cases but can revisit if/when we
get to that.

"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)."
Copy link
Member

@gregsdennis gregsdennis Jun 30, 2022

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)

Copy link
Member Author

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.

Copy link
Member

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.
@Julian Julian force-pushed the update-test-schema branch from 43ca443 to 2b536c0 Compare June 30, 2022 21:06
@Julian Julian requested a review from gregsdennis June 30, 2022 21:06
@Julian
Copy link
Member Author

Julian commented Jun 30, 2022

Thanks again for the review!

@Julian Julian merged commit 1047a1a into main Jun 30, 2022
@Julian Julian deleted the update-test-schema branch June 30, 2022 21:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants