Skip to content

Commit 47753d9

Browse files
authored
Merge pull request #1329 from json-schema-org/gregsdennis-annotation-inclusion-requirements
add droppedAnnotations
2 parents 7cf2230 + c28c256 commit 47753d9

File tree

2 files changed

+61
-6
lines changed

2 files changed

+61
-6
lines changed

jsonschema-core.xml

+49-5
Original file line numberDiff line numberDiff line change
@@ -2929,11 +2929,14 @@ https://example.com/schemas/common#/$defs/allOf/1
29292929

29302930
<section title="Annotations">
29312931
<t>
2932-
Any annotations produced by the validation. This property MUST NOT
2933-
be included if the validation was unsuccessful. The value
2934-
for this property MUST be an object where the keys are the names of
2935-
keywords and the values are the annotations produced by the
2936-
associated keyword.
2932+
Any annotations produced by the evaluation. This property MUST NOT
2933+
be included if the validation result of the containing subschema was
2934+
unsuccessful.
2935+
</t>
2936+
<t>
2937+
The value for this property MUST be an object where the
2938+
keys are the names of keywords and the values are the annotations
2939+
produced by the associated keyword.
29372940
</t>
29382941
<t>
29392942
Each keyword defines its own annotation data type (e.g. "properties"
@@ -2944,6 +2947,33 @@ https://example.com/schemas/common#/$defs/allOf/1
29442947
</t>
29452948
</section>
29462949

2950+
<section title="Dropped Annotations">
2951+
<t>
2952+
Any annotations produced and subsequently dropped by the evaluation
2953+
due to an unsuccessful validation result of the containing subschema.
2954+
This property MAY be included if the validation result of the containing
2955+
subschema was unsuccessful. It MUST NOT be included if the local
2956+
validation result of the containing subschema was successful.
2957+
</t>
2958+
<t>
2959+
Implementations that wish to provide these annotations MUST NOT provide
2960+
them as their default behavior. These annotations MUST only be included
2961+
by explicitly configuring the implementation to do so.
2962+
</t>
2963+
<t>
2964+
The value for this property MUST be an object where the
2965+
keys are the names of keywords and the values are the annotations
2966+
produced by the associated keyword.
2967+
</t>
2968+
<t>
2969+
Each keyword defines its own annotation data type (e.g. "properties"
2970+
produces a list of keywords, whereas "title" produces a string).
2971+
</t>
2972+
<t>
2973+
The JSON key for this information is "droppedAnnotations".
2974+
</t>
2975+
</section>
2976+
29472977
<section title="Nested Results">
29482978
<t>
29492979
Nested results are generated from keywords which create a new dynamic
@@ -3337,6 +3367,10 @@ https://example.com/schemas/common#/$defs/allOf/1
33373367
"evaluationPath": "/properties/foo/allOf/1",
33383368
"schemaLocation": "https://json-schema.org/schemas/example#/properties/foo/allOf/1",
33393369
"instanceLocation": "/foo",
3370+
"droppedAnnotations": {
3371+
"properties": [ "foo-prop" ],
3372+
"title": "foo-title"
3373+
},
33403374
"nested": [
33413375
{
33423376
"valid": false,
@@ -3345,6 +3379,9 @@ https://example.com/schemas/common#/$defs/allOf/1
33453379
"instanceLocation": "/foo/foo-prop",
33463380
"errors": {
33473381
"const": "Expected \"1\""
3382+
},
3383+
"droppedAnnotations": {
3384+
"title": "foo-prop-title"
33483385
}
33493386
},
33503387
{
@@ -3368,6 +3405,10 @@ https://example.com/schemas/common#/$defs/allOf/1
33683405
"evaluationPath": "/properties/bar/$ref",
33693406
"schemaLocation": "https://json-schema.org/schemas/example#/$defs/bar",
33703407
"instanceLocation": "/bar",
3408+
"droppedAnnotations": {
3409+
"properties": [ "bar-prop" ],
3410+
"title": "bar-title"
3411+
},
33713412
"nested": [
33723413
{
33733414
"valid": false,
@@ -3376,6 +3417,9 @@ https://example.com/schemas/common#/$defs/allOf/1
33763417
"instanceLocation": "/bar/bar-prop",
33773418
"errors": {
33783419
"minimum": "2 is less than or equal to 10"
3420+
},
3421+
"droppedAnnotations": {
3422+
"title": "bar-prop-title"
33793423
}
33803424
}
33813425
]

output/schema.json

+12-1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@
3131
"type": "object",
3232
"additionalProperties": true
3333
},
34+
"droppedAnnotations": {
35+
"type": "object",
36+
"additionalProperties": true
37+
},
3438
"errors": {
3539
"type": "object",
3640
"additionalProperties": { "type": "string" }
@@ -40,7 +44,14 @@
4044
"allOf": [
4145
{
4246
"if": {
43-
"required": [ "errors" ]
47+
"anyOf": [
48+
{
49+
"required": [ "errors" ]
50+
},
51+
{
52+
"required": [ "droppedAnnotations" ]
53+
}
54+
]
4455
},
4556
"then": {
4657
"properties": {

0 commit comments

Comments
 (0)