xref: /aosp_15_r20/external/json-schema-validator/src/test/resources/draft7/issue653.json (revision 78c4dd6aa35290980cdcd1623a7e337e8d021c7c)
1[
2  {
3    "description": "issue653",
4    "schema": {
5      "title": "PetArray",
6      "type": "object",
7      "properties": {
8        "pets": {
9          "type": "array",
10          "items": {
11            "oneOf": [
12              {
13                "if": {
14                  "properties": {
15                    "pet_type": {
16                      "const": "Cat"
17                    }
18                  }
19                },
20                "then": {
21                  "type": "object",
22                  "properties": {
23                    "hunts": {
24                      "type": "boolean"
25                    },
26                    "age": {
27                      "type": "integer"
28                    }
29                  },
30                  "required": [
31                    "age"
32                  ]
33                },
34                "else": false
35              },
36              {
37                "if": {
38                  "properties": {
39                    "pet_type": {
40                      "const": "Dog"
41                    }
42                  }
43                },
44                "then": {
45                  "type": "object",
46                  "properties": {
47                    "bark": {
48                      "type": "boolean"
49                    },
50                    "breed": {
51                      "type": "string"
52                    }
53                  },
54                  "required": [
55                    "bark"
56                  ]
57                },
58                "else": false
59              }
60            ]
61          }
62        }
63      },
64      "additionalProperties": false,
65      "required": [
66        "pets"
67      ]
68    },
69    "tests": [
70      {
71        "description": "OneOf Validation removes validations, making invalid data appear valid",
72        "data": {
73          "pets": [
74            {
75              "pet_type": "Cat",
76              "hunts": "asdf",
77              "additionaValue": "asdf"
78            }
79          ]
80        },
81        "valid": false,
82        "validationMessages": [
83          "$.pets[0]: must be valid to one and only one schema, but 0 are valid",
84          "$.pets[0]: required property 'age' not found",
85          "$.pets[0]: schema for 'else' is false"
86        ]
87      }
88    ]
89  }
90]