2702
2702
Implementations MAY elect to provide additional information.
2703
2703
</t >
2704
2704
2705
- <section title =" Keyword Relative Location" >
2705
+ <section title =" Subschema Relative Location" >
2706
2706
<t >
2707
- The relative location of the validating keyword that follows the path
2707
+ The relative location of the validating subschema that follows the path
2708
2708
traversed through the schema. The value MUST be expressed as a JSON
2709
2709
Pointer, and it MUST include any by-reference applicators such as
2710
2710
"$ref" or "$dynamicRef".
2722
2722
</artwork >
2723
2723
</figure >
2724
2724
<t >
2725
- Note that this pointer may not be resolvable by the normal JSON Pointer process
2726
- due to the inclusion of these by-reference applicator keywords.
2725
+ Note that this pointer may not be resolvable by the normal JSON Pointer process
2726
+ due to the inclusion of these by-reference applicator keywords.
2727
2727
</t >
2728
2728
<t >
2729
2729
The JSON key for this information is "evaluationPath".
2730
2730
</t >
2731
2731
</section >
2732
2732
2733
- <section title =" Keyword Absolute Location" >
2733
+ <section title =" Subschema Absolute Location" >
2734
2734
<t >
2735
- The absolute, dereferenced location of the validating keyword . The value MUST
2735
+ The absolute, dereferenced location of the validating subschema . The value MUST
2736
2736
be expressed as a full IRI using the canonical IRI of the relevant
2737
2737
schema object, and it MUST NOT include by-reference applicators
2738
- such as "$ref" or "$dynamicRef" as non-terminal path components.
2739
- It MAY end in such keywords if the error or annotation is for that
2740
- keyword, such as an unresolvable reference.
2738
+ such as "$ref" or "$dynamicRef" as path components.
2741
2739
<cref >
2742
2740
Note that "absolute" here is in the sense of "absolute filesystem path"
2743
2741
(meaning the complete location) rather than the "absolute-IRI"
@@ -2753,10 +2751,6 @@ https://example.com/schemas/common#/$defs/count/minimum
2753
2751
]]>
2754
2752
</artwork >
2755
2753
</figure >
2756
- <t >
2757
- This information MAY be omitted only if either the dynamic scope did not pass
2758
- over a reference or if the schema does not declare an absolute IRI as its "$id".
2759
- </t >
2760
2754
<t >
2761
2755
The JSON key for this information is "schemaLocation".
2762
2756
</t >
@@ -2772,32 +2766,48 @@ https://example.com/schemas/common#/$defs/count/minimum
2772
2766
</t >
2773
2767
</section >
2774
2768
2775
- <section title =" Error or Annotation " >
2769
+ <section title =" Errors " >
2776
2770
<t >
2777
- The error or annotation that is produced by the validation.
2771
+ Any errors produced by the validation. This property MUST NOT
2772
+ be included if the validation was successful. The value
2773
+ for this property is an object where the keys are the names of
2774
+ keywords and the values are the error message produced by the
2775
+ associated keyword.
2778
2776
</t >
2779
2777
<t >
2780
- For errors, the specific wording for the message is not defined by this
2778
+ The specific wording for the message is not defined by this
2781
2779
specification. Implementations will need to provide this.
2782
2780
</t >
2783
2781
<t >
2784
- For annotations, each keyword that produces an annotation specifies its
2785
- format. By default, it is the keyword's value.
2782
+ The JSON key for this information is "errors".
2783
+ </t >
2784
+ </section >
2785
+
2786
+ <section title =" Annotations" >
2787
+ <t >
2788
+ Any annotations produced by the validation. This property MUST NOT
2789
+ be included if the validation was unsuccessful. The value
2790
+ for this property is an object where the keys are the names of
2791
+ keywords and the values are the annotations produced by the
2792
+ associated keyword.
2793
+ </t >
2794
+ <t >
2795
+ Each keyword defines its own annotation data type (e.g. "properties"
2796
+ produces a list of keywords, whereas "$title" produces a string).
2786
2797
</t >
2787
2798
<t >
2788
- The JSON key for failed validations is "error"; for successful validations
2789
- it is "annotation".
2799
+ The JSON key for this information is "annotations".
2790
2800
</t >
2791
2801
</section >
2792
2802
2793
2803
<section title =" Nested Results" >
2794
2804
<t >
2795
2805
For "basic", this property will appear only at the root node and will hold
2796
- all errors or annotations in a list.
2806
+ all results in a flat list.
2797
2807
</t >
2798
2808
<t >
2799
- For "detailed" and "verbose", this property will hold nested errors
2800
- and annotations in a tree structure, mimicking that of the schema.
2809
+ For "detailed" and "verbose", this property will hold nested results
2810
+ in a tree structure, mimicking that of the schema.
2801
2811
</t >
2802
2812
<t >
2803
2813
The JSON key for nested results is "nested".
@@ -2817,67 +2827,145 @@ https://example.com/schemas/common#/$defs/count/minimum
2817
2827
failure
2818
2828
</t >
2819
2829
<t >
2820
- "nested" - the collection of errors or annotations produced by a keyword
2830
+ "nested" - the collection of errors or annotations produced by a subschema
2821
2831
</t >
2822
2832
</list >
2823
- For these examples, the following schema and instance will be used.
2833
+ For these examples, the following schema and instances will be used.
2824
2834
</t >
2825
2835
<figure >
2826
2836
<artwork >
2827
2837
<![CDATA[
2838
+ // schema
2828
2839
{
2829
- "$id": "https://example.com/polygon",
2830
2840
"$schema": "https://json-schema.org/draft/next/schema",
2831
- "$defs": {
2832
- "point": {
2841
+ "$id": "https://json-schema.org/schemas/example",
2842
+ "type": "object",
2843
+ "title": "root",
2844
+ "properties": {
2845
+ "foo": {
2833
2846
"type": "object",
2847
+ "title": "foo-title",
2834
2848
"properties": {
2835
- "x": { "type": "number" },
2836
- "y": { "type": "number" }
2837
- },
2838
- "additionalProperties": false,
2839
- "required": [ "x", "y" ]
2849
+ "foo-prop": {
2850
+ "const": 1,
2851
+ "title": "foo-prop-title"
2852
+ }
2853
+ }
2854
+ },
2855
+ "bar": {
2856
+ "$ref": "#/$defs/bar"
2840
2857
}
2841
2858
},
2842
- "type": "array",
2843
- "items": { "$ref": "#/$defs/point" },
2844
- "minItems": 3
2859
+ "$defs": {
2860
+ "bar": {
2861
+ "type": "object",
2862
+ "title": "bar-title",
2863
+ "properties": {
2864
+ "bar-prop": {
2865
+ "type": "integer",
2866
+ "minimum": 10,
2867
+ "title": "bar-prop-title"
2868
+ }
2869
+ }
2870
+ }
2871
+ }
2845
2872
}
2846
2873
2847
- [
2848
- {
2849
- "x": 2.5,
2850
- "y": 1.3
2851
- },
2852
- {
2853
- "x": 1,
2854
- "z": 6.7
2855
- }
2856
- ]
2874
+ // failing instance
2875
+ {
2876
+ "foo": {"foo-prop": "not 1"},
2877
+ "bar": {"bar-prop": 2}
2878
+ }
2879
+
2880
+ // passing instance
2881
+ {
2882
+ "foo": {"foo-prop": 1},
2883
+ "bar": {"bar-prop": 20}
2884
+ }
2857
2885
]]>
2858
2886
</artwork >
2859
2887
</figure >
2860
2888
<t >
2861
- This instance will fail validation and produce errors, but it's trivial to deduce
2862
- examples for passing schemas that produce annotations.
2889
+ The failing instance will produce the following errors:
2890
+ <list >
2891
+ <t >
2892
+ The value at "/foo/foo-prop"
2893
+ validated at "/properties/foo/properties/foo-prop"
2894
+ by following the path "/properties/foo/properties/foo-prop"
2895
+ by the "const" keyword
2896
+ is not the constant value 1.
2897
+ </t >
2898
+ <t >
2899
+ The value at "/bar/bar-prop"
2900
+ validated at "/$defs/bar/properties/bar-prop"
2901
+ by following the path "/properties/bar/$ref/properties/bar-prop"
2902
+ by the "type" keyword
2903
+ is not a number.
2904
+ </t >
2905
+ </list >
2906
+ <cref >
2907
+ "minimum" doesn't produce an error because it only operates on
2908
+ instances that are numbers.
2909
+ </cref >
2910
+ <cref >
2911
+ Note that the error message wording as depicted in the examples below is not a
2912
+ requirement of this specification. Implementations SHOULD craft error messages
2913
+ tailored for their audience or provide a templating mechanism that allows their
2914
+ users to craft their own messages.
2915
+ </cref >
2863
2916
</t >
2864
2917
<t >
2865
- Specifically, the errors it will produce are :
2918
+ The passing instance will produce the following annotations :
2866
2919
<list >
2867
2920
<t >
2868
- The second object is missing a "y" property.
2921
+ The keyword "title"
2922
+ validated at ""
2923
+ by following the path ""
2924
+ will produce "root".
2925
+ </t >
2926
+ <t >
2927
+ The keyword "properties"
2928
+ validated at ""
2929
+ by following the path ""
2930
+ will produce "["foo", "bar"]".
2931
+ </t >
2932
+ <t >
2933
+ The keyword "title"
2934
+ validated at "/properties/foo"
2935
+ by following the path "/properties/foo"
2936
+ will produce "foo-title".
2937
+ </t >
2938
+ <t >
2939
+ The keyword "properties"
2940
+ validated at "/properties/foo"
2941
+ by following the path "/properties/foo"
2942
+ will produce "["foo-prop"]".
2943
+ </t >
2944
+ <t >
2945
+ The keyword "title"
2946
+ validated at "/properties/foo/properties/foo-prop"
2947
+ by following the path "/properties/foo/properties/foo-prop"
2948
+ will produce "foo-prop-title".
2949
+ </t >
2950
+ <t >
2951
+ The keyword "title"
2952
+ validated at "/$defs/bar"
2953
+ by following the path "/properties/bar/$ref"
2954
+ will produce "bar-title".
2869
2955
</t >
2870
2956
<t >
2871
- The second object has a disallowed "z" property.
2957
+ The keyword "properties"
2958
+ validated at "/$defs/bar"
2959
+ by following the path "/properties/var/$ref"
2960
+ will produce "["bar-prop"]".
2872
2961
</t >
2873
2962
<t >
2874
- There are only two objects, but three are required.
2963
+ The keyword "title"
2964
+ validated at "/$defs/bar/properties/bar-prop"
2965
+ by following the path "/properties/bar/$ref/properties/bar-prop"
2966
+ will produce "bar-prop-title".
2875
2967
</t >
2876
2968
</list >
2877
- Note that the error message wording as depicted in these examples is not a
2878
- requirement of this specification. Implementations SHOULD craft error messages
2879
- tailored for their audience or provide a templating mechanism that allows their
2880
- users to craft their own messages.
2881
2969
</t >
2882
2970
2883
2971
<section title =" Flag" >
0 commit comments