Debian Codegraph @

spec/tests/schemas/advanced.json

raw symbols SCIP
1 [
2 {
3 "description": "advanced schema from z-schema benchmark (https://github.com/zaggino/z-schema)",
4 "schema": {
5 "$schema": "http://json-schema.org/draft-07/schema#",
6 "type": "object",
7 "properties": {
8 "/": {"$ref": "#/definitions/entry"}
9 },
10 "patternProperties": {
11 "^(/[^/]+)+$": {"$ref": "#/definitions/entry"}
12 },
13 "additionalProperties": false,
14 "required": ["/"],
15 "definitions": {
16 "entry": {
17 "$schema": "http://json-schema.org/draft-07/schema#",
18 "description": "schema for an fstab entry",
19 "type": "object",
20 "required": ["storage"],
21 "properties": {
22 "storage": {
23 "type": "object",
24 "oneOf": [
25 {"$ref": "#/definitions/entry/definitions/diskDevice"},
26 {"$ref": "#/definitions/entry/definitions/diskUUID"},
27 {"$ref": "#/definitions/entry/definitions/nfs"},
28 {"$ref": "#/definitions/entry/definitions/tmpfs"}
29 ]
30 },
31 "fstype": {
32 "enum": ["ext3", "ext4", "btrfs"]
33 },
34 "options": {
35 "type": "array",
36 "minItems": 1,
37 "items": {"type": "string"},
38 "uniqueItems": true
39 },
40 "readonly": {"type": "boolean"}
41 },
42 "definitions": {
43 "diskDevice": {
44 "properties": {
45 "type": {"enum": ["disk"]},
46 "device": {
47 "type": "string",
48 "pattern": "^/dev/[^/]+(/[^/]+)*$"
49 }
50 },
51 "required": ["type", "device"],
52 "additionalProperties": false
53 },
54 "diskUUID": {
55 "properties": {
56 "type": {"enum": ["disk"]},
57 "label": {
58 "type": "string",
59 "pattern": "^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$"
60 }
61 },
62 "required": ["type", "label"],
63 "additionalProperties": false
64 },
65 "nfs": {
66 "properties": {
67 "type": {"enum": ["nfs"]},
68 "remotePath": {
69 "type": "string",
70 "pattern": "^(/[^/]+)+$"
71 },
72 "server": {
73 "type": "string",
74 "anyOf": [{"format": "hostname"}, {"format": "ipv4"}, {"format": "ipv6"}]
75 }
76 },
77 "required": ["type", "server", "remotePath"],
78 "additionalProperties": false
79 },
80 "tmpfs": {
81 "properties": {
82 "type": {"enum": ["tmpfs"]},
83 "sizeInMB": {
84 "type": "integer",
85 "minimum": 16,
86 "maximum": 512
87 }
88 },
89 "required": ["type", "sizeInMB"],
90 "additionalProperties": false
91 }
92 }
93 }
94 }
95 },
96 "tests": [
97 {
98 "description": "valid object from z-schema benchmark",
99 "data": {
100 "/": {
101 "storage": {
102 "type": "disk",
103 "device": "/dev/sda1"
104 },
105 "fstype": "btrfs",
106 "readonly": true
107 },
108 "/var": {
109 "storage": {
110 "type": "disk",
111 "label": "8f3ba6f4-5c70-46ec-83af-0d5434953e5f"
112 },
113 "fstype": "ext4",
114 "options": ["nosuid"]
115 },
116 "/tmp": {
117 "storage": {
118 "type": "tmpfs",
119 "sizeInMB": 64
120 }
121 },
122 "/var/www": {
123 "storage": {
124 "type": "nfs",
125 "server": "my.nfs.server",
126 "remotePath": "/exports/mypath"
127 }
128 }
129 },
130 "valid": true
131 },
132 {
133 "description": "not object",
134 "data": 1,
135 "valid": false
136 },
137 {
138 "description": "root only is valid",
139 "data": {
140 "/": {
141 "storage": {
142 "type": "disk",
143 "device": "/dev/sda1"
144 },
145 "fstype": "btrfs",
146 "readonly": true
147 }
148 },
149 "valid": true
150 },
151 {
152 "description": "missing root entry",
153 "data": {
154 "no root/": {
155 "storage": {
156 "type": "disk",
157 "device": "/dev/sda1"
158 },
159 "fstype": "btrfs",
160 "readonly": true
161 }
162 },
163 "valid": false
164 },
165 {
166 "description": "invalid entry key",
167 "data": {
168 "/": {
169 "storage": {
170 "type": "disk",
171 "device": "/dev/sda1"
172 },
173 "fstype": "btrfs",
174 "readonly": true
175 },
176 "invalid/var": {
177 "storage": {
178 "type": "disk",
179 "label": "8f3ba6f4-5c70-46ec-83af-0d5434953e5f"
180 },
181 "fstype": "ext4",
182 "options": ["nosuid"]
183 }
184 },
185 "valid": false
186 },
187 {
188 "description": "missing storage in entry",
189 "data": {
190 "/": {
191 "fstype": "btrfs",
192 "readonly": true
193 }
194 },
195 "valid": false
196 },
197 {
198 "description": "missing storage type",
199 "data": {
200 "/": {
201 "storage": {
202 "device": "/dev/sda1"
203 },
204 "fstype": "btrfs",
205 "readonly": true
206 }
207 },
208 "valid": false
209 },
210 {
211 "description": "storage type should be a string",
212 "data": {
213 "/": {
214 "storage": {
215 "type": null,
216 "device": "/dev/sda1"
217 },
218 "fstype": "btrfs",
219 "readonly": true
220 }
221 },
222 "valid": false
223 },
224 {
225 "description": "storage device should match pattern",
226 "data": {
227 "/": {
228 "storage": {
229 "type": null,
230 "device": "invalid/dev/sda1"
231 },
232 "fstype": "btrfs",
233 "readonly": true
234 }
235 },
236 "valid": false
237 }
238 ]
239 }
240 ]