Add user dynamic array field support
[deliverable/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
158 items:
f1ac89a9
PP
159 if:
160 type: object
161 then:
162 properties:
163 label:
164 type: string
165 value:
166 if:
167 type: array
168 then:
169 items:
170 type: integer
171 minItems: 2
172 maxItems: 2
173 else:
174 type: integer
175 additionalProperties: false
176 required:
177 - label
178 - value
179 else:
180 type: string
6839ffba
PP
181 required:
182 - class
183 - value-type
184 additionalProperties: false
4810b707 185 string-ft-class-prop:
6839ffba
PP
186 type: string
187 enum:
188 - str
189 - string
4810b707 190 string-ft:
6839ffba
PP
191 title: String field type object
192 type: object
193 properties:
194 class:
4810b707 195 $ref: '#/definitions/string-ft-class-prop'
6839ffba 196 encoding:
4810b707 197 $ref: '#/definitions/opt-encoding-prop'
6839ffba
PP
198 required:
199 - class
200 additionalProperties: false
be9f12dc 201 array-ft-class-prop:
6839ffba
PP
202 type: string
203 const: array
be9f12dc 204 array-ft:
4810b707 205 title: Static array field type object
6839ffba
PP
206 type: object
207 properties:
208 class:
be9f12dc 209 $ref: '#/definitions/array-ft-class-prop'
6839ffba 210 element-type:
4810b707 211 $ref: '#/definitions/ft'
6839ffba 212 length:
be9f12dc
PP
213 if:
214 type: integer
215 then:
216 minimum: 0
217 else:
218 type: string
219 const: dynamic
6839ffba
PP
220 required:
221 - class
222 - element-type
223 - length
224 additionalProperties: false
4810b707 225 struct-ft-class-prop:
6839ffba
PP
226 type: string
227 enum:
228 - struct
229 - structure
4810b707 230 struct-ft:
6839ffba
PP
231 title: Structure field type object
232 type: object
233 properties:
234 class:
4810b707 235 $ref: '#/definitions/struct-ft-class-prop'
6839ffba 236 min-align:
c3fa1a14 237 $ref: https://barectf.org/schemas/config/common/common.json#/definitions/opt-int-min-1
6839ffba 238 fields:
f1ac89a9
PP
239 if:
240 type: object
241 then:
242 patternProperties:
243 '^[A-Za-z_][A-Za-z0-9_]*$':
4810b707 244 $ref: '#/definitions/ft'
f1ac89a9
PP
245 additionalProperties: false
246 else:
247 type: 'null'
6839ffba
PP
248 required:
249 - class
250 additionalProperties: false
4810b707 251 ft:
6839ffba
PP
252 type: object
253 properties:
254 class:
4810b707
PP
255 # This is used to make sure that the field type's class name is
256 # valid as any of the conditionals below can fail.
257 #
258 # Although we could use `oneOf` instead of this enumeration here
259 # and refer to each of the `*-ft-class-prop` definitions, it
260 # would be hard for the validator to show something useful for
261 # the user as all cases would fail.
262 #
263 # Using `enum` below makes the validator show a very clear
264 # validation failure message.
6839ffba
PP
265 enum:
266 - int
267 - integer
268 - flt
269 - float
270 - floating-point
271 - enum
272 - enumeration
273 - str
274 - string
275 - array
276 - struct
277 - structure
278 allOf:
279 - if:
280 properties:
281 class:
4810b707 282 $ref: '#/definitions/int-ft-class-prop'
6839ffba 283 then:
4810b707 284 $ref: '#/definitions/int-ft'
6839ffba
PP
285 - if:
286 properties:
287 class:
4810b707 288 $ref: '#/definitions/real-ft-class-prop'
6839ffba 289 then:
4810b707 290 $ref: '#/definitions/real-ft'
6839ffba
PP
291 - if:
292 properties:
293 class:
4810b707 294 $ref: '#/definitions/enum-ft-class-prop'
6839ffba 295 then:
4810b707 296 $ref: '#/definitions/enum-ft'
6839ffba
PP
297 - if:
298 properties:
299 class:
4810b707 300 $ref: '#/definitions/string-ft-class-prop'
6839ffba 301 then:
4810b707 302 $ref: '#/definitions/string-ft'
6839ffba
PP
303 - if:
304 properties:
305 class:
be9f12dc 306 $ref: '#/definitions/array-ft-class-prop'
6839ffba 307 then:
be9f12dc 308 $ref: '#/definitions/array-ft'
6839ffba
PP
309 - if:
310 properties:
311 class:
4810b707 312 $ref: '#/definitions/struct-ft-class-prop'
6839ffba 313 then:
4810b707 314 $ref: '#/definitions/struct-ft'
6839ffba
PP
315 required:
316 - class
4810b707 317$ref: '#/definitions/ft'
This page took 0.044952 seconds and 4 git commands to generate.