Fix: YAML: force enumeration FT objects to have at least one mapping
[barectf.git] / barectf / schemas / config / 3 / field-type.yaml
1 # The MIT License (MIT)
2 #
3 # Copyright (c) 2020 Philippe Proulx <pproulx@efficios.com>
4 #
5 # Permission is hereby granted, free of charge, to any person obtaining
6 # a copy of this software and associated documentation files (the
7 # "Software"), to deal in the Software without restriction, including
8 # without limitation the rights to use, copy, modify, merge, publish,
9 # distribute, sublicense, and/or sell copies of the Software, and to
10 # permit persons to whom the Software is furnished to do so, subject to
11 # the following conditions:
12 #
13 # The above copyright notice and this permission notice shall be
14 # included in all copies or substantial portions of the Software.
15 #
16 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17 # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18 # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19 # IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20 # CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21 # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22 # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23
24 $schema: http://json-schema.org/draft-07/schema#
25 $id: https://barectf.org/schemas/config/3/field-type.json
26 title: Effective field type object
27 definitions:
28 ft-base:
29 type: object
30 required:
31 - class
32 bit-array-ft:
33 allOf:
34 - $ref: '#/definitions/ft-base'
35 - properties:
36 size:
37 $ref: https://barectf.org/schemas/config/common/common.json#/definitions/int-ft-size-prop
38 alignment:
39 $ref: https://barectf.org/schemas/config/common/common.json#/definitions/opt-int-min-1
40 required:
41 - size
42 int-ft-props:
43 properties:
44 class: true
45 size: true
46 alignment: true
47 preferred-display-base: true
48 additionalProperties: false
49 int-ft:
50 allOf:
51 - $ref: '#/definitions/bit-array-ft'
52 - properties:
53 preferred-display-base:
54 $ref: https://barectf.org/schemas/config/common/common.json#/definitions/opt-int-ft-preferred-display-base-prop
55 uint-ft-class-prop:
56 type: string
57 enum:
58 - uint
59 - unsigned-int
60 - unsigned-integer
61 uint-ft:
62 title: Unsigned integer field type object
63 allOf:
64 - $ref: '#/definitions/int-ft'
65 - $ref: '#/definitions/int-ft-props'
66 - properties:
67 class:
68 $ref: '#/definitions/uint-ft-class-prop'
69 sint-ft-class-prop:
70 type: string
71 enum:
72 - sint
73 - signed-int
74 - signed-integer
75 sint-ft:
76 title: Signed integer field type object
77 allOf:
78 - $ref: '#/definitions/int-ft'
79 - $ref: '#/definitions/int-ft-props'
80 - properties:
81 class:
82 $ref: '#/definitions/sint-ft-class-prop'
83 enum-ft-props:
84 properties:
85 class: true
86 size: true
87 alignment: true
88 preferred-display-base: true
89 mappings: true
90 additionalProperties: false
91 enum-ft:
92 properties:
93 class: true
94 size: true
95 alignment: true
96 preferred-display-base: true
97 mappings:
98 if:
99 type: object
100 then:
101 patternProperties:
102 '.*':
103 type: array
104 minItems: 1
105 items:
106 if:
107 type: array
108 then:
109 items:
110 type: integer
111 minItems: 2
112 maxItems: 2
113 else:
114 type: integer
115 minProperties: 1
116 else:
117 type: 'null'
118 additionalProperties: false
119 required:
120 - mappings
121 uenum-ft-class-prop:
122 type: string
123 enum:
124 - uenum
125 - unsigned-enum
126 - unsigned-enumeration
127 uenum-ft:
128 title: Unsigned enumeration field type object
129 allOf:
130 - $ref: '#/definitions/int-ft'
131 - $ref: '#/definitions/enum-ft'
132 - $ref: '#/definitions/enum-ft-props'
133 - properties:
134 class:
135 $ref: '#/definitions/uenum-ft-class-prop'
136 senum-ft-class-prop:
137 type: string
138 enum:
139 - senum
140 - signed-enum
141 - signed-enumeration
142 senum-ft:
143 title: Signed enumeration field type object
144 allOf:
145 - $ref: '#/definitions/int-ft'
146 - $ref: '#/definitions/enum-ft'
147 - $ref: '#/definitions/enum-ft-props'
148 - properties:
149 class:
150 $ref: '#/definitions/senum-ft-class-prop'
151 real-ft-class-prop:
152 type: string
153 const: real
154 real-ft:
155 title: Real field type object
156 allOf:
157 - $ref: '#/definitions/bit-array-ft'
158 - properties:
159 class:
160 $ref: '#/definitions/real-ft-class-prop'
161 size:
162 enum:
163 - 32
164 - 64
165 properties:
166 class: true
167 size: true
168 alignment: true
169 additionalProperties: false
170 string-ft-class-prop:
171 type: string
172 enum:
173 - str
174 - string
175 string-ft:
176 title: String field type object
177 allOf:
178 - $ref: '#/definitions/ft-base'
179 - properties:
180 class:
181 $ref: '#/definitions/string-ft-class-prop'
182 properties:
183 class: true
184 additionalProperties: false
185 array-ft:
186 title: Array field type object
187 allOf:
188 - $ref: '#/definitions/ft-base'
189 - properties:
190 element-field-type:
191 $ref: '#/definitions/ft'
192 required:
193 - element-field-type
194 static-array-ft-class-prop:
195 type: string
196 const: static-array
197 static-array-ft:
198 title: Static array field type object
199 allOf:
200 - $ref: '#/definitions/array-ft'
201 - properties:
202 class:
203 $ref: '#/definitions/static-array-ft-class-prop'
204 length:
205 type: integer
206 minimum: 0
207 properties:
208 class: true
209 element-field-type: true
210 length: true
211 additionalProperties: false
212 dynamic-array-ft-class-prop:
213 type: string
214 const: dynamic-array
215 dynamic-array-ft-class-prop:
216 title: Dynamic array field type object
217 allOf:
218 - $ref: '#/definitions/array-ft'
219 - properties:
220 class:
221 $ref: '#/definitions/dynamic-array-ft-class-prop'
222 properties:
223 class: true
224 element-field-type: true
225 additionalProperties: false
226 struct-ft-class-prop:
227 type: string
228 enum:
229 - struct
230 - structure
231 struct-ft-member:
232 type: object
233 properties:
234 field-type:
235 $ref: '#/definitions/ft'
236 required:
237 - field-type
238 additionalProperties: false
239 struct-ft-members:
240 type: array
241 items:
242 type: object
243 patternProperties:
244 '^[A-Za-z_][A-Za-z0-9_]*$':
245 $ref: '#/definitions/struct-ft-member'
246 minProperties: 1
247 maxProperties: 1
248 struct-ft:
249 title: Structure field type object
250 allOf:
251 - $ref: '#/definitions/ft-base'
252 - properties:
253 class:
254 $ref: '#/definitions/struct-ft-class-prop'
255 minimum-alignment:
256 $ref: https://barectf.org/schemas/config/common/common.json#/definitions/opt-int-min-1
257 members:
258 if:
259 type: array
260 then:
261 $ref: '#/definitions/struct-ft-members'
262 else:
263 type: 'null'
264 properties:
265 class: true
266 minimum-alignment: true
267 members: true
268 additionalProperties: false
269 ft:
270 allOf:
271 - $ref: '#/definitions/ft-base'
272 - properties:
273 # This is used to make sure that the field type's class name
274 # is valid as any of the conditionals below can fail.
275 #
276 # Although we could use `oneOf` instead of this enumeration
277 # here and refer to each of the `*-ft-class-prop` definitions,
278 # it would be hard for the validator to show something useful
279 # for the user as all cases would fail.
280 #
281 # Using `enum` below makes the validator show a very clear
282 # validation failure message.
283 class:
284 enum:
285 - uint
286 - unsigned-int
287 - unsigned-integer
288 - sint
289 - signed-int
290 - signed-integer
291 - uenum
292 - unsigned-enum
293 - unsigned-enumeration
294 - senum
295 - signed-enum
296 - signed-enumeration
297 - real
298 - str
299 - string
300 - static-array
301 - dynamic-array
302 - struct
303 - structure
304 - if:
305 properties:
306 class:
307 $ref: '#/definitions/uint-ft-class-prop'
308 then:
309 $ref: '#/definitions/uint-ft'
310 - if:
311 properties:
312 class:
313 $ref: '#/definitions/sint-ft-class-prop'
314 then:
315 $ref: '#/definitions/sint-ft'
316 - if:
317 properties:
318 class:
319 $ref: '#/definitions/uenum-ft-class-prop'
320 then:
321 $ref: '#/definitions/uenum-ft'
322 - if:
323 properties:
324 class:
325 $ref: '#/definitions/senum-ft-class-prop'
326 then:
327 $ref: '#/definitions/senum-ft'
328 - if:
329 properties:
330 class:
331 $ref: '#/definitions/real-ft-class-prop'
332 then:
333 $ref: '#/definitions/real-ft'
334 - if:
335 properties:
336 class:
337 $ref: '#/definitions/string-ft-class-prop'
338 then:
339 $ref: '#/definitions/string-ft'
340 - if:
341 properties:
342 class:
343 $ref: '#/definitions/static-array-ft-class-prop'
344 then:
345 $ref: '#/definitions/static-array-ft'
346 - if:
347 properties:
348 class:
349 $ref: '#/definitions/dynamic-array-ft-class-prop'
350 then:
351 $ref: '#/definitions/dynamic-array-ft'
352 - if:
353 properties:
354 class:
355 $ref: '#/definitions/struct-ft-class-prop'
356 then:
357 $ref: '#/definitions/struct-ft'
358 required:
359 - class
360 $ref: '#/definitions/ft'
This page took 0.038872 seconds and 4 git commands to generate.