From 9ddc0a82d1ab23dff607abb613c1c04d1faef233 Mon Sep 17 00:00:00 2001 From: Marcono1234 Date: Mon, 5 May 2025 14:47:54 +0200 Subject: [PATCH 1/2] Run ajv in strict mode To fail the CI builds in case of schema issues, instead of just logging them. --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 2acc5be3..e42d598d 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ "build:messages": "node -e \"fs.writeFileSync(path.join(__dirname, 'assets/js/messages.json'), JSON.stringify(require('yaml').parse(fs.readFileSync(path.join(__dirname, 'assets/messages.yml'), 'utf8'))))\"", "build:js": "browserify assets/js/index.js | terser > dist/bundle.js", "build": "npm run build:css && npm run build:messages && copyfiles index.html favicon.ico assets/**/*.* dist && npm run build:js", - "test:messages": "ajv validate -s messages_schema.json -d assets/js/messages.json", + "test:messages": "ajv validate --strict=true -s messages_schema.json -d assets/js/messages.json", "test": "npm run test:messages" }, "repository": { From eef254f46cdef1a2d1df5ae8264960f259621838 Mon Sep 17 00:00:00 2001 From: Marcono1234 Date: Mon, 5 May 2025 14:49:46 +0200 Subject: [PATCH 2/2] Fix & improve messages schema - Add missing `type: object` - Fix `categories` using `additionalProperties` despite being an array --- messages_schema.json | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/messages_schema.json b/messages_schema.json index f9dec5a3..fc0fc2ad 100644 --- a/messages_schema.json +++ b/messages_schema.json @@ -1,29 +1,29 @@ { "$schema": "http://json-schema.org/draft-07/schema", "type": "object", + "additionalProperties": false, "properties": { "categories": { - "additionalProperties": { - "type": "array", - "items": { - "type": "object", - "additionalProperties": false, - "properties": { - "category": { - "type": "string" - }, - "name": { - "type": "string" - } + "type": "array", + "items": { + "type": "object", + "additionalProperties": false, + "properties": { + "category": { + "type": "string" }, - "required": [ - "category", - "name" - ] - } + "name": { + "type": "string" + } + }, + "required": [ + "category", + "name" + ] } }, "variables": { + "type": "object", "additionalProperties": { "type": "array", "items": { @@ -48,6 +48,7 @@ } }, "messages": { + "type": "object", "additionalProperties": { "type": "array", "items": { @@ -121,4 +122,4 @@ } } } -} \ No newline at end of file +}