xref: /aosp_15_r20/external/json-schema-validator/src/test/resources/draft7/issue516.json (revision 78c4dd6aa35290980cdcd1623a7e337e8d021c7c)
1[
2  {
3    "description": "issue516",
4    "schema": {
5      "type": "object",
6      "properties": {
7        "locationName": {
8          "type": "string"
9        },
10        "activities": {
11          "type": "array",
12          "items": {
13            "oneOf": [
14              {
15                "type": "object",
16                "required": [
17                  "activityType",
18                  "weight",
19                  "height"
20                ],
21                "additionalProperties": false,
22                "properties": {
23                  "activityType": {
24                    "enum": [
25                      "machine"
26                    ]
27                  },
28                  "weight": {
29                    "type": "integer"
30                  },
31                  "height": {
32                    "type": "integer"
33                  }
34                }
35              },
36              {
37                "type": "object",
38                "required": [
39                  "activityType",
40                  "chemicalCharacteristic"
41                ],
42                "additionalProperties": false,
43                "properties": {
44                  "activityType": {
45                    "enum": [
46                      "chemical"
47                    ]
48                  },
49                  "chemicalCharacteristic": {
50                    "oneOf": [
51                      {
52                        "type": "object",
53                        "required": [
54                          "chemicalName"
55                        ],
56                        "additionalProperties": false,
57                        "properties": {
58                          "commonName": {
59                            "type": "string"
60                          },
61                          "chemicalName": {
62                            "type": "string"
63                          }
64                        }
65                      },
66                      {
67                        "type": "object",
68                        "required": [
69                          "chemicalName"
70                        ],
71                        "additionalProperties": false,
72                        "properties": {
73                          "categoryName": {
74                            "type": "string"
75                          },
76                          "chemicalName": {
77                            "type": "string"
78                          }
79                        }
80                      }
81                    ]
82                  }
83                }
84              }
85            ]
86          }
87        }
88      }
89    },
90    "tests": [
91      {
92        "description": "OneOfValidator is filtering out the required errors if all the oneOf schemas are having the issues",
93        "data": {
94          "locationName": "factoryLocation",
95          "activities": [
96            {
97              "activityType": "machine",
98              "age": "(additionalProperty not allowed)",
99              "height": 10.5
100            },
101            {
102              "activityType": "chemical",
103              "toxic": "(additionalProperty not allowed)",
104              "chemicalCharacteristic": {
105                "commonName": "methane",
106                "chemicalName": "CH4"
107              }
108            },
109            {
110              "activityType": "chemical",
111              "toxic": "(additionalProperty not allowed)",
112              "chemicalCharacteristic": {
113                "name": "methane",
114                "categoryName": "gasses",
115                "chemicalName": "CH4"
116              }
117            }
118          ]
119        },
120        "valid": false,
121        "validationMessages": [
122          "$.activities[0]: must be valid to one and only one schema, but 0 are valid",
123          "$.activities[0]: property 'age' is not defined in the schema and the schema does not allow additional properties",
124          "$.activities[0]: required property 'chemicalCharacteristic' not found",
125          "$.activities[0]: property 'height' is not defined in the schema and the schema does not allow additional properties",
126          "$.activities[0]: required property 'weight' not found",
127          "$.activities[1]: must be valid to one and only one schema, but 0 are valid",
128          "$.activities[1]: property 'chemicalCharacteristic' is not defined in the schema and the schema does not allow additional properties",
129          "$.activities[1]: required property 'height' not found",
130          "$.activities[1]: property 'toxic' is not defined in the schema and the schema does not allow additional properties",
131          "$.activities[1]: required property 'weight' not found",
132          "$.activities[2]: must be valid to one and only one schema, but 0 are valid",
133          "$.activities[2]: property 'chemicalCharacteristic' is not defined in the schema and the schema does not allow additional properties",
134          "$.activities[2].chemicalCharacteristic: must be valid to one and only one schema, but 0 are valid",
135          "$.activities[2].chemicalCharacteristic: property 'categoryName' is not defined in the schema and the schema does not allow additional properties",
136          "$.activities[2].chemicalCharacteristic: property 'name' is not defined in the schema and the schema does not allow additional properties",
137          "$.activities[2]: required property 'height' not found",
138          "$.activities[2]: property 'toxic' is not defined in the schema and the schema does not allow additional properties",
139          "$.activities[2]: required property 'weight' not found"
140        ]
141      }
142    ]
143  }
144]