Skip to content

Commit a12ded6

Browse files
committed
reflow; add build
1 parent 9ab1781 commit a12ded6

File tree

2 files changed

+113
-42
lines changed

2 files changed

+113
-42
lines changed

jsonschema-validation-output-machines.md

Lines changed: 110 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,40 @@
11
# A Specification for Machine-Readable Output for JSON Schema Validation and Annotation
22

3-
JSON Schema is defined to be platform-independent. As such, to increase compatibility across platforms, implementations SHOULD conform to a standard validation output format. This section describes the minimum requirements that consumers will need to properly interpret validation results.
3+
JSON Schema is defined to be platform-independent. As such, to increase
4+
compatibility across platforms, implementations SHOULD conform to a standard
5+
validation output format. This specification describes the minimum requirements
6+
for machine consumers to properly interpret validation results.
7+
8+
## Table of Contents
49

510
## Schema Identifiers
611

7-
The output defined in this specification requires that the evaluation root be defined with an absolute IRI, i.e. using the `$id` keyword. In the event an absolute IRI has not been defined, the implementation MUST generate one.
12+
The output defined in this specification requires that the evaluation root be
13+
defined with an absolute IRI, i.e. using the `$id` keyword. In the event an
14+
absolute IRI has not been defined, the implementation MUST generate one.
815

9-
There are no requirements on the form of IRI itself, except that it MUST be absolute.
16+
There are no requirements on the form of IRI itself, except that it MUST be
17+
absolute.
1018

1119
## Textual Format and Encoding
1220

