Skip to content

Commit ef78a0e

Browse files
authored
Merge pull request #683 from mwadams/main
Added tests to encoded refs to unknown keywords.
2 parents e99b24c + db36573 commit ef78a0e

File tree

3 files changed

+132
-0
lines changed

3 files changed

+132
-0
lines changed

tests/draft2019-09/optional/refOfUnknownKeyword.json

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,28 @@
2121
}
2222
]
2323
},
24+
{
25+
"description": "reference of a root arbitrary keyword with encoded ref",
26+
"schema": {
27+
"$schema": "https://json-schema.org/draft/2019-09/schema",
28+
"unknown/keyword": {"type": "integer"},
29+
"properties": {
30+
"bar": {"$ref": "#/unknown~1keyword"}
31+
}
32+
},
33+
"tests": [
34+
{
35+
"description": "match",
36+
"data": {"bar": 3},
37+
"valid": true
38+
},
39+
{
40+
"description": "mismatch",
41+
"data": {"bar": true},
42+
"valid": false
43+
}
44+
]
45+
},
2446
{
2547
"description": "reference of an arbitrary keyword of a sub-schema",
2648
"schema": {
@@ -65,5 +87,27 @@
6587
"valid": false
6688
}
6789
]
90+
},
91+
{
92+
"description": "reference of an arbitrary keyword of a sub-schema with encoded ref",
93+
"schema": {
94+
"$schema": "https://json-schema.org/draft/2019-09/schema",
95+
"properties": {
96+
"foo": {"unknown/keyword": {"type": "integer"}},
97+
"bar": {"$ref": "#/properties/foo/unknown~1keyword"}
98+
}
99+
},
100+
"tests": [
101+
{
102+
"description": "match",
103+
"data": {"bar": 3},
104+
"valid": true
105+
},
106+
{
107+
"description": "mismatch",
108+
"data": {"bar": true},
109+
"valid": false
110+
}
111+
]
68112
}
69113
]

tests/draft2020-12/optional/refOfUnknownKeyword.json

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,28 @@
2121
}
2222
]
2323
},
24+
{
25+
"description": "reference of a root arbitrary keyword with encoded ref",
26+
"schema": {
27+
"$schema": "https://json-schema.org/draft/2020-12/schema",
28+
"unknown/keyword": {"type": "integer"},
29+
"properties": {
30+
"bar": {"$ref": "#/unknown~1keyword"}
31+
}
32+
},
33+
"tests": [
34+
{
35+
"description": "match",
36+
"data": {"bar": 3},
37+
"valid": true
38+
},
39+
{
40+
"description": "mismatch",
41+
"data": {"bar": true},
42+
"valid": false
43+
}
44+
]
45+
},
2446
{
2547
"description": "reference of an arbitrary keyword of a sub-schema",
2648
"schema": {
@@ -65,5 +87,27 @@
6587
"valid": false
6688
}
6789
]
90+
},
91+
{
92+
"description": "reference of an arbitrary keyword of a sub-schema with encoded ref",
93+
"schema": {
94+
"$schema": "https://json-schema.org/draft/2020-12/schema",
95+
"properties": {
96+
"foo": {"unknown/keyword": {"type": "integer"}},
97+
"bar": {"$ref": "#/properties/foo/unknown~1keyword"}
98+
}
99+
},
100+
"tests": [
101+
{
102+
"description": "match",
103+
"data": {"bar": 3},
104+
"valid": true
105+
},
106+
{
107+
"description": "mismatch",
108+
"data": {"bar": true},
109+
"valid": false
110+
}
111+
]
68112
}
69113
]

tests/v1/optional/refOfUnknownKeyword.json

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,28 @@
2121
}
2222
]
2323
},
24+
{
25+
"description": "reference of a root arbitrary keyword with encoded ref",
26+
"schema": {
27+
"$schema": "https://json-schema.org/v1",
28+
"unknown/keyword": {"type": "integer"},
29+
"properties": {
30+
"bar": {"$ref": "#/unknown~1keyword"}
31+
}
32+
},
33+
"tests": [
34+
{
35+
"description": "match",
36+
"data": {"bar": 3},
37+
"valid": true
38+
},
39+
{
40+
"description": "mismatch",
41+
"data": {"bar": true},
42+
"valid": false
43+
}
44+
]
45+
},
2446
{
2547
"description": "reference of an arbitrary keyword of a sub-schema",
2648
"schema": {
@@ -65,5 +87,27 @@
6587
"valid": false
6688
}
6789
]
90+
},
91+
{
92+
"description": "reference of an arbitrary keyword of a sub-schema with encoded ref",
93+
"schema": {
94+
"$schema": "https://json-schema.org/v1",
95+
"properties": {
96+
"foo": {"unknown/keyword": {"type": "integer"}},
97+
"bar": {"$ref": "#/properties/foo/unknown~1keyword"}
98+
}
99+
},
100+
"tests": [
101+
{
102+
"description": "match",
103+
"data": {"bar": 3},
104+
"valid": true
105+
},
106+
{
107+
"description": "mismatch",
108+
"data": {"bar": true},
109+
"valid": false
110+
}
111+
]
68112
}
69113
]

0 commit comments

Comments
 (0)