Skip to content

Commit

Permalink
Optimize our jsonschema by using refs (#13271)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
skullydazed authored Jun 25, 2021
1 parent 9d4412c commit b908275
Show file tree
Hide file tree
Showing 9 changed files with 351 additions and 310 deletions.
44 changes: 16 additions & 28 deletions data/schemas/api_keyboard.jsonschema
Original file line number Diff line number Diff line change
@@ -1,34 +1,22 @@
{
"$id": "qmk.api.keyboard.v1",
"allOf": [
{ "$ref": "qmk.keyboard.v1" },
{"$ref": "qmk.keyboard.v1"},
{
"$id": "qmk.api.keyboard.v1",
"keymaps": {
"type": "string"
},
"parse_errors": {
"type": "array",
"items": {
"type": "string"
}
},
"parse_warnings": {
"type": "array",
"items": {
"type": "string"
}
},
"processor_type": {
"type": "string"
},
"protocol": {
"type": "string"
},
"keyboard_folder": {
"type": "string"
},
"platform": {
"type": "string"
"properties": {
"keymaps": {
"type": "object",
"properties": {
"url": {"type": "string"}
}

},
"parse_errors": {"$ref": "qmk.definitions.v1#/string_array"},
"parse_warnings": {"$ref": "qmk.definitions.v1#/string_array"},
"processor_type": {"type": "string"},
"protocol": {"type": "string"},
"keyboard_folder": {"type": "string"},
"platform": {"type": "string"}
}
}
]
Expand Down
107 changes: 107 additions & 0 deletions data/schemas/definitions.jsonschema
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "qmk.definitions.v1",
"title": "Common definitions used across QMK's jsonschemas.",
"type": "object",
"boolean_array": {
"type": "object",
"additionalProperties": {"type": "boolean"}
},
"filename": {
"type": "string",
"minLength": 1,
"pattern": "^[0-9a-z_]*$"
},
"hex_number_2d": {
"type": "string",
"pattern": "^0x[0-9A-F]{2}$"
},
"hex_number_4d": {
"type": "string",
"pattern": "^0x[0-9A-F]{4}$"
},
"text_identifier": {
"type": "string",
"minLength": 1,
"maxLength": 250
},
"layout_macro": {
"oneOf": [
{
"type": "string",
"enum": ["LAYOUT", "LAYOUT_planck_1x2uC"]
},
{
"type": "string",
"pattern": "^LAYOUT_[0-9a-z_]*$"
}
]
},
"key_unit": {
"type": "number",
"min": 0.25
},
"mcu_pin_array": {
"type": "array",
"items": {"$ref": "#/mcu_pin"}
},
"mcu_pin": {
"oneOf": [
{
"type": "string",
"pattern": "^[A-K]\\d{1,2}$"
},
{
"type": "string",
"pattern": "^LINE_PIN\\d{1,2}$"
},
{
"type": "number",
"multipleOf": 1
},
{
"type": "null"
}
]
},
"signed_decimal": {
"type": "number"
},
"signed_int": {
"type": "number",
"multipleOf": 1
}
"signed_int_8": {
"type": "number",
"min": -127,
"max": 127,
"multipleOf": 1
}
"string_array": {
"type": "array",
"items": {
"type": "string"
}
},
"string_object": {
"type": "object",
"additionalProperties": {
"type": "string"
}
},
"unsigned_decimal": {
"type": "number",
"min": 0
},
"unsigned_int": {
"type": "number",
"min": 0,
"multipleOf": 1
}
"unsigned_int_8": {
"type": "number",
"min": 0,
"max": 255,
"multipleOf": 1
}
}
Loading

0 comments on commit b908275

Please sign in to comment.