diff options
author | Zach White <skullydazed@gmail.com> | 2021-06-24 20:48:53 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-24 20:48:53 -0700 |
commit | b908275354ba6cd9dd4d393dbbedfbd2ad0f316d (patch) | |
tree | 7efbb70c51fb917d203b629feb9eadf169f71c91 /data | |
parent | 9d4412cb8bf9512952118b190fedea72e33d28cb (diff) | |
download | qmk_firmware-b908275354ba6cd9dd4d393dbbedfbd2ad0f316d.tar.gz qmk_firmware-b908275354ba6cd9dd4d393dbbedfbd2ad0f316d.zip |
Optimize our jsonschema by using refs (#13271)
* fix some broken info.json files
* optimize our jsonschema using refs
* fix formatting after vscode broke it
* make flake8 happy
* cleanup
* make our schema validation more compact and flexible
Diffstat (limited to 'data')
-rw-r--r-- | data/schemas/api_keyboard.jsonschema | 44 | ||||
-rw-r--r-- | data/schemas/definitions.jsonschema | 107 | ||||
-rw-r--r-- | data/schemas/keyboard.jsonschema | 263 |
3 files changed, 162 insertions, 252 deletions
diff --git a/data/schemas/api_keyboard.jsonschema b/data/schemas/api_keyboard.jsonschema index d570ee999..d638658a1 100644 --- a/data/schemas/api_keyboard.jsonschema +++ b/data/schemas/api_keyboard.jsonschema | |||
@@ -1,34 +1,22 @@ | |||
1 | { | 1 | { |
2 | "$id": "qmk.api.keyboard.v1", | ||
2 | "allOf": [ | 3 | "allOf": [ |
3 | { "$ref": "qmk.keyboard.v1" }, | 4 | {"$ref": "qmk.keyboard.v1"}, |
4 | { | 5 | { |
5 | "$id": "qmk.api.keyboard.v1", | 6 | "properties": { |
6 | "keymaps": { | 7 | "keymaps": { |
7 | "type": "string" | 8 | "type": "object", |
8 | }, | 9 | "properties": { |
9 | "parse_errors": { | 10 | "url": {"type": "string"} |
10 | "type": "array", | 11 | } |
11 | "items": { | 12 | |
12 | "type": "string" | 13 | }, |
13 | } | 14 | "parse_errors": {"$ref": "qmk.definitions.v1#/string_array"}, |
14 | }, | 15 | "parse_warnings": {"$ref": "qmk.definitions.v1#/string_array"}, |
15 | "parse_warnings": { | 16 | "processor_type": {"type": "string"}, |
16 | "type": "array", | 17 | "protocol": {"type": "string"}, |
17 | "items": { | 18 | "keyboard_folder": {"type": "string"}, |
18 | "type": "string" | 19 | "platform": {"type": "string"} |
19 | } | ||
20 | }, | ||
21 | "processor_type": { | ||
22 | "type": "string" | ||
23 | }, | ||
24 | "protocol": { | ||
25 | "type": "string" | ||
26 | }, | ||
27 | "keyboard_folder": { | ||
28 | "type": "string" | ||
29 | }, | ||
30 | "platform": { | ||
31 | "type": "string" | ||
32 | } | 20 | } |
33 | } | 21 | } |
34 | ] | 22 | ] |
diff --git a/data/schemas/definitions.jsonschema b/data/schemas/definitions.jsonschema new file mode 100644 index 000000000..822f23707 --- /dev/null +++ b/data/schemas/definitions.jsonschema | |||
@@ -0,0 +1,107 @@ | |||
1 | { | ||
2 | "$schema": "http://json-schema.org/draft-07/schema#", | ||
3 | "$id": "qmk.definitions.v1", | ||
4 | "title": "Common definitions used across QMK's jsonschemas.", | ||
5 | "type": "object", | ||
6 | "boolean_array": { | ||
7 | "type": "object", | ||
8 | "additionalProperties": {"type": "boolean"} | ||
9 | }, | ||
10 | "filename": { | ||
11 | "type": "string", | ||
12 | "minLength": 1, | ||
13 | "pattern": "^[0-9a-z_]*$" | ||
14 | }, | ||
15 | "hex_number_2d": { | ||
16 | "type": "string", | ||
17 | "pattern": "^0x[0-9A-F]{2}$" | ||
18 | }, | ||
19 | "hex_number_4d": { | ||
20 | "type": "string", | ||
21 | "pattern": "^0x[0-9A-F]{4}$" | ||
22 | }, | ||
23 | "text_identifier": { | ||
24 | "type": "string", | ||
25 | "minLength": 1, | ||
26 | "maxLength": 250 | ||
27 | }, | ||
28 | "layout_macro": { | ||
29 | "oneOf": [ | ||
30 | { | ||
31 | "type": "string", | ||
32 | "enum": ["LAYOUT", "LAYOUT_planck_1x2uC"] | ||
33 | }, | ||
34 | { | ||
35 | "type": "string", | ||
36 | "pattern": "^LAYOUT_[0-9a-z_]*$" | ||
37 | } | ||
38 | ] | ||
39 | }, | ||
40 | "key_unit": { | ||
41 | "type": "number", | ||
42 | "min": 0.25 | ||
43 | }, | ||
44 | "mcu_pin_array": { | ||
45 | "type": "array", | ||
46 | "items": {"$ref": "#/mcu_pin"} | ||
47 | }, | ||
48 | "mcu_pin": { | ||
49 | "oneOf": [ | ||
50 | { | ||
51 | "type": "string", | ||
52 | "pattern": "^[A-K]\\d{1,2}$" | ||
53 | }, | ||
54 | { | ||
55 | "type": "string", | ||
56 | "pattern": "^LINE_PIN\\d{1,2}$" | ||
57 | }, | ||
58 | { | ||
59 | "type": "number", | ||
60 | "multipleOf": 1 | ||
61 | }, | ||
62 | { | ||
63 | "type": "null" | ||
64 | } | ||
65 | ] | ||
66 | }, | ||
67 | "signed_decimal": { | ||
68 | "type": "number" | ||
69 | }, | ||
70 | "signed_int": { | ||
71 | "type": "number", | ||
72 | "multipleOf": 1 | ||
73 | } | ||
74 | "signed_int_8": { | ||
75 | "type": "number", | ||
76 | "min": -127, | ||
77 | "max": 127, | ||
78 | "multipleOf": 1 | ||
79 | } | ||
80 | "string_array": { | ||
81 | "type": "array", | ||
82 | "items": { | ||
83 | "type": "string" | ||
84 | } | ||
85 | }, | ||
86 | "string_object": { | ||
87 | "type": "object", | ||
88 | "additionalProperties": { | ||
89 | "type": "string" | ||
90 | } | ||
91 | }, | ||
92 | "unsigned_decimal": { | ||
93 | "type": "number", | ||
94 | "min": 0 | ||
95 | }, | ||
96 | "unsigned_int": { | ||
97 | "type": "number", | ||
98 | "min": 0, | ||
99 | "multipleOf": 1 | ||
100 | } | ||
101 | "unsigned_int_8": { | ||
102 | "type": "number", | ||
103 | "min": 0, | ||
104 | "max": 255, | ||
105 | "multipleOf": 1 | ||
106 | } | ||
107 | } | ||
diff --git a/data/schemas/keyboard.jsonschema b/data/schemas/keyboard.jsonschema index 177bb0a96..d6d33ce4e 100644 --- a/data/schemas/keyboard.jsonschema +++ b/data/schemas/keyboard.jsonschema | |||
@@ -1,24 +1,12 @@ | |||
1 | { | 1 | { |
2 | "$schema": "http://json-schema.org/schema#", | 2 | "$schema": "http://json-schema.org/draft-07/schema#", |
3 | "$id": "qmk.keyboard.v1", | 3 | "$id": "qmk.keyboard.v1", |
4 | "title": "Keyboard Information", | 4 | "title": "Keyboard Information", |
5 | "type": "object", | 5 | "type": "object", |
6 | "properties": { | 6 | "properties": { |
7 | "keyboard_name": { | 7 | "keyboard_name": {"$ref": "qmk.definitions.v1#/text_identifier"}, |
8 | "type": "string", | 8 | "maintainer": {"$ref": "qmk.definitions.v1#/text_identifier"}, |
9 | "minLength": 2, | 9 | "manufacturer": {"$ref": "qmk.definitions.v1#/text_identifier"}, |
10 | "maxLength": 250 | ||
11 | }, | ||
12 | "maintainer": { | ||
13 | "type": "string", | ||
14 | "minLength": 2, | ||
15 | "maxLength": 250 | ||
16 | }, | ||
17 | "manufacturer": { | ||
18 | "type": "string", | ||
19 | "minLength": 2, | ||
20 | "maxLength": 250 | ||
21 | }, | ||
22 | "url": { | 10 | "url": { |
23 | "type": "string", | 11 | "type": "string", |
24 | "format": "uri" | 12 | "format": "uri" |
@@ -40,62 +28,25 @@ | |||
40 | "type": "string", | 28 | "type": "string", |
41 | "enum": ["COL2ROW", "ROW2COL"] | 29 | "enum": ["COL2ROW", "ROW2COL"] |
42 | }, | 30 | }, |
43 | "debounce": { | 31 | "debounce": {"$ref": "qmk.definitions.v1#/unsigned_int"}, |
44 | "type": "number", | 32 | "height": {"$ref": "qmk.definitions.v1#/key_unit"}, |
45 | "min": 0, | 33 | "width": {"$ref": "qmk.definitions.v1#/key_unit"}, |
46 | "multipleOf": 1 | ||
47 | }, | ||
48 | "height": { | ||
49 | "type": "number", | ||
50 | "min": 0.25 | ||
51 | }, | ||
52 | "width": { | ||
53 | "type": "number", | ||
54 | "min": 0.25 | ||
55 | }, | ||
56 | "community_layouts": { | 34 | "community_layouts": { |
57 | "type": "array", | 35 | "type": "array", |
58 | "items": { | 36 | "items": {"$ref": "qmk.definitions.v1#/filename"} |
59 | "type": "string", | ||
60 | "minLength": 2, | ||
61 | "pattern": "^[0-9a-z_]*$" | ||
62 | } | ||
63 | }, | ||
64 | "features": { | ||
65 | "type": "object", | ||
66 | "additionalProperties": {"type": "boolean"} | ||
67 | }, | 37 | }, |
38 | "features": {"$ref": "qmk.definitions.v1#/boolean_array"}, | ||
68 | "indicators": { | 39 | "indicators": { |
69 | "type": "object", | 40 | "type": "object", |
70 | "properties": { | 41 | "properties": { |
71 | "caps_lock": { | 42 | "caps_lock": {"$ref": "qmk.definitions.v1#/mcu_pin"}, |
72 | "type": "string", | 43 | "num_lock": {"$ref": "qmk.definitions.v1#/mcu_pin"}, |
73 | "pattern": "^[A-K]\\d{1,2}$" | 44 | "scroll_lock": {"$ref": "qmk.definitions.v1#/mcu_pin"} |
74 | }, | ||
75 | "num_lock": { | ||
76 | "type": "string", | ||
77 | "pattern": "^[A-K]\\d{1,2}$" | ||
78 | }, | ||
79 | "scroll_lock": { | ||
80 | "type": "string", | ||
81 | "pattern": "^[A-K]\\d{1,2}$" | ||
82 | } | ||
83 | } | 45 | } |
84 | }, | 46 | }, |
85 | "layout_aliases": { | 47 | "layout_aliases": { |
86 | "type": "object", | 48 | "type": "object", |
87 | "additionalProperties": { | 49 | "additionalProperties": {"$ref": "qmk.definitions.v1#/layout_macro"} |
88 | "oneOf": [ | ||
89 | { | ||
90 | "type": "string", | ||
91 | "enum": ["LAYOUT", "LAYOUT_planck_1x2uC"] | ||
92 | }, | ||
93 | { | ||
94 | "type": "string", | ||
95 | "pattern": "^LAYOUT_[0-9a-z_]*$" | ||
96 | } | ||
97 | ] | ||
98 | } | ||
99 | }, | 50 | }, |
100 | "layouts": { | 51 | "layouts": { |
101 | "type": "object", | 52 | "type": "object", |
@@ -109,11 +60,7 @@ | |||
109 | "c_macro": { | 60 | "c_macro": { |
110 | "type": "boolean" | 61 | "type": "boolean" |
111 | }, | 62 | }, |
112 | "key_count": { | 63 | "key_count": {"$ref": "qmk.definitions.v1#/key_unit"}, |
113 | "type": "number", | ||
114 | "min": 0, | ||
115 | "multipleOf": 1 | ||
116 | }, | ||
117 | "layout": { | 64 | "layout": { |
118 | "type": "array", | 65 | "type": "array", |
119 | "items": { | 66 | "items": { |
@@ -131,34 +78,14 @@ | |||
131 | "multipleOf": 1 | 78 | "multipleOf": 1 |
132 | } | 79 | } |
133 | }, | 80 | }, |
134 | "h": { | 81 | "key_count": {"$ref": "qmk.definitions.v1#/key_unit"}, |
135 | "type": "number", | 82 | "r": {"$ref": "qmk.definitions.v1#/unsigned_decimal"}, |
136 | "min": 0.25 | 83 | "rx": {"$ref": "qmk.definitions.v1#/unsigned_decimal"}, |
137 | }, | 84 | "ry": {"$ref": "qmk.definitions.v1#/unsigned_decimal"}, |
138 | "r": { | 85 | "h": {"$ref": "qmk.definitions.v1#/key_unit"}, |
139 | "type": "number", | 86 | "w": {"$ref": "qmk.definitions.v1#/key_unit"}, |
140 | "min": 0 | 87 | "x": {"$ref": "qmk.definitions.v1#/key_unit"}, |
141 | }, | 88 | "y": {"$ref": "qmk.definitions.v1#/key_unit"} |
142 | "rx": { | ||
143 | "type": "number", | ||
144 | "min": 0 | ||
145 | }, | ||
146 | "ry": { | ||
147 | "type": "number", | ||
148 | "min": 0 | ||
149 | }, | ||
150 | "w": { | ||
151 | "type": "number", | ||
152 | "min": 0.25 | ||
153 | }, | ||
154 | "x": { | ||
155 | "type": "number", | ||
156 | "min": 0 | ||
157 | }, | ||
158 | "y": { | ||
159 | "type": "number", | ||
160 | "min": 0 | ||
161 | } | ||
162 | } | 89 | } |
163 | } | 90 | } |
164 | } | 91 | } |
@@ -171,73 +98,10 @@ | |||
171 | "properties": { | 98 | "properties": { |
172 | "direct": { | 99 | "direct": { |
173 | "type": "array", | 100 | "type": "array", |
174 | "items": { | 101 | "items": {$ref": "qmk.definitions.v1#/mcu_pin_array"} |
175 | "type": "array", | ||
176 | "items": { | ||
177 | "oneOf": [ | ||
178 | { | ||
179 | "type": "string", | ||
180 | "pattern": "^[A-K]\\d{1,2}$" | ||
181 | }, | ||
182 | { | ||
183 | "type": "string", | ||
184 | "pattern": "^LINE_PIN\\d{1,2}$" | ||
185 | }, | ||
186 | { | ||
187 | "type": "number", | ||
188 | "multipleOf": 1 | ||
189 | }, | ||
190 | { | ||
191 | "type": "null" | ||
192 | } | ||
193 | ] | ||
194 | } | ||
195 | } | ||
196 | }, | 102 | }, |
197 | "cols": { | 103 | "cols": {"$ref": "qmk.definitions.v1#/mcu_pin_array"}, |
198 | "type": "array", | 104 | "rows": {"$ref": "qmk.definitions.v1#/mcu_pin_array"} |
199 | "items": { | ||
200 | "oneOf": [ | ||
201 | { | ||
202 | "type": "string", | ||
203 | "pattern": "^[A-K]\\d{1,2}$" | ||
204 | }, | ||
205 | { | ||
206 | "type": "string", | ||
207 | "pattern": "^LINE_PIN\\d{1,2}$" | ||
208 | }, | ||
209 | { | ||
210 | "type": "number", | ||
211 | "multipleOf": 1 | ||
212 | }, | ||
213 | { | ||
214 | "type": "null" | ||
215 | } | ||
216 | ] | ||
217 | } | ||
218 | }, | ||
219 | "rows": { | ||
220 | "type": "array", | ||
221 | "items": { | ||
222 | "oneOf": [ | ||
223 | { | ||
224 | "type": "string", | ||
225 | "pattern": "^[A-K]\\d{1,2}$" | ||
226 | }, | ||
227 | { | ||
228 | "type": "string", | ||
229 | "pattern": "^LINE_PIN\\d{1,2}$" | ||
230 | }, | ||
231 | { | ||
232 | "type": "number", | ||
233 | "multipleOf": 1 | ||
234 | }, | ||
235 | { | ||
236 | "type": "null" | ||
237 | } | ||
238 | ] | ||
239 | } | ||
240 | } | ||
241 | } | 105 | } |
242 | }, | 106 | }, |
243 | "rgblight": { | 107 | "rgblight": { |
@@ -250,47 +114,19 @@ | |||
250 | "type": "boolean" | 114 | "type": "boolean" |
251 | } | 115 | } |
252 | }, | 116 | }, |
253 | "brightness_steps": { | 117 | "brightness_steps": {"$ref": "qmk.definitions.v1#/unsigned_int"}, |
254 | "type": "number", | 118 | "hue_steps": {"$ref": "qmk.definitions.v1#/unsigned_int"}, |
255 | "min": 0, | 119 | "led_count": {"$ref": "qmk.definitions.v1#/unsigned_int"}, |
256 | "multipleOf": 1 | 120 | "max_brightness": {"$ref": "qmk.definitions.v1#/unsigned_int_8"}, |
257 | }, | 121 | "pin": {"$ref": "qmk.definitions.v1#/mcu_pin"}, |
258 | "hue_steps": { | 122 | "saturation_steps": {"$ref": "qmk.definitions.v1#/unsigned_int"}, |
259 | "type": "number", | ||
260 | "min": 0, | ||
261 | "multipleOf": 1 | ||
262 | }, | ||
263 | "led_count": { | ||
264 | "type": "number", | ||
265 | "min": 0, | ||
266 | "multipleOf": 1 | ||
267 | }, | ||
268 | "max_brightness": { | ||
269 | "type": "number", | ||
270 | "min": 0, | ||
271 | "max": 255, | ||
272 | "multipleOf": 1 | ||
273 | }, | ||
274 | "pin": { | ||
275 | "type": "string", | ||
276 | "pattern": "^([A-K]\\d{1,2}|LINE_PIN\\d{1,2})$" | ||
277 | }, | ||
278 | "saturation_steps": { | ||
279 | "type": "number", | ||
280 | "min": 0, | ||
281 | "multipleOf": 1 | ||
282 | }, | ||
283 | "sleep": {"type": "boolean"}, | 123 | "sleep": {"type": "boolean"}, |
284 | "split": {"type": "boolean"}, | 124 | "split": {"type": "boolean"}, |
285 | "split_count": { | 125 | "split_count": { |
286 | "type": "array", | 126 | "type": "array", |
287 | "minLength": 2, | 127 | "minLength": 2, |
288 | "maxLength": 2, | 128 | "maxLength": 2, |
289 | "items": { | 129 | "items": {"$ref": "qmk.definitions.v1#/unsigned_int"} |
290 | "type": "number", | ||
291 | "min": 0, | ||
292 | "multipleOf": 1 | ||
293 | } | ||
294 | } | 130 | } |
295 | } | 131 | } |
296 | }, | 132 | }, |
@@ -298,40 +134,19 @@ | |||
298 | "type": "object", | 134 | "type": "object", |
299 | "additionalProperties": false, | 135 | "additionalProperties": false, |
300 | "properties": { | 136 | "properties": { |
301 | "device_ver": { | 137 | "device_ver": {"$ref": "qmk.definitions.v1#/hex_number_4d"}, |
302 | "type": "string", | 138 | "pid": {"$ref": "qmk.definitions.v1#/hex_number_4d"}, |
303 | "pattern": "^[0-9A-F]x[0-9A-F][0-9A-F][0-9A-F][0-9A-F]" | 139 | "vid": {"$ref": "qmk.definitions.v1#/hex_number_4d"} |
304 | }, | ||
305 | "pid": { | ||
306 | "type": "string", | ||
307 | "pattern": "^[0-9A-F]x[0-9A-F][0-9A-F][0-9A-F][0-9A-F]" | ||
308 | }, | ||
309 | "vid": { | ||
310 | "type": "string", | ||
311 | "pattern": "^[0-9A-F]x[0-9A-F][0-9A-F][0-9A-F][0-9A-F]" | ||
312 | } | ||
313 | } | 140 | } |
314 | }, | 141 | }, |
315 | "qmk_lufa_bootloader": { | 142 | "qmk_lufa_bootloader": { |
316 | "type": "object", | 143 | "type": "object", |
317 | "additionalProperties": false, | 144 | "additionalProperties": false, |
318 | "properties": { | 145 | "properties": { |
319 | "esc_output": { | 146 | "esc_output": {"$ref": "qmk.definitions.v1#/mcu_pin"}, |
320 | "type": "string", | 147 | "esc_input": {"$ref": "qmk.definitions.v1#/mcu_pin"}, |
321 | "pattern": "^[A-K]\\d{1,2}$" | 148 | "led": {"$ref": "qmk.definitions.v1#/mcu_pin"}, |
322 | }, | 149 | "speaker": {"$ref": "qmk.definitions.v1#/mcu_pin"} |
323 | "esc_input": { | ||
324 | "type": "string", | ||
325 | "pattern": "^[A-K]\\d{1,2}$" | ||
326 | }, | ||
327 | "led": { | ||
328 | "type": "string", | ||
329 | "pattern": "^[A-K]\\d{1,2}$" | ||
330 | }, | ||
331 | "speaker": { | ||
332 | "type": "string", | ||
333 | "pattern": "^[A-K]\\d{1,2}$" | ||
334 | } | ||
335 | } | 150 | } |
336 | } | 151 | } |
337 | } | 152 | } |