13-
JSON Schema output is defined using the JSON Schema data instance model as described in [JSON Schema](#json-schema) "Instance Data Model". Implementations MAY deviate from this in their internal modelling, as supported by their specific languages and platforms, however it is RECOMMENDED that the output be convertible to the JSON format defined herein via serialization or other means.
21+
JSON Schema output is defined using the JSON Schema data instance model as
22+
described in [JSON Schema](#json-schema) "Instance Data Model". Implementations
23+
MAY deviate from this in their internal modelling, as supported by their
24+
specific languages and platforms, however it is RECOMMENDED that the output be
25+
convertible to the JSON format defined herein via serialization or other means.
1426

1527
## Minimum Information
1628

17-
Beyond the simplistic "flag" output, additional information is useful to aid in debugging evaluation of an instance by a schema.
29+
Beyond the simplistic "flag" output, additional information is useful to aid in
30+
debugging evaluation of an instance by a schema.
1831

19-
The output of a subschema validation is considered an "output unit." The contents of each output unit is specified by this section.
32+
The output of a subschema validation is considered an "output unit." The
33+
contents of each output unit is specified by this section.
2034

21-
Each output unit MUST contain the [validation result](#validation-result) for the associated subschema as well as the following information defined by [JSON Schema](#json-schema) "Output Formatting":
35+
Each output unit MUST contain the [validation result](#validation-result) for
36+
the associated subschema as well as the following information defined by
37+
[JSON Schema](#json-schema) "Output Formatting":
2238

2339
- Evaluation Path
2440
- Schema Location
@@ -36,19 +52,28 @@ Implementations MAY elect to provide additional information.
3652

3753
### Validation Result {#validation-result}
3854

39-
The validation result is a boolean that indicates whether the local instance passed validation by the local subschema.
55+
The validation result is a boolean that indicates whether the local instance
56+
passed validation by the local subschema.
4057

4158
The JSON key for these additional results is `valid`.
4259

4360
### Results from Subschemas
4461

45-
Evaluation results generated by applying a subschema to the instance or a child of the instance. Keywords which have multiple subschemas (e.g. `anyOf`) will generally generate an output unit for each subschema. In order to accommodate potentially multiple results, the value of this property MUST be an array of output units, even if only a single output unit is produced.
62+
Evaluation results generated by applying a subschema to the instance or a child
63+
of the instance. Keywords which have multiple subschemas (e.g. `anyOf`) will
64+
generally generate an output unit for each subschema. In order to accommodate
65+
potentially multiple results, the value of this property MUST be an array of
66+
output units, even if only a single output unit is produced.
4667

47-
For "list", this property will appear only at the root output unit and will hold all output units in a flat list.
68+
For "list", this property will appear only at the root output unit and will hold
69+
all output units in a flat list.
4870

49-
For "hierarchical", this property will contain results in a tree structure where each output unit may itself have further nested results.
71+
For "hierarchical", this property will contain results in a tree structure where
72+
each output unit may itself have further nested results.
5073

51-
The sequence of output units within this list is not specified and MAY be determined by the implementation. Sets of output units are considered equivalent if they contain the same units, in any order.
74+
The sequence of output units within this list is not specified and MAY be
75+
determined by the implementation. Sets of output units are considered equivalent
76+
if they contain the same units, in any order.
5277

5378
<!-- Not sure if it's necessary to mention equivalence. -->
5479

@@ -58,16 +83,19 @@ The JSON key for these additional results is `details`.
5883

5984
This specification defines three output formats.
6085

61-
- **Flag** - A boolean which simply indicates the overall validation result with no further details.
86+
- **Flag** - A boolean which simply indicates the overall validation result with
87+
no further details.
6288
- **List** - Provides validation information in a flat list structure.
63-
- **Hierarchical** - Provides validation information in a hierarchical structure that follows the evaluation paths generated while processing the schema.
89+
- **Hierarchical** - Provides validation information in a hierarchical structure
90+
that follows the evaluation paths generated while processing the schema.
6491

65-
An implementation MUST provide the "flag" format and SHOULD provide at least one of the "list" or "hierarchical" formats. Implementations SHOULD specify in their documentation which formats they support.
92+
An implementation MUST provide the "flag" format and SHOULD provide at least one
93+
of the "list" or "hierarchical" formats. Implementations SHOULD specify in their
94+
documentation which formats they support.
6695

6796
For these examples, the following schema and instances will be used.
6897

69-
```jsonc
70-
// schema
98+
```jsonschema "schema"
7199
{
72100
"$schema": "https://json-schema.org/draft/next/schema",
73101
"$id": "https://json-schema.org/schemas/example",
@@ -108,23 +136,25 @@ For these examples, the following schema and instances will be used.
108136
}
109137
}
110138
}
139+
```
111140

112-
// failing instance
141+
```json "failing instance"
113142
{
114143
"foo": {"foo-prop": "not 1", "other-prop": false},
115144
"bar": {"bar-prop": 2}
116145
}
146+
```
117147

118-
// passing instance
148+
```json "passing instance"
119149
{
120150
"foo": {
121151
"foo-prop": 1,
122152
"unspecified-prop": true
123153
},
124154
"bar": {"bar-prop": 20}
125155
}
126-
127156
```
157+
128158
The failing instance will produce the following errors:
129159

130160
- The instance value at `/foo`
@@ -191,23 +221,35 @@ The passing instance will produce the following annotations:
191221

192222
### Flag
193223

194-
In the simplest case, merely the boolean result for the `valid` valid property needs to be fulfilled. For this format, all other information is explicitly omitted.
224+
In the simplest case, merely the boolean result for the `valid` valid property
225+
needs to be fulfilled. For this format, all other information is explicitly
226+
omitted.
195227

196228
```json
197229
{
198230
"valid": false
199231
}
200232
```
201233

202-
Because no errors or annotations are returned with this format, it is RECOMMENDED that implementations use short-circuiting logic to return failure or success as soon as the outcome can be determined. For example, if an `anyOf` keyword contains five subschemas, and the second one passes, there is no need to check the other three. The logic can simply return with success.
234+
Because no errors or annotations are returned with this format, it is
235+
RECOMMENDED that implementations use short-circuiting logic to return failure or
236+
success as soon as the outcome can be determined. For example, if an `anyOf`
237+
keyword contains five subschemas, and the second one passes, there is no need to
238+
check the other three. The logic can simply return with success.
203239

204240
### List
205241

206-
The "list" structure is a flat list of output units contained within a root output unit.
242+
The "list" structure is a flat list of output units contained within a root
243+
output unit.
207244

208-
The root output unit contains `valid` for the overall result and `details` for the list of specific results. All other information is explicitly omitted from the root output unit. If the root schema produces errors or annotations, then the output node for the root MUST be present within the root output unit's `details` list with those errors or annotations.
245+
The root output unit contains `valid` for the overall result and `details` for
246+
the list of specific results. All other information is explicitly omitted from
247+
the root output unit. If the root schema produces errors or annotations, then
248+
the output node for the root MUST be present within the root output unit's
249+
`details` list with those errors or annotations.
209250

210-
Output units which do not contain errors or annotations SHOULD be excluded from this format, however implementations MAY choose to include them for
251+
Output units which do not contain errors or annotations SHOULD be excluded from
252+
this format, however implementations MAY choose to include them for
211253
completeness.
212254

213255
```jsonc
@@ -313,7 +355,10 @@ completeness.
313355

314356
### Hierarchical
315357

316-
The "Hierarchical" structure is a tree structure that follows the evaluation path during the validation process. Typically, it will resemble the schema as if all referenced schemas were inlined in place of their associated by-reference keywords.
358+
The "Hierarchical" structure is a tree structure that follows the evaluation
359+
path during the validation process. Typically, it will resemble the schema as if
360+
all referenced schemas were inlined in place of their associated by-reference
361+
keywords.
317362

318363
All output units are included in this format.
319364

@@ -506,44 +551,69 @@ The location properties of the root output unit MAY be omitted.
506551

507552
## Output validation schemas
508553

509-
For convenience, JSON Schema has been provided to validate output generated by implementations. Its IRI is: https://json-schema.org/draft/next/output/schema
554+
For convenience, JSON Schema has been provided to validate output generated by
555+
implementations. Its IRI is: <https://json-schema.org/draft/next/output/schema>
510556

511557
## Filtering
512558

513-
For various reasons, including human readability and performance during evaluation, a user may desire to omit certain details from the output. To address this, implementations MAY provide filtering output information.
559+
For various reasons, including human readability and performance during
560+
evaluation, a user may desire to omit certain details from the output. To
561+
address this, implementations MAY provide filtering output information.
514562

515-
This section defines several RECOMMENDED approaches to filtering, however implementations MAY choose to provide these features in a way that suits them and their users best.
563+
This section defines several RECOMMENDED approaches to filtering, however
564+
implementations MAY choose to provide these features in a way that suits them
565+
and their users best.
516566

517-
For those implementations which support filtering behaviors, the behaviors MUST be configurable and disabled by default.
567+
For those implementations which support filtering behaviors, the behaviors MUST
568+
be configurable and disabled by default.
518569

519570
### Annotation Filtering
520571

521-
Collecting and storing annotations can require increasing amounts of system resources as evaluation proceeds. The strain on systems can be reduced by only collecting those annotations which users care about.
572+
Collecting and storing annotations can require increasing amounts of system
573+
resources as evaluation proceeds. The strain on systems can be reduced by only
574+
collecting those annotations which users care about.
522575

523-
For annotation filtering, implementations SHOULD provide a mechanism which allows users to configure either the set annotations they would like to keep or the set they would like to ignore.
576+
For annotation filtering, implementations SHOULD provide a mechanism which
577+
allows users to configure either the set annotations they would like to keep or
578+
the set they would like to ignore.
524579

525-
For a "keep" list, an implementation MUST include in the output only those annotations which are configured.
580+
For a "keep" list, an implementation MUST include in the output only those
581+
annotations which are configured.
526582

527-
For an "ignore" list, an implementation MUST NOT include in the output those annotations which are configured.
583+
For an "ignore" list, an implementation MUST NOT include in the output those
584+
annotations which are configured.
528585

529586
#### Annotations Required for Evaluation
530587

531-
Some implementations may be annotation-driven. That is, the evaluation of some keywords depends on the annotation results of other keywords. For example, which properties are seen by `additionalProperties` can be determined by looking at the annotation results of `properties` and `patternProperties`.
588+
Some implementations may be annotation-driven. That is, the evaluation of some
589+
keywords depends on the annotation results of other keywords. For example, which
590+
properties are seen by `additionalProperties` can be determined by looking at
591+
the annotation results of `properties` and `patternProperties`.
532592

533-
For these implementations, the annotation results of these dependent keywords must still be collected for proper evaluation. However, these annotations MUST NOT be included in the output unless they are configured accordingly.
593+
For these implementations, the annotation results of these dependent keywords
594+
must still be collected for proper evaluation. However, these annotations MUST
595+
NOT be included in the output unless they are configured accordingly.
534596

535597
### Output Unit Pruning
536598

537-
In many cases, the output structures defined herein produce output units for more than is necessary to identify evaluation issues. Implementations SHOULD provide a mechanism which removes unimportant output units from the final structure in order to highlight those units which impact the final result.
599+
In many cases, the output structures defined herein produce output units for
600+
more than is necessary to identify evaluation issues. Implementations SHOULD
601+
provide a mechanism which removes unimportant output units from the final
602+
structure in order to highlight those units which impact the final result.
538603

539604
Reasons to omit output units may include, but are not limited to:
540605

541-
- Child output units whose validation result does not impact the validation result of the parent. For example, a subschema of an `anyOf` which has a false validation result when there exists a sibling subschema with a true validation result.
542-
- Child output units which have a true validation result but contain no annotations.
606+
- Child output units whose validation result does not impact the validation
607+
result of the parent. For example, a subschema of an `anyOf` which has a false
608+
validation result when there exists a sibling subschema with a true validation
609+
result.
610+
- Child output units which have a true validation result but contain no
611+
annotations.
543612

544613
Output units which include annotations MUST NOT be pruned.
545614

546-
Implementations which provide this behavior SHOULD provide configuration mechanisms appropriate for their users' needs.
615+
Implementations which provide this behavior SHOULD provide configuration
616+
mechanisms appropriate for their users' needs.
547617

548618
## References
549619

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@
66
"main": "index.js",
77
"scripts": {
88
"lint": "eslint build/",
9-
"build": "npm run build-core && npm run build-validation",
9+
"build": "npm run build-core && npm run build-validation && npm run build-output",
1010
"build-core": "node build/build.js < jsonschema-core.md > jsonschema-core.html",
11-
"build-validation": "node build/build.js < jsonschema-validation.md > jsonschema-validation.html"
11+
"build-validation": "node build/build.js < jsonschema-validation.md > jsonschema-validation.html",
12+
"build-output": "node build/build.js < jsonschema-validation-output-machines.md > jsonschema-validation-output-machines.html"
1213
},
1314
"license": "MIT",
1415
"dependencies": {

0 commit comments

Comments
 (0)