Skip to content
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

Removed strict $schema: const, so that https also gets transformed #187

Merged
merged 10 commits into from
Apr 1, 2024
3 changes: 2 additions & 1 deletion rules/jsonschema-2019-09-to-2020-12.json
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should probably add a few tests exercising these new rules if we want to get them in

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright, my auto-formatter does this thing in VS Code. I can add the tests.
But these tests are validating syntax, but meta schema validation. So, should that be included under standard test-suite?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I mean just upgrade tests that confirm that if you pass the HTTPS URLs they get upgraded too, etc. No actual meta-schema validation needs to take place

Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"required": [ "$schema" ],
"properties": {
"$schema": {
"const": "https://json-schema.org/draft/2019-09/schema"
"type": "string",
"pattern": "^http[s]?://json-schema.org/draft/2019-09/schema[#]?$"
}
}
},
Expand Down
3 changes: 2 additions & 1 deletion rules/jsonschema-draft3-to-draft4.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"required": [ "$schema" ],
"properties": {
"$schema": {
"const": "http://json-schema.org/draft-03/schema#"
"type": "string",
"pattern": "^http[s]?://json-schema.org/draft-03/schema[#]?$"
}
}
},
Expand Down
3 changes: 2 additions & 1 deletion rules/jsonschema-draft4-to-draft6.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"required": [ "$schema" ],
"properties": {
"$schema": {
"const": "http://json-schema.org/draft-04/schema#"
"type": "string",
"pattern": "^http[s]?://json-schema.org/draft-04/schema[#]?$"
}
}
},
Expand Down
3 changes: 2 additions & 1 deletion rules/jsonschema-draft6-to-draft7.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"required": [ "$schema" ],
"properties": {
"$schema": {
"const": "http://json-schema.org/draft-06/schema#"
"type": "string",
"pattern": "^http[s]?://json-schema.org/draft-06/schema[#]?$"
}
}
},
Expand Down
3 changes: 2 additions & 1 deletion rules/jsonschema-draft7-to-2019-09.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"required": [ "$schema" ],
"properties": {
"$schema": {
"const": "http://json-schema.org/draft-07/schema#"
"type": "string",
"pattern": "^http[s]?://json-schema.org/draft-07/schema[#]?$"
}
}
},
Expand Down
22 changes: 22 additions & 0 deletions test/rules/jsonschema-2019-09-to-2020-12.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,28 @@
"type": "object"
}
},
{
"name": "2019-09 official $schema to 2020-12 with http scheme",
"schema": {
"$schema": "http://json-schema.org/draft/2019-09/schema",
"type": "object"
},
"expected": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object"
}
},
{
"name": "2019-09 official $schema to 2020-12 with an empty fragment",
"schema": {
"$schema": "https://json-schema.org/draft/2019-09/schema#",
"type": "object"
},
"expected": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object"
}
},
{
"name": "items array to prefixItems",
"schema": {
Expand Down
18 changes: 18 additions & 0 deletions test/rules/jsonschema-draft4-to-2019-09.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,24 @@
"$schema": "https://json-schema.org/draft/2019-09/schema"
}
},
{
"name": "draft4 $schema with https scheme",
"schema": {
"$schema": "https://json-schema.org/draft-04/schema#"
},
"expected": {
"$schema": "https://json-schema.org/draft/2019-09/schema"
}
},
{
"name": "draft4 $schema without an empty fragment",
"schema": {
"$schema": "http://json-schema.org/draft-04/schema"
},
"expected": {
"$schema": "https://json-schema.org/draft/2019-09/schema"
}
},
{
"name": "draft4 id to $id",
"schema": {
Expand Down
18 changes: 18 additions & 0 deletions test/rules/jsonschema-draft4-to-2020-12.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,24 @@
"$schema": "https://json-schema.org/draft/2020-12/schema"
}
},
{
"name": "draft4 $schema with https scheme",
"schema": {
"$schema": "http://json-schema.org/draft-04/schema#"
},
"expected": {
"$schema": "https://json-schema.org/draft/2020-12/schema"
}
},
{
"name": "draft4 $schema without an empty fragment",
"schema": {
"$schema": "http://json-schema.org/draft-04/schema"
},
"expected": {
"$schema": "https://json-schema.org/draft/2020-12/schema"
}
},
{
"name": "draft4 id to $id",
"schema": {
Expand Down
18 changes: 18 additions & 0 deletions test/rules/jsonschema-draft4-to-draft6.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,24 @@
"$schema": "http://json-schema.org/draft-06/schema#"
}
},
{
"name": "draft4 $schema with https scheme",
"schema": {
"$schema": "http://json-schema.org/draft-04/schema#"
},
"expected": {
"$schema": "http://json-schema.org/draft-06/schema#"
}
},
{
"name": "draft4 $schema without an empty fragment",
"schema": {
"$schema": "http://json-schema.org/draft-04/schema"
},
"expected": {
"$schema": "http://json-schema.org/draft-06/schema#"
}
},
{
"name": "draft4 id to $id",
"schema": {
Expand Down
18 changes: 18 additions & 0 deletions test/rules/jsonschema-draft4-to-draft7.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,24 @@
"$schema": "http://json-schema.org/draft-07/schema#"
}
},
{
"name": "draft4 $schema with https scheme",
"schema": {
"$schema": "http://json-schema.org/draft-04/schema#"
},
"expected": {
"$schema": "http://json-schema.org/draft-07/schema#"
}
},
{
"name": "draft4 $schema without an empty fragment",
"schema": {
"$schema": "http://json-schema.org/draft-04/schema"
},
"expected": {
"$schema": "http://json-schema.org/draft-07/schema#"
}
},
{
"name": "draft4 id to $id",
"schema": {
Expand Down
18 changes: 18 additions & 0 deletions test/rules/jsonschema-draft6-to-2019-09.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,24 @@
"$schema": "https://json-schema.org/draft/2019-09/schema"
}
},
{
"name": "draft6 $schema witgh https scheme",
"schema": {
"$schema": "https://json-schema.org/draft-06/schema#"
},
"expected": {
"$schema": "https://json-schema.org/draft/2019-09/schema"
}
},
{
"name": "draft6 $schema without an empty fragment",
"schema": {
"$schema": "http://json-schema.org/draft-06/schema"
},
"expected": {
"$schema": "https://json-schema.org/draft/2019-09/schema"
}
},
{
"name": "draft6 $id with # to $anchor",
"schema": {
Expand Down
18 changes: 18 additions & 0 deletions test/rules/jsonschema-draft6-to-2020-12.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,24 @@
"$schema": "https://json-schema.org/draft/2020-12/schema"
}
},
{
"name": "draft6 $schema with https scheme",
"schema": {
"$schema": "https://json-schema.org/draft-06/schema#"
},
"expected": {
"$schema": "https://json-schema.org/draft/2020-12/schema"
}
},
{
"name": "draft6 $schema without an empty fragment",
"schema": {
"$schema": "http://json-schema.org/draft-06/schema"
},
"expected": {
"$schema": "https://json-schema.org/draft/2020-12/schema"
}
},
{
"name": "draft6 $id with # to $anchor",
"schema": {
Expand Down
18 changes: 18 additions & 0 deletions test/rules/jsonschema-draft6-to-draft7.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,24 @@
"$schema": "http://json-schema.org/draft-07/schema#"
}
},
{
"name": "draft6 $schema wituh https scheme",
"schema": {
"$schema": "http://json-schema.org/draft-06/schema#"
},
"expected": {
"$schema": "http://json-schema.org/draft-07/schema#"
}
},
{
"name": "draft6 $schema without an empty fragment",
"schema": {
"$schema": "http://json-schema.org/draft-06/schema"
},
"expected": {
"$schema": "http://json-schema.org/draft-07/schema#"
}
},
{
"name": "true no metaschema",
"schema": {},
Expand Down
18 changes: 18 additions & 0 deletions test/rules/jsonschema-draft7-to-2019-09.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,24 @@
"$schema": "https://json-schema.org/draft/2019-09/schema"
}
},
{
"name": "draft7 $schema with https scheme",
"schema": {
"$schema": "https://json-schema.org/draft-07/schema#"
},
"expected": {
"$schema": "https://json-schema.org/draft/2019-09/schema"
}
},
{
"name": "draft7 $schema without an empty fragment",
"schema": {
"$schema": "http://json-schema.org/draft-07/schema"
},
"expected": {
"$schema": "https://json-schema.org/draft/2019-09/schema"
}
},
{
"name": "draft7 $id with # to $anchor",
"schema": {
Expand Down
18 changes: 18 additions & 0 deletions test/rules/jsonschema-draft7-to-2020-12.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,24 @@
"$schema": "https://json-schema.org/draft/2020-12/schema"
}
},
{
"name": "draft7 $schema with https scheme",
"schema": {
"$schema": "https://json-schema.org/draft-07/schema#"
},
"expected": {
"$schema": "https://json-schema.org/draft/2020-12/schema"
}
},
{
"name": "draft7 $schema without an empty fragment",
"schema": {
"$schema": "http://json-schema.org/draft-07/schema"
},
"expected": {
"$schema": "https://json-schema.org/draft/2020-12/schema"
}
},
{
"name": "draft7 $id with # to $anchor",
"schema": {
Expand Down
Loading