From 27eb9c664b505ed850cc48c28d43b563c1430110 Mon Sep 17 00:00:00 2001 From: bruno-f-cruz <7049351+bruno-f-cruz@users.noreply.github.com> Date: Mon, 6 Oct 2025 19:19:28 -0700 Subject: [PATCH 1/3] Allow multiple hardware targets in device schema --- schema/device.json | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/schema/device.json b/schema/device.json index 2fe833d..7be067c 100644 --- a/schema/device.json +++ b/schema/device.json @@ -19,9 +19,12 @@ "type": "string" }, "hardwareTargets": { - "description": "Specifies the version of the device hardware.", - "pattern": "^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)$", - "type": "string" + "description": "Specifies the version of the hardware targets.", + "type": "array", + "items": { + "type": "string", + "pattern": "^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)$" + } }, "registers": { "additionalProperties": { From 577e371e6138ce710bc71e22bd4d391555343cc8 Mon Sep 17 00:00:00 2001 From: glopesdev Date: Thu, 19 Feb 2026 08:28:29 +0000 Subject: [PATCH 2/3] Update JSON schema spec to version 2019-09 Following more recent versions of the spec, the $defs keyword should be used for grouping reused validations. --- schema/core.json | 2 +- schema/device.json | 2 +- schema/ios.json | 12 +++++------ schema/registers.json | 46 +++++++++++++++++++++---------------------- 4 files changed, 31 insertions(+), 31 deletions(-) diff --git a/schema/core.json b/schema/core.json index bb8d2cc..77e87c5 100644 --- a/schema/core.json +++ b/schema/core.json @@ -1,5 +1,5 @@ { - "$schema": "https://json-schema.org/draft-07/schema", + "$schema": "https://json-schema.org/draft/2019-09/schema", "$id": "https://harp-tech.org/draft-03/schema/core.json", "type": "object", "allOf": [ diff --git a/schema/device.json b/schema/device.json index 7be067c..22d2a81 100644 --- a/schema/device.json +++ b/schema/device.json @@ -1,5 +1,5 @@ { - "$schema": "https://json-schema.org/draft-07/schema", + "$schema": "https://json-schema.org/draft/2019-09/schema", "$id": "https://harp-tech.org/draft-03/schema/device.json", "type": "object", "allOf": [ diff --git a/schema/ios.json b/schema/ios.json index e47515c..41d9aea 100644 --- a/schema/ios.json +++ b/schema/ios.json @@ -1,15 +1,15 @@ { - "$schema": "https://json-schema.org/draft-07/schema", + "$schema": "https://json-schema.org/draft/2019-09/schema", "$id": "https://harp-tech.org/draft-03/schema/ios.json", "type": "object", "description": "Specifies the IO pin configuration used to automatically generate firmware.", "additionalProperties": { "oneOf": [ - { "$ref": "#/definitions/inputPin" }, - { "$ref": "#/definitions/outputPin" } + { "$ref": "#/$defs/inputPin" }, + { "$ref": "#/$defs/outputPin" } ] }, - "definitions": { + "$defs": { "portPin": { "type": "object", "properties": { @@ -34,7 +34,7 @@ "required": ["port", "pinNumber", "direction"] }, "inputPin": { - "allOf": [{ "$ref": "#/definitions/portPin" }], + "allOf": [{ "$ref": "#/$defs/portPin" }], "properties": { "direction": { "enum": ["input"] @@ -62,7 +62,7 @@ } }, "outputPin": { - "allOf": [{ "$ref": "#/definitions/portPin" }], + "allOf": [{ "$ref": "#/$defs/portPin" }], "properties": { "direction": { "enum": ["output"] diff --git a/schema/registers.json b/schema/registers.json index ad1913f..3928485 100644 --- a/schema/registers.json +++ b/schema/registers.json @@ -1,26 +1,26 @@ { - "$schema": "https://json-schema.org/draft-07/schema", + "$schema": "https://json-schema.org/draft/2019-09/schema", "$id": "https://harp-tech.org/draft-03/schema/registers.json", "type": "object", "properties": { "registers": { "type": "object", "description": "Specifies the collection of registers implementing the device function.", - "additionalProperties": { "$ref": "#/definitions/register" } + "additionalProperties": { "$ref": "#/$defs/register" } }, "bitMasks": { "type": "object", "description": "Specifies the collection of masks available to be used with the different registers.", - "additionalProperties": { "$ref": "#/definitions/bitMask" } + "additionalProperties": { "$ref": "#/$defs/bitMask" } }, "groupMasks": { "type": "object", "description": "Specifies the collection of group masks available to be used with the different registers.", - "additionalProperties": { "$ref": "#/definitions/groupMask" } + "additionalProperties": { "$ref": "#/$defs/groupMask" } } }, "required": ["registers"], - "definitions": { + "$defs": { "type": { "description": "Specifies the type of the register payload.", "type": "string", @@ -60,7 +60,7 @@ }, "bits": { "type": "object", - "additionalProperties": { "$ref": "#/definitions/maskValue" } + "additionalProperties": { "$ref": "#/$defs/maskValue" } } }, "required": ["bits"] @@ -75,7 +75,7 @@ }, "values": { "type": "object", - "additionalProperties": { "$ref": "#/definitions/maskValue" } + "additionalProperties": { "$ref": "#/$defs/maskValue" } } }, "required": ["values"] @@ -120,12 +120,12 @@ "description": "Specifies a summary description of the payload member.", "type": "string" }, - "minValue": { "$ref": "#/definitions/minValue" }, - "maxValue": { "$ref": "#/definitions/maxValue" }, - "defaultValue": { "$ref": "#/definitions/defaultValue" }, - "maskType": { "$ref": "#/definitions/maskType" }, - "interfaceType": { "$ref": "#/definitions/interfaceType" }, - "converter": { "$ref": "#/definitions/converter" } + "minValue": { "$ref": "#/$defs/minValue" }, + "maxValue": { "$ref": "#/$defs/maxValue" }, + "defaultValue": { "$ref": "#/$defs/defaultValue" }, + "maskType": { "$ref": "#/$defs/maskType" }, + "interfaceType": { "$ref": "#/$defs/interfaceType" }, + "converter": { "$ref": "#/$defs/converter" } } }, "register": { @@ -136,7 +136,7 @@ "type": "integer", "maximum": 255 }, - "type": { "$ref": "#/definitions/type" }, + "type": { "$ref": "#/$defs/type" }, "length": { "description": "Specifies the length of the register payload.", "type": "integer", @@ -145,10 +145,10 @@ "access": { "description": "Specifies the expected use of the register.", "oneOf": [ - { "$ref": "#/definitions/access" }, + { "$ref": "#/$defs/access" }, { "type": "array", - "items": { "$ref": "#/definitions/access" }, + "items": { "$ref": "#/$defs/access" }, "uniqueItems": true, "minItems": 1, "maxItems": 3 @@ -159,10 +159,10 @@ "description": "Specifies a summary description of the register function.", "type": "string" }, - "minValue": { "$ref": "#/definitions/minValue" }, - "maxValue": { "$ref": "#/definitions/maxValue" }, - "defaultValue": { "$ref": "#/definitions/defaultValue" }, - "maskType": { "$ref": "#/definitions/maskType" }, + "minValue": { "$ref": "#/$defs/minValue" }, + "maxValue": { "$ref": "#/$defs/maxValue" }, + "defaultValue": { "$ref": "#/$defs/defaultValue" }, + "maskType": { "$ref": "#/$defs/maskType" }, "visibility": { "description": "Specifies whether the register function is exposed in the high-level interface.", "type": "string", @@ -174,10 +174,10 @@ }, "payloadSpec": { "type": "object", - "additionalProperties": { "$ref": "#/definitions/payloadMember" } + "additionalProperties": { "$ref": "#/$defs/payloadMember" } }, - "interfaceType": { "$ref": "#/definitions/interfaceType" }, - "converter": { "$ref": "#/definitions/converter" } + "interfaceType": { "$ref": "#/$defs/interfaceType" }, + "converter": { "$ref": "#/$defs/converter" } }, "required": ["address", "access", "type"] } From febd181c593c08b7eab6eefb8458ea878a29542a Mon Sep 17 00:00:00 2001 From: glopesdev Date: Thu, 19 Feb 2026 09:24:06 +0000 Subject: [PATCH 3/3] Allow multiple hardware targets in device schema A common definition of version is used to avoid redeclaration of the regex pattern across all version strings. --- schema/core.json | 11 ++++++++--- schema/device.json | 13 ++++++++----- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/schema/core.json b/schema/core.json index 77e87c5..f89260b 100644 --- a/schema/core.json +++ b/schema/core.json @@ -7,12 +7,17 @@ "properties": { "protocolVersion": { "description": "Specifies the version of the device protocol.", - "pattern": "^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)$", - "type": "string" + "$ref": "#/$defs/version" } }, "required": ["protocolVersion"] }, { "$ref": "registers.json" } - ] + ], + "$defs": { + "version": { + "type": "string", + "pattern": "^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)$" + } + } } \ No newline at end of file diff --git a/schema/device.json b/schema/device.json index 22d2a81..9eaee64 100644 --- a/schema/device.json +++ b/schema/device.json @@ -15,16 +15,19 @@ }, "firmwareVersion": { "description": "Specifies the version of the device firmware.", - "pattern": "^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)$", - "type": "string" + "$ref": "core.json#/$defs/version" }, "hardwareTargets": { "description": "Specifies the version of the hardware targets.", + "oneOf": [ + { "$ref": "core.json#/$defs/version" }, + { "type": "array", - "items": { - "type": "string", - "pattern": "^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)$" + "items": { "$ref": "core.json#/$defs/version" }, + "uniqueItems": true, + "minItems": 1 } + ] }, "registers": { "additionalProperties": {