Additional schema fixes (#17414)
parent
7b3ee1db8c
commit
17ec1650fd
|
@ -1,5 +1,5 @@
|
||||||
{
|
{
|
||||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
"$schema": "https://json-schema.org/draft/2020-12/schema#",
|
||||||
"$id": "qmk.definitions.v1",
|
"$id": "qmk.definitions.v1",
|
||||||
"title": "Common definitions used across QMK's jsonschemas.",
|
"title": "Common definitions used across QMK's jsonschemas.",
|
||||||
"type": "object",
|
"type": "object",
|
||||||
|
@ -65,8 +65,7 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"key_unit": {
|
"key_unit": {
|
||||||
"type": "number",
|
"type": "number"
|
||||||
"min": 0.25
|
|
||||||
},
|
},
|
||||||
"keyboard": {
|
"keyboard": {
|
||||||
"oneOf": [
|
"oneOf": [
|
||||||
|
@ -103,8 +102,7 @@
|
||||||
"pattern": "^LINE_PIN\\d{1,2}$"
|
"pattern": "^LINE_PIN\\d{1,2}$"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "number",
|
"type": "integer"
|
||||||
"multipleOf": 1
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "null"
|
"type": "null"
|
||||||
|
@ -115,14 +113,12 @@
|
||||||
"type": "number"
|
"type": "number"
|
||||||
},
|
},
|
||||||
"signed_int": {
|
"signed_int": {
|
||||||
"type": "number",
|
"type": "integer"
|
||||||
"multipleOf": 1
|
|
||||||
},
|
},
|
||||||
"signed_int_8": {
|
"signed_int_8": {
|
||||||
"type": "number",
|
"type": "integer",
|
||||||
"min": -127,
|
"minimum": -127,
|
||||||
"max": 127,
|
"maximum": 127
|
||||||
"multipleOf": 1
|
|
||||||
},
|
},
|
||||||
"string_array": {
|
"string_array": {
|
||||||
"type": "array",
|
"type": "array",
|
||||||
|
@ -138,23 +134,20 @@
|
||||||
},
|
},
|
||||||
"unsigned_decimal": {
|
"unsigned_decimal": {
|
||||||
"type": "number",
|
"type": "number",
|
||||||
"min": 0
|
"minimum": 0
|
||||||
},
|
},
|
||||||
"unsigned_int": {
|
"unsigned_int": {
|
||||||
"type": "number",
|
"type": "integer",
|
||||||
"min": 0,
|
"minimum": 0
|
||||||
"multipleOf": 1
|
|
||||||
},
|
},
|
||||||
"unsigned_int_8": {
|
"unsigned_int_8": {
|
||||||
"type": "number",
|
"type": "integer",
|
||||||
"min": 0,
|
"minimum": 0,
|
||||||
"max": 255,
|
"maximum": 255
|
||||||
"multipleOf": 1
|
|
||||||
},
|
},
|
||||||
"bit": {
|
"bit": {
|
||||||
"type": "number",
|
"type": "integer",
|
||||||
"min": 0,
|
"minimum": 0,
|
||||||
"max": 1,
|
"maximum": 1
|
||||||
"multipleOf": 1
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
{
|
{
|
||||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
"$schema": "https://json-schema.org/draft/2020-12/schema#",
|
||||||
"$id": "qmk.keyboard.v1",
|
"$id": "qmk.keyboard.v1",
|
||||||
"title": "Keyboard Information",
|
"title": "Keyboard Information",
|
||||||
"type": "object",
|
"type": "object",
|
||||||
|
@ -40,10 +40,9 @@
|
||||||
"breathing": {"type": "boolean"},
|
"breathing": {"type": "boolean"},
|
||||||
"breathing_period": {"$ref": "qmk.definitions.v1#/unsigned_int_8"},
|
"breathing_period": {"$ref": "qmk.definitions.v1#/unsigned_int_8"},
|
||||||
"levels": {
|
"levels": {
|
||||||
"type": "number",
|
"type": "integer",
|
||||||
"minimum": 1,
|
"minimum": 1,
|
||||||
"maximum": 31,
|
"maximum": 31
|
||||||
"multipleOf": 1
|
|
||||||
},
|
},
|
||||||
"pin": {"$ref": "qmk.definitions.v1#/mcu_pin"},
|
"pin": {"$ref": "qmk.definitions.v1#/mcu_pin"},
|
||||||
"on_state": {"$ref": "qmk.definitions.v1#/bit"}
|
"on_state": {"$ref": "qmk.definitions.v1#/bit"}
|
||||||
|
@ -158,12 +157,11 @@
|
||||||
"minItems": 2,
|
"minItems": 2,
|
||||||
"maxItems": 2,
|
"maxItems": 2,
|
||||||
"items": {
|
"items": {
|
||||||
"type": "number",
|
"type": "integer",
|
||||||
"minimum": 0,
|
"minimum": 0
|
||||||
"multipleOf": 1
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"r": {"$ref": "qmk.definitions.v1#/unsigned_decimal"},
|
"r": {"$ref": "qmk.definitions.v1#/signed_decimal"},
|
||||||
"rx": {"$ref": "qmk.definitions.v1#/unsigned_decimal"},
|
"rx": {"$ref": "qmk.definitions.v1#/unsigned_decimal"},
|
||||||
"ry": {"$ref": "qmk.definitions.v1#/unsigned_decimal"},
|
"ry": {"$ref": "qmk.definitions.v1#/unsigned_decimal"},
|
||||||
"h": {"$ref": "qmk.definitions.v1#/key_unit"},
|
"h": {"$ref": "qmk.definitions.v1#/key_unit"},
|
||||||
|
@ -234,14 +232,13 @@
|
||||||
"minItems": 2,
|
"minItems": 2,
|
||||||
"maxItems": 2,
|
"maxItems": 2,
|
||||||
"items": {
|
"items": {
|
||||||
"type": "number",
|
"type": "integer",
|
||||||
"minimum": 0,
|
"minimum": 0
|
||||||
"multipleOf": 1
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"x": {"$ref": "qmk.definitions.v1#/key_unit"},
|
"x": {"$ref": "qmk.definitions.v1#/key_unit"},
|
||||||
"y": {"$ref": "qmk.definitions.v1#/key_unit"},
|
"y": {"$ref": "qmk.definitions.v1#/key_unit"},
|
||||||
"flags": {"$ref": "qmk.definitions.v1#/unsigned_decimal"}
|
"flags": {"$ref": "qmk.definitions.v1#/unsigned_int_8"}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -262,14 +259,13 @@
|
||||||
"minItems": 2,
|
"minItems": 2,
|
||||||
"maxItems": 2,
|
"maxItems": 2,
|
||||||
"items": {
|
"items": {
|
||||||
"type": "number",
|
"type": "integer",
|
||||||
"minimum": 0,
|
"minimum": 0
|
||||||
"multipleOf": 1
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"x": {"$ref": "qmk.definitions.v1#/key_unit"},
|
"x": {"$ref": "qmk.definitions.v1#/key_unit"},
|
||||||
"y": {"$ref": "qmk.definitions.v1#/key_unit"},
|
"y": {"$ref": "qmk.definitions.v1#/key_unit"},
|
||||||
"flags": {"$ref": "qmk.definitions.v1#/unsigned_decimal"}
|
"flags": {"$ref": "qmk.definitions.v1#/unsigned_int_8"}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -294,10 +290,9 @@
|
||||||
"blink": {"type": "boolean"},
|
"blink": {"type": "boolean"},
|
||||||
"enabled": {"type": "boolean"},
|
"enabled": {"type": "boolean"},
|
||||||
"max": {
|
"max": {
|
||||||
"type": "number",
|
"type": "integer",
|
||||||
"minimum": 1,
|
"minimum": 1,
|
||||||
"maximum": 32,
|
"maximum": 32
|
||||||
"multipleOf": 1
|
|
||||||
},
|
},
|
||||||
"override_rgb": {"type": "boolean"}
|
"override_rgb": {"type": "boolean"}
|
||||||
}
|
}
|
||||||
|
@ -333,9 +328,8 @@
|
||||||
"minItems": 2,
|
"minItems": 2,
|
||||||
"maxItems": 2,
|
"maxItems": 2,
|
||||||
"items": {
|
"items": {
|
||||||
"type": "number",
|
"type": "integer",
|
||||||
"minimum": 0,
|
"minimum": 0
|
||||||
"multipleOf": 1
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -375,10 +369,9 @@
|
||||||
},
|
},
|
||||||
"soft_serial_pin": {"$ref": "qmk.definitions.v1#/mcu_pin"},
|
"soft_serial_pin": {"$ref": "qmk.definitions.v1#/mcu_pin"},
|
||||||
"soft_serial_speed": {
|
"soft_serial_speed": {
|
||||||
"type": "number",
|
"type": "integer",
|
||||||
"minimum": 0,
|
"minimum": 0,
|
||||||
"maximum": 5,
|
"maximum": 5
|
||||||
"multipleOf": 1
|
|
||||||
},
|
},
|
||||||
"transport": {
|
"transport": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
|
@ -432,7 +425,7 @@
|
||||||
"force_nkro": {"type": "boolean"},
|
"force_nkro": {"type": "boolean"},
|
||||||
"pid": {"$ref": "qmk.definitions.v1#/hex_number_4d"},
|
"pid": {"$ref": "qmk.definitions.v1#/hex_number_4d"},
|
||||||
"vid": {"$ref": "qmk.definitions.v1#/hex_number_4d"},
|
"vid": {"$ref": "qmk.definitions.v1#/hex_number_4d"},
|
||||||
"max_power": {"$ref": "qmk.definitions.v1#/unsigned_int_8"},
|
"max_power": {"$ref": "qmk.definitions.v1#/unsigned_int"},
|
||||||
"no_startup_check": {"type": "boolean"},
|
"no_startup_check": {"type": "boolean"},
|
||||||
"polling_interval": {"$ref": "qmk.definitions.v1#/unsigned_int_8"},
|
"polling_interval": {"$ref": "qmk.definitions.v1#/unsigned_int_8"},
|
||||||
"shared_endpoint": {
|
"shared_endpoint": {
|
||||||
|
@ -443,7 +436,7 @@
|
||||||
"mouse": {"type": "boolean"}
|
"mouse": {"type": "boolean"}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"suspend_wakeup_delay": {"$ref": "qmk.definitions.v1#/unsigned_int_8"},
|
"suspend_wakeup_delay": {"$ref": "qmk.definitions.v1#/unsigned_int"},
|
||||||
"wait_for": {"type": "boolean"},
|
"wait_for": {"type": "boolean"},
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -452,8 +445,8 @@
|
||||||
"additionalProperties": false,
|
"additionalProperties": false,
|
||||||
"properties": {
|
"properties": {
|
||||||
"keys_per_scan": {"$ref": "qmk.definitions.v1#/unsigned_int_8"},
|
"keys_per_scan": {"$ref": "qmk.definitions.v1#/unsigned_int_8"},
|
||||||
"tap_keycode_delay": {"$ref": "qmk.definitions.v1#/unsigned_int_8"},
|
"tap_keycode_delay": {"$ref": "qmk.definitions.v1#/unsigned_int"},
|
||||||
"tap_capslock_delay": {"$ref": "qmk.definitions.v1#/unsigned_int_8"},
|
"tap_capslock_delay": {"$ref": "qmk.definitions.v1#/unsigned_int"},
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"qmk_lufa_bootloader": {
|
"qmk_lufa_bootloader": {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
{
|
{
|
||||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
"$schema": "https://json-schema.org/draft/2020-12/schema#",
|
||||||
"$id": "qmk.keymap.v1",
|
"$id": "qmk.keymap.v1",
|
||||||
"title": "Keymap Information",
|
"title": "Keymap Information",
|
||||||
"type": "object",
|
"type": "object",
|
||||||
|
@ -50,8 +50,7 @@
|
||||||
},
|
},
|
||||||
"config": {"$ref": "qmk.keyboard.v1"},
|
"config": {"$ref": "qmk.keyboard.v1"},
|
||||||
"notes": {
|
"notes": {
|
||||||
"type": "string",
|
"type": "string"
|
||||||
"description": "asdf"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"required": [
|
"required": [
|
||||||
|
|
|
@ -5,7 +5,7 @@ Compile an info.json for a particular keyboard and pretty-print it.
|
||||||
import json
|
import json
|
||||||
|
|
||||||
from argcomplete.completers import FilesCompleter
|
from argcomplete.completers import FilesCompleter
|
||||||
from jsonschema import Draft7Validator, RefResolver, validators
|
from jsonschema import Draft202012Validator, RefResolver, validators
|
||||||
from milc import cli
|
from milc import cli
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ from qmk.path import is_keyboard, normpath
|
||||||
|
|
||||||
|
|
||||||
def pruning_validator(validator_class):
|
def pruning_validator(validator_class):
|
||||||
"""Extends Draft7Validator to remove properties that aren't specified in the schema.
|
"""Extends Draft202012Validator to remove properties that aren't specified in the schema.
|
||||||
"""
|
"""
|
||||||
validate_properties = validator_class.VALIDATORS["properties"]
|
validate_properties = validator_class.VALIDATORS["properties"]
|
||||||
|
|
||||||
|
@ -37,10 +37,10 @@ def strip_info_json(kb_info_json):
|
||||||
"""Remove the API-only properties from the info.json.
|
"""Remove the API-only properties from the info.json.
|
||||||
"""
|
"""
|
||||||
schema_store = compile_schema_store()
|
schema_store = compile_schema_store()
|
||||||
pruning_draft_7_validator = pruning_validator(Draft7Validator)
|
pruning_draft_validator = pruning_validator(Draft202012Validator)
|
||||||
schema = schema_store['qmk.keyboard.v1']
|
schema = schema_store['qmk.keyboard.v1']
|
||||||
resolver = RefResolver.from_schema(schema_store['qmk.keyboard.v1'], store=schema_store)
|
resolver = RefResolver.from_schema(schema_store['qmk.keyboard.v1'], store=schema_store)
|
||||||
validator = pruning_draft_7_validator(schema, resolver=resolver).validate
|
validator = pruning_draft_validator(schema, resolver=resolver).validate
|
||||||
|
|
||||||
return validator(kb_info_json)
|
return validator(kb_info_json)
|
||||||
|
|
||||||
|
|
|
@ -68,11 +68,7 @@ def create_validator(schema):
|
||||||
schema_store = compile_schema_store()
|
schema_store = compile_schema_store()
|
||||||
resolver = jsonschema.RefResolver.from_schema(schema_store[schema], store=schema_store)
|
resolver = jsonschema.RefResolver.from_schema(schema_store[schema], store=schema_store)
|
||||||
|
|
||||||
# TODO: Remove this after the jsonschema>=4 requirement had time to reach users
|
return jsonschema.Draft202012Validator(schema_store[schema], resolver=resolver).validate
|
||||||
try:
|
|
||||||
return jsonschema.Draft202012Validator(schema_store[schema], resolver=resolver).validate
|
|
||||||
except AttributeError:
|
|
||||||
return jsonschema.Draft7Validator(schema_store[schema], resolver=resolver).validate
|
|
||||||
|
|
||||||
|
|
||||||
def validate(data, schema):
|
def validate(data, schema):
|
||||||
|
|
Loading…
Reference in New Issue