Fix: YAML: force enumeration FT objects to have at least one mapping
[barectf.git] / barectf / schemas / config / 2 / field-type.yaml
CommitLineData
6839ffba
PP
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#
c3fa1a14 25$id: https://barectf.org/schemas/config/2/field-type.json
6839ffba
PP
26title: Effective field type object
27definitions:
4810b707 28 opt-encoding-prop:
6839ffba 29 title: Encoding property value
f1ac89a9
PP
30 if:
31 type: string
32 then:
33 enum:
6839ffba
PP
34 - utf8
35 - UTF8
36 - utf-8
37 - UTF-8
38 - Utf-8
39 - ascii
40 - Ascii
41 - ASCII
42 - none
43 - None
44 - NONE
f1ac89a9
PP
45 else:
46 type: 'null'
4810b707 47 int-ft-class-prop:
6839ffba
PP
48 type: string
49 enum:
50 - int
51 - integer
4810b707 52 int-ft:
6839ffba
PP
53 title: Integer field type object
54 type: object
55 properties:
56 class:
4810b707 57 $ref: '#/definitions/int-ft-class-prop'
6839ffba 58 size:
c3fa1a14 59 $ref: https://barectf.org/schemas/config/common/common.json#/definitions/int-ft-size-prop
6839ffba
PP
60 signed:
61 oneOf:
62 - type: boolean
63 - type: 'null'
64 align:
c3fa1a14 65 $ref: https://barectf.org/schemas/config/common/common.json#/definitions/opt-int-min-1
6839ffba 66 byte-order:
c3fa1a14 67 $ref: https://barectf.org/schemas/config/common/common.json#/definitions/opt-byte-order-prop
6839ffba 68 base:
c3fa1a14 69 $ref: https://barectf.org/schemas/config/common/common.json#/definitions/opt-int-ft-preferred-display-base-prop
6839ffba 70 encoding:
4810b707 71 $ref: '#/definitions/opt-encoding-prop'
6839ffba 72 property-mappings:
f1ac89a9
PP
73 if:
74 type: array
75 then:
76 items:
77 type: object
78 properties:
79 type:
80 type: string
81 const: clock
82 name:
83 type: string
84 pattern: '^[A-Za-z_][A-Za-z0-9_]*$'
85 property:
86 type: string
87 const: value
88 required:
89 - type
90 - name
91 - property
92 additionalProperties: false
93 minItems: 1
94 maxItems: 1
95 else:
96 type: 'null'
6839ffba
PP
97 required:
98 - class
99 - size
100 additionalProperties: false
4810b707 101 real-ft-class-prop:
6839ffba
PP
102 type: string
103 enum:
104 - flt
105 - float
106 - floating-point
4810b707
PP
107 real-ft:
108 title: Real field type object
6839ffba
PP
109 type: object
110 properties:
111 class:
4810b707 112 $ref: '#/definitions/real-ft-class-prop'
6839ffba
PP
113 size:
114 type: object
115 properties:
116 exp:
117 type: integer
118 mant:
119 type: integer
120 oneOf:
121 - properties:
122 exp:
123 const: 8
124 mant:
125 const: 24
126 - properties:
127 exp:
128 const: 11
129 mant:
130 const: 53
131 required:
132 - exp
133 - mant
134 additionalProperties: false
135 align:
c3fa1a14 136 $ref: https://barectf.org/schemas/config/common/common.json#/definitions/opt-int-min-1
6839ffba 137 byte-order:
c3fa1a14 138 $ref: https://barectf.org/schemas/config/common/common.json#/definitions/opt-byte-order-prop
6839ffba
PP
139 required:
140 - class
141 - size
142 additionalProperties: false
4810b707 143 enum-ft-class-prop:
6839ffba
PP
144 type: string
145 enum:
146 - enum
147 - enumeration
4810b707 148 enum-ft:
6839ffba
PP
149 title: Enumeration field type object
150 type: object
151 properties:
152 class:
4810b707 153 $ref: '#/definitions/enum-ft-class-prop'
6839ffba 154 value-type:
4810b707 155 $ref: '#/definitions/int-ft'
6839ffba
PP
156 members:
157 type: array
98bc60de 158 minItems: 1
6839ffba 159 items:
f1ac89a9
PP
160 if:
161 type: object
162 then:
163 properties:
164 label:
165 type: string
166 value:
167 if:
168 type: array
169 then:
170 items:
171 type: integer
172 minItems: 2
173 maxItems: 2
174 else:
175 type: integer
176 additionalProperties: false
177 required:
178 - label
179 - value
180 else:
181 type: string
6839ffba
PP
182 required:
183 - class
184 - value-type
185 additionalProperties: false
4810b707 186 string-ft-class-prop:
6839ffba
PP
187 type: string
188 enum:
189 - str
190 - string
4810b707 191 string-ft:
6839ffba
PP
192 title: String field type object
193 type: object
194 properties:
195 class:
4810b707 196 $ref: '#/definitions/string-ft-class-prop'
6839ffba 197 encoding:
4810b707 198 $ref: '#/definitions/opt-encoding-prop'
6839ffba
PP
199 required:
200 - class
201 additionalProperties: false
be9f12dc 202 array-ft-class-prop:
6839ffba
PP
203 type: string
204 const: array
be9f12dc 205 array-ft:
4810b707 206 title: Static array field type object
6839ffba
PP
207 type: object
208 properties:
209 class:
be9f12dc 210 $ref: '#/definitions/array-ft-class-prop'
6839ffba 211 element-type:
4810b707 212 $ref: '#/definitions/ft'
6839ffba 213 length:
be9f12dc
PP
214 if:
215 type: integer
216 then:
217 minimum: 0
218 else:
219 type: string
220 const: dynamic
6839ffba
PP
221 required:
222 - class
223 - element-type
224 - length
225 additionalProperties: false
4810b707 226 struct-ft-class-prop:
6839ffba
PP
227 type: string
228 enum:
229 - struct
230 - structure
4810b707 231 struct-ft:
6839ffba
PP
232 title: Structure field type object
233 type: object
234 properties:
235 class:
4810b707 236 $ref: '#/definitions/struct-ft-class-prop'
6839ffba 237 min-align:
c3fa1a14 238 $ref: https://barectf.org/schemas/config/common/common.json#/definitions/opt-int-min-1
6839ffba 239 fields:
f1ac89a9
PP
240 if:
241 type: object
242 then:
243 patternProperties:
244 '^[A-Za-z_][A-Za-z0-9_]*$':
4810b707 245 $ref: '#/definitions/ft'
f1ac89a9
PP
246 additionalProperties: false
247 else:
248 type: 'null'
6839ffba
PP
249 required:
250 - class
251 additionalProperties: false
4810b707 252 ft:
6839ffba
PP
253 type: object
254 properties:
255 class:
4810b707
PP
256 # This is used to make sure that the field type's class name is
257 # valid as any of the conditionals below can fail.
258 #
259 # Although we could use `oneOf` instead of this enumeration here
260 # and refer to each of the `*-ft-class-prop` definitions, it
261 # would be hard for the validator to show something useful for
262 # the user as all cases would fail.
263 #
264 # Using `enum` below makes the validator show a very clear
265 # validation failure message.
6839ffba
PP
266 enum:
267 - int
268 - integer
269 - flt
270 - float
271 - floating-point
272 - enum
273 - enumeration
274 - str
275 - string
276 - array
277 - struct
278 - structure
279 allOf:
280 - if:
281 properties:
282 class:
4810b707 283 $ref: '#/definitions/int-ft-class-prop'
6839ffba 284 then:
4810b707 285 $ref: '#/definitions/int-ft'
6839ffba
PP
286 - if:
287 properties:
288 class:
4810b707 289 $ref: '#/definitions/real-ft-class-prop'
6839ffba 290 then:
4810b707 291 $ref: '#/definitions/real-ft'
6839ffba
PP
292 - if:
293 properties:
294 class:
4810b707 295 $ref: '#/definitions/enum-ft-class-prop'
6839ffba 296 then:
4810b707 297 $ref: '#/definitions/enum-ft'
6839ffba
PP
298 - if:
299 properties:
300 class:
4810b707 301 $ref: '#/definitions/string-ft-class-prop'
6839ffba 302 then:
4810b707 303 $ref: '#/definitions/string-ft'
6839ffba
PP
304 - if:
305 properties:
306 class:
be9f12dc 307 $ref: '#/definitions/array-ft-class-prop'
6839ffba 308 then:
be9f12dc 309 $ref: '#/definitions/array-ft'
6839ffba
PP
310 - if:
311 properties:
312 class:
4810b707 313 $ref: '#/definitions/struct-ft-class-prop'
6839ffba 314 then:
4810b707 315 $ref: '#/definitions/struct-ft'
6839ffba
PP
316 required:
317 - class
4810b707 318$ref: '#/definitions/ft'
This page took 0.03835 seconds and 4 git commands to generate.