xref: /aosp_15_r20/external/json-schema-validator/src/test/resources/schema/walk-schema-default.json (revision 78c4dd6aa35290980cdcd1623a7e337e8d021c7c)
1{
2  "$schema": "http://json-schema.org/draft-04/schema#",
3  "title": "Schema with default values ",
4
5  "definitions": {
6    "RandomObject": {
7      "type": "object",
8      "properties": {
9        "stringValue_missing": {
10          "description": "the test data does not have this attribute, so default should be applied if the ApplyDefaultsStrategy requires it",
11          "type": "string",
12          "default": "hello"
13        },
14        "stringValue_missing_with_default_null": {
15          "description": "the test data does not have this attribute, so default as null should be applied if the ApplyDefaultsStrategy requires it",
16          "type": "string",
17          "default": null
18        },
19        "stringValue_missing_with_no_default": {
20          "description": "the test data does not have this attribute, no default value should be applied",
21          "type": "string"
22        }
23      },
24      "required": [
25        "stringValue_missing"
26      ]
27    }
28  },
29
30  "type": "object",
31  "properties": {
32    "outer": {
33      "type": "object",
34      "properties": {
35        "mixedObject": {
36          "type": "object",
37          "properties": {
38            "intValue_present": {
39              "description": "the test data supplies a value for this attribute so the default is ignored",
40              "type": "integer",
41              "default": 5
42            },
43            "intValue_missing": {
44              "description": "the test data does not have this attribute, so default should be applied if the ApplyDefaultsStrategy requires it",
45              "type": "integer",
46              "default": 15
47            },
48            "intValue_missing_notRequired": {
49              "description": "the test data does not have this attribute, so default should be applied if the ApplyDefaultsStrategy requires it",
50              "type": "integer",
51              "default": 25
52            },
53            "intValue_null": {
54              "description": "the test data supplies the value null for this attribute so the default should be applied if the ApplyDefaultsStrategy requires it",
55              "type": "integer",
56              "default": 35
57            },
58            "intValue_missingButError": {
59              "description": "the test data does not have this attribute, so default should be applied if the ApplyDefaultsStrategy requires it, but the default is wrong so there should be an error",
60              "type": "integer",
61              "default": "forty-five"
62            }
63          },
64          "additionalProperties": false,
65          "required": [
66            "intValue_present",
67            "intValue_missing",
68            "intValue_null",
69            "intValue_missingButError"
70          ]
71        },
72
73        "goodArray": {
74          "type": "array",
75          "items": {
76            "description": "if an item in the array is null, then default value should be applied if the ApplyDefaultsStrategy requires it",
77            "type": "string",
78            "default": "five"
79          }
80        },
81
82        "badArray": {
83          "type": "array",
84          "items": {
85            "description": "if an item in the array is null, then default value should be applied if the ApplyDefaultsStrategy requires it, but the default is wrong so there should be an error",
86            "type": "string",
87            "default": 5
88          }
89        },
90
91        "reference": {
92          "$ref": "#/definitions/RandomObject"
93        }
94      },
95      "additionalProperties": false,
96      "required": ["mixedObject", "goodArray", "badArray", "reference"]
97    }
98  },
99  "additionalProperties": false,
100  "required": ["outer"]
101}
102