1{
2  "$schema": "https://json-schema.org/draft/2020-12/schema",
3  "$id": "https://json-schema.org/draft/2020-12/output/schema",
4  "description": "A schema that validates the minimum requirements for validation output",
5
6  "anyOf": [
7    { "$ref": "#/$defs/flag" },
8    { "$ref": "#/$defs/basic" },
9    { "$ref": "#/$defs/detailed" },
10    { "$ref": "#/$defs/verbose" }
11  ],
12  "$defs": {
13    "outputUnit":{
14      "properties": {
15        "valid": { "type": "boolean" },
16        "keywordLocation": {
17          "type": "string",
18          "format": "json-pointer"
19        },
20        "absoluteKeywordLocation": {
21          "type": "string",
22          "format": "uri"
23        },
24        "instanceLocation": {
25          "type": "string",
26          "format": "json-pointer"
27        },
28        "error": {
29          "type": "string"
30        },
31        "errors": {
32          "$ref": "#/$defs/outputUnitArray"
33        },
34        "annotations": {
35          "$ref": "#/$defs/outputUnitArray"
36        }
37      },
38      "required": [ "valid", "keywordLocation", "instanceLocation" ],
39      "allOf": [
40        {
41          "if": {
42            "properties": {
43              "valid": { "const": false }
44            }
45          },
46          "then": {
47            "anyOf": [
48              {
49                "required": [ "error" ]
50              },
51              {
52                "required": [ "errors" ]
53              }
54            ]
55          }
56        },
57        {
58          "if": {
59            "anyOf": [
60              {
61                "properties": {
62                  "keywordLocation": {
63                    "pattern": "/\\$ref/"
64                  }
65                }
66              },
67              {
68                "properties": {
69                  "keywordLocation": {
70                    "pattern": "/\\$dynamicRef/"
71                  }
72                }
73              }
74            ]
75          },
76          "then": {
77            "required": [ "absoluteKeywordLocation" ]
78          }
79        }
80      ]
81    },
82    "outputUnitArray": {
83      "type": "array",
84      "items": { "$ref": "#/$defs/outputUnit" }
85    },
86    "flag": {
87      "properties": {
88        "valid": { "type": "boolean" }
89      },
90      "required": [ "valid" ]
91    },
92    "basic": { "$ref": "#/$defs/outputUnit" },
93    "detailed": { "$ref": "#/$defs/outputUnit" },
94    "verbose": { "$ref": "#/$defs/outputUnit" }
95  }
96}
97