diff --git a/hk.pkl b/hk.pkl index eeb5ef9fcb..a3f5b81981 100644 --- a/hk.pkl +++ b/hk.pkl @@ -81,7 +81,8 @@ fi } ["schema"] { glob = List("schema/**/*.json") - check = "ajv compile -s schema/mise.json --spec=draft2019 --strict-schema=true && ajv compile -s schema/mise-task.json --spec=draft2019 --strict-schema=true && ajv compile -s schema/mise.plugin.json --spec=draft2020 --strict-schema=true && ajv compile -s schema/mise-registry-tool.json --spec=draft7 --strict-schema=true" + stdin = "{{ files_list | join(sep='\u{0}') }}" + check = "xargs -0 -I {} ajv compile -s {} --spec=draft2020 --strict-types=true --strict-tuples=true" } } diff --git a/schema/mise-registry-tool.json b/schema/mise-registry-tool.json index 37a36c5b98..f6948403fc 100644 --- a/schema/mise-registry-tool.json +++ b/schema/mise-registry-tool.json @@ -1,5 +1,5 @@ { - "$schema": "http://json-schema.org/draft-07/schema#", + "$schema": "https://json-schema.org/draft/2020-12/schema", "$id": "https://mise.en.dev/schema/mise-registry-tool.json", "title": "mise registry tool schema", "description": "Schema for individual tool files in the mise registry", @@ -56,13 +56,13 @@ "type": "object", "description": "Platform-specific configuration", "additionalProperties": { - "type": ["string", "boolean"] + "oneOf": [{ "type": "string" }, { "type": "boolean" }] } } } }, "additionalProperties": { - "type": ["string", "boolean"] + "oneOf": [{ "type": "string" }, { "type": "boolean" }] } } }, diff --git a/schema/mise-settings.json b/schema/mise-settings.json index d04cbb7c82..46cb624387 100644 --- a/schema/mise-settings.json +++ b/schema/mise-settings.json @@ -1,5 +1,5 @@ { - "$schema": "http://json-schema.org/draft-07/schema#", + "$schema": "https://json-schema.org/draft/2020-12/schema", "$id": "https://mise.en.dev/schema/mise-settings.json", "title": "Mise Settings Schema", "description": "JSON schema for mise settings.toml configuration file", @@ -84,9 +84,15 @@ "properties": { "value": { "oneOf": [ - { "type": "string" }, - { "type": "boolean" }, - { "type": "integer" } + { + "type": "string" + }, + { + "type": "boolean" + }, + { + "type": "integer" + } ], "description": "The enum value" }, diff --git a/schema/mise-task.json b/schema/mise-task.json index 1706638e30..7ef7240a2d 100644 --- a/schema/mise-task.json +++ b/schema/mise-task.json @@ -1,6 +1,6 @@ { "$id": "https://mise.en.dev/schema/mise-task.json", - "$schema": "https://json-schema.org/draft/2019-09/schema#", + "$schema": "https://json-schema.org/draft/2020-12/schema", "title": "mise-task-schema", "type": "object", "$defs": { diff --git a/schema/mise.json b/schema/mise.json index 53d1b0a228..ebbe472dde 100644 --- a/schema/mise.json +++ b/schema/mise.json @@ -1,6 +1,6 @@ { "$id": "https://mise.en.dev/schema/mise.json", - "$schema": "https://json-schema.org/draft/2019-09/schema#", + "$schema": "https://json-schema.org/draft/2020-12/schema", "title": "mise", "type": "object", "$defs": { @@ -1324,8 +1324,15 @@ "uv_venv_auto": { "default": false, "description": "Integrate with uv to manage project venvs when uv.lock is present.", - "type": ["boolean", "string"], - "enum": [false, "source", "create|source", true] + "enum": [false, "source", "create|source", true], + "oneOf": [ + { + "type": "boolean" + }, + { + "type": "string" + } + ] }, "uv_venv_create_args": { "description": "Arguments to pass to uv when creating a venv.", diff --git a/xtasks/render/schema.ts b/xtasks/render/schema.ts index 00056f1375..2c9958942d 100755 --- a/xtasks/render/schema.ts +++ b/xtasks/render/schema.ts @@ -54,7 +54,7 @@ function buildElement(key: string, props: Props): Element { ListPath: "string[]", SetString: "string[]", "IndexMap": "object", - BoolOrString: ["boolean", "string"], + BoolOrString: "__bool_or_string__", }; const type = props.type ? typeMap[props.type] : undefined; if (!type) { @@ -93,6 +93,16 @@ function buildElement(key: string, props: Props): Element { }; } + // BoolOrString: use oneOf instead of union type array for AJV strictTypes + if (type === "__bool_or_string__") { + delete (element as Record).type; + const oneOfTypes: Array<{ type: string }> = [ + { type: "boolean" }, + { type: "string" }, + ]; + (element as Record).oneOf = oneOfTypes; + } + return element; }