Skip to content

Commit 46e0670

Browse files
authored
Add rules and test for draft 3 to 4 schema keyword (#26)
1 parent 8405f08 commit 46e0670

File tree

3 files changed

+107
-3
lines changed

3 files changed

+107
-3
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"vocabulary": "core",
3+
"condition": [
4+
{ "operation": "has-key", "path": [], "value": "$schema" },
5+
{ "operation": "match-pattern", "path": [ "$schema" ], "value": "^http[s]?://json-schema.org/draft-03/schema[#]?$" }
6+
],
7+
"transform": [
8+
{ "operation": "replace", "path": [ "$schema" ], "value": "http://json-schema.org/draft-04/schema#" }
9+
]
10+
}
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
[
2+
{
3+
"title": "Simple matching schema",
4+
"from": {
5+
"$schema": "https://json-schema.org/draft-03/schema"
6+
},
7+
"to": {
8+
"$schema": "https://json-schema.org/draft-04/schema"
9+
}
10+
},
11+
{
12+
"name": "$schema with https scheme",
13+
"from": {
14+
"$schema": "http://json-schema.org/draft-03/schema#"
15+
},
16+
"to": {
17+
"$schema": "http://json-schema.org/draft-04/schema#"
18+
}
19+
},
20+
{
21+
"name": "$schema without an empty fragment",
22+
"from": {
23+
"$schema": "http://json-schema.org/draft-03/schema"
24+
},
25+
"to": {
26+
"$schema": "http://json-schema.org/draft-04/schema#"
27+
}
28+
},
29+
{
30+
"title": "Simple non matching schema",
31+
"from": {
32+
"$schema": "https://json-schema.org/draft/2020-12/schema"
33+
},
34+
"to": {
35+
"$schema": "https://json-schema.org/draft/2020-12/schema"
36+
}
37+
},
38+
{
39+
"title": "Nested matching schema",
40+
"from": {
41+
"$schema": "https://json-schema.org/draft-03/schema",
42+
"properties": {
43+
"foo": {
44+
"$schema": "https://json-schema.org/draft-03/schema"
45+
}
46+
}
47+
},
48+
"to": {
49+
"$schema": "https://json-schema.org/draft-04/schema",
50+
"properties": {
51+
"foo": {
52+
"$schema": "https://json-schema.org/draft-04/schema"
53+
}
54+
}
55+
}
56+
},
57+
{
58+
"title": "Nested half matching schema",
59+
"from": {
60+
"$schema": "https://json-schema.org/draft/2020-12/schema",
61+
"properties": {
62+
"foo": {
63+
"$schema": "https://json-schema.org/draft-03/schema"
64+
}
65+
}
66+
},
67+
"to": {
68+
"$schema": "https://json-schema.org/draft/2020-12/schema",
69+
"properties": {
70+
"foo": {
71+
"$schema": "https://json-schema.org/draft-04/schema"
72+
}
73+
}
74+
}
75+
},
76+
{
77+
"title": "$schema inside unknown keyword",
78+
"from": {
79+
"$schema": "https://json-schema.org/draft-03/schema",
80+
"foo": {
81+
"$schema": "https://json-schema.org/draft-03/schema"
82+
}
83+
},
84+
"to": {
85+
"$schema": "https://json-schema.org/draft-04/schema",
86+
"foo": {
87+
"$schema": "https://json-schema.org/draft-03/schema"
88+
}
89+
}
90+
}
91+
]

test/from-draft7/to-2019-09/schema.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,16 @@
2020
{
2121
"title": "Nested matching schema",
2222
"from": {
23-
"$schema": "http://json-schema.org/draft-07/schema#",
24-
"definitions": {
23+
"$schema": "https://json-schema.org/draft-07/schema",
24+
"properties": {
2525
"foo": {
2626
"$schema": "http://json-schema.org/draft-07/schema#"
2727
}
2828
}
2929
},
3030
"to": {
3131
"$schema": "https://json-schema.org/draft/2019-09/schema",
32-
"definitions": {
32+
"properties": {
3333
"foo": {
3434
"$schema": "https://json-schema.org/draft/2019-09/schema"
3535
}
@@ -41,6 +41,7 @@
4141
"from": {
4242
"$schema": "https://json-schema.org/draft/2019-09/schema",
4343
"definitions": {
44+
4445
"foo": {
4546
"$schema": "http://json-schema.org/draft-07/schema#"
4647
}
@@ -71,3 +72,5 @@
7172
}
7273
}
7374
]
75+
76+

0 commit comments

Comments
 (0)