Skip to content

Commit 626b433

Browse files
test that annations are collected inside a "not"
Normally we can skip collecting annotations below a "not" keyword, because if the subschema passes (and produces annotations) the "not" turns that to an invalid result and annotations are discarded, and if the subschema is invalid no annotations are produced. However, annotations must still be collected *inside* the "not" if there is a reason to do so, such as the presence of an "unevaluated" keyword.
1 parent f57d3e0 commit 626b433

File tree

3 files changed

+81
-3
lines changed

3 files changed

+81
-3
lines changed

tests/draft-next/not.json

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,5 +123,31 @@
123123
"valid": true
124124
}
125125
]
126-
}
126+
},
127+
{
128+
"description": "collect annotations inside a 'not', even if collection is disabled",
129+
"schema": {
130+
"$schema": "https://json-schema.org/draft/next/schema",
131+
"not": {
132+
"$comment": "this subschema must still produce annotations internally, even though the 'not' will ultimately discard them",
133+
"anyOf": [
134+
true,
135+
{ "properties": { "foo": true } }
136+
],
137+
"unevaluatedProperties": false
138+
}
139+
},
140+
"tests": [
141+
{
142+
"description": "no properties to evaluate",
143+
"data": {},
144+
"valid": true
145+
},
146+
{
147+
"description": "annotations are still collected inside a 'not'",
148+
"data": { "foo": 1 },
149+
"valid": false
150+
}
151+
]
152+
}
127153
]

tests/draft2019-09/not.json

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,5 +123,31 @@
123123
"valid": true
124124
}
125125
]
126-
}
126+
},
127+
{
128+
"description": "collect annotations inside a 'not', even if collection is disabled",
129+
"schema": {
130+
"$schema": "https://json-schema.org/draft/2019-09/schema",
131+
"not": {
132+
"$comment": "this subschema must still produce annotations internally, even though the 'not' will ultimately discard them",
133+
"anyOf": [
134+
true,
135+
{ "properties": { "foo": true } }
136+
],
137+
"unevaluatedProperties": false
138+
}
139+
},
140+
"tests": [
141+
{
142+
"description": "no properties to evaluate",
143+
"data": {},
144+
"valid": true
145+
},
146+
{
147+
"description": "annotations are still collected inside a 'not'",
148+
"data": { "foo": 1 },
149+
"valid": false
150+
}
151+
]
152+
}
127153
]

tests/draft2020-12/not.json

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,5 +123,31 @@
123123
"valid": true
124124
}
125125
]
126-
}
126+
},
127+
{
128+
"description": "collect annotations inside a 'not', even if collection is disabled",
129+
"schema": {
130+
"$schema": "https://json-schema.org/draft/2020-12/schema",
131+
"not": {
132+
"$comment": "this subschema must still produce annotations internally, even though the 'not' will ultimately discard them",
133+
"anyOf": [
134+
true,
135+
{ "properties": { "foo": true } }
136+
],
137+
"unevaluatedProperties": false
138+
}
139+
},
140+
"tests": [
141+
{
142+
"description": "no properties to evaluate",
143+
"data": {},
144+
"valid": true
145+
},
146+
{
147+
"description": "annotations are still collected inside a 'not'",
148+
"data": { "foo": 1 },
149+
"valid": false
150+
}
151+
]
152+
}
127153
]

0 commit comments

Comments
 (0)