From 546e917ad4bb295b2153f0ddf974d3b4c7d6a418 Mon Sep 17 00:00:00 2001 From: Peter Newman Date: Sat, 12 Sep 2020 20:38:40 +0100 Subject: [PATCH 01/64] Add codespell action --- .github/workflows/codespell.yml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 .github/workflows/codespell.yml diff --git a/.github/workflows/codespell.yml b/.github/workflows/codespell.yml new file mode 100644 index 0000000..f39b305 --- /dev/null +++ b/.github/workflows/codespell.yml @@ -0,0 +1,15 @@ +# GitHub Action to automate the identification of common misspellings in text files. +# https://github.com/codespell-project/actions-codespell +# https://github.com/codespell-project/codespell +name: codespell +on: [push, pull_request] +jobs: + codespell: + name: Check for spelling errors + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: codespell-project/actions-codespell@master + with: + check_filenames: true + skip: ./.git From ecb58e59747a12f6d5d9c2fb62b1daffa90427d8 Mon Sep 17 00:00:00 2001 From: Peter Newman Date: Sat, 12 Sep 2020 20:39:56 +0100 Subject: [PATCH 02/64] Fix a typo --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2dac6f2..33b52c9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -404,7 +404,7 @@ Here's the articles I referenced: either be a "commandType" or a "duplicateCommandType". * Added a "refType" to the "oneOfTypes" list so that other parts can also be duplicated. For example, maybe one of the items in a command needs to - duplicate another command item, either in the same or a different commmand. + duplicate another command item, either in the same or a different command. It is of type "json-pointer", see https://tools.ietf.org/html/rfc6901. ### Changed From ad2dda0d81d78bea6efcd3a6b4a25c60731ceb43 Mon Sep 17 00:00:00 2001 From: Peter Newman Date: Sat, 12 Sep 2020 20:54:46 +0100 Subject: [PATCH 03/64] Validate the schema itself --- .github/workflows/json-schema-validation.yml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 .github/workflows/json-schema-validation.yml diff --git a/.github/workflows/json-schema-validation.yml b/.github/workflows/json-schema-validation.yml new file mode 100644 index 0000000..fb4c769 --- /dev/null +++ b/.github/workflows/json-schema-validation.yml @@ -0,0 +1,17 @@ +# GitHub Action to validate schema and example files +# https://github.com/codespell-project/actions-codespell +name: JSON-Schema Validation +on: [push, pull_request] +jobs: + validate-schema: + name: Validate our Schema + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Set up Node + uses: actions/setup-node@v1 + with: + node-version: '12' + - name: Install dependencies + run: npm install @hyperjump/json-schema + - run: node validate-schema.js From ee04d55dc7d861bfba897f52c03faf42ca49195b Mon Sep 17 00:00:00 2001 From: Peter Newman Date: Sat, 12 Sep 2020 21:01:46 +0100 Subject: [PATCH 04/64] First go at validation --- validate-schema.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 validate-schema.js diff --git a/validate-schema.js b/validate-schema.js new file mode 100644 index 0000000..56e839d --- /dev/null +++ b/validate-schema.js @@ -0,0 +1,12 @@ +const JsonSchema = require("@hyperjump/json-schema"); + +// Example: Inline schema +const schemaJson = { + "$schema": "https://json-schema.org/draft/2019-09/schema", +} +JsonSchema.add(schemaJson); +const schema = await JsonSchema.get("https://json-schema.org/draft/2019-09/schema"); + +// Example: Specify output format +const output = await JsonSchema.validate(schema, "foo", JsonSchema.VERBOSE); +console.log(output); From 093878011d1b24d9e708d9d3374f0a293e1b7459 Mon Sep 17 00:00:00 2001 From: Peter Newman Date: Sat, 12 Sep 2020 21:03:01 +0100 Subject: [PATCH 05/64] Remove awaits --- validate-schema.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/validate-schema.js b/validate-schema.js index 56e839d..463f073 100644 --- a/validate-schema.js +++ b/validate-schema.js @@ -5,8 +5,8 @@ const schemaJson = { "$schema": "https://json-schema.org/draft/2019-09/schema", } JsonSchema.add(schemaJson); -const schema = await JsonSchema.get("https://json-schema.org/draft/2019-09/schema"); +const schema = JsonSchema.get("https://json-schema.org/draft/2019-09/schema"); // Example: Specify output format -const output = await JsonSchema.validate(schema, "foo", JsonSchema.VERBOSE); +const output = JsonSchema.validate(schema, "foo", JsonSchema.VERBOSE); console.log(output); From d81e07b22468d7b6da079e099262d081c875a570 Mon Sep 17 00:00:00 2001 From: Peter Newman Date: Sat, 12 Sep 2020 21:06:11 +0100 Subject: [PATCH 06/64] Ensure we meta-validate --- validate-schema.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/validate-schema.js b/validate-schema.js index 463f073..26411bf 100644 --- a/validate-schema.js +++ b/validate-schema.js @@ -7,6 +7,8 @@ const schemaJson = { JsonSchema.add(schemaJson); const schema = JsonSchema.get("https://json-schema.org/draft/2019-09/schema"); -// Example: Specify output format +JsonSchema.setShouldMetaValidate(true); +JsonSchema.setMetaOutputFormat(JsonSchema.VERBOSE); + const output = JsonSchema.validate(schema, "foo", JsonSchema.VERBOSE); console.log(output); From 6b7e1a0892b1a0977432df40ea4ae302e8963269 Mon Sep 17 00:00:00 2001 From: Peter Newman Date: Sat, 12 Sep 2020 21:11:42 +0100 Subject: [PATCH 07/64] Switch to just our schema and validate a file --- validate-schema.js | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/validate-schema.js b/validate-schema.js index 26411bf..1ebbbd5 100644 --- a/validate-schema.js +++ b/validate-schema.js @@ -1,14 +1,10 @@ const JsonSchema = require("@hyperjump/json-schema"); -// Example: Inline schema -const schemaJson = { - "$schema": "https://json-schema.org/draft/2019-09/schema", -} -JsonSchema.add(schemaJson); -const schema = JsonSchema.get("https://json-schema.org/draft/2019-09/schema"); +// Fetch from file +const schema = JsonSchema.get("file:///home/runner/work/rdm-schema/rdm-schema/rdm-schema.json"); JsonSchema.setShouldMetaValidate(true); JsonSchema.setMetaOutputFormat(JsonSchema.VERBOSE); -const output = JsonSchema.validate(schema, "foo", JsonSchema.VERBOSE); +const output = JsonSchema.validate(schema, "file:///home/runner/work/rdm-schema/rdm-schema/rdm-schema/examples/e1.20/DEVICE_INFO.json", JsonSchema.VERBOSE); console.log(output); From 7b4e231f8001c4c2f11cf2605de90910642a2f5d Mon Sep 17 00:00:00 2001 From: Peter Newman Date: Sat, 12 Sep 2020 21:22:11 +0100 Subject: [PATCH 08/64] Try and deal with unhandled promises --- validate-schema.js | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/validate-schema.js b/validate-schema.js index 1ebbbd5..25a1a42 100644 --- a/validate-schema.js +++ b/validate-schema.js @@ -1,10 +1,14 @@ const JsonSchema = require("@hyperjump/json-schema"); -// Fetch from file -const schema = JsonSchema.get("file:///home/runner/work/rdm-schema/rdm-schema/rdm-schema.json"); +async function validate() { + // Fetch from file + const schema = await JsonSchema.get("file:///home/runner/work/rdm-schema/rdm-schema/rdm-schema.json"); -JsonSchema.setShouldMetaValidate(true); -JsonSchema.setMetaOutputFormat(JsonSchema.VERBOSE); + JsonSchema.setShouldMetaValidate(true); + JsonSchema.setMetaOutputFormat(JsonSchema.VERBOSE); -const output = JsonSchema.validate(schema, "file:///home/runner/work/rdm-schema/rdm-schema/rdm-schema/examples/e1.20/DEVICE_INFO.json", JsonSchema.VERBOSE); -console.log(output); + const output = await JsonSchema.validate(schema, "file:///home/runner/work/rdm-schema/rdm-schema/rdm-schema/examples/e1.20/DEVICE_INFO.json", JsonSchema.VERBOSE); + console.log(output); +} + +validate(); From 04e917cb229ce04de11b723ebbf96e9f5698a374 Mon Sep 17 00:00:00 2001 From: Peter Newman Date: Sat, 12 Sep 2020 23:14:01 +0100 Subject: [PATCH 09/64] Try and exit when we get an error --- validate-schema.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/validate-schema.js b/validate-schema.js index 25a1a42..c7f075a 100644 --- a/validate-schema.js +++ b/validate-schema.js @@ -9,6 +9,12 @@ async function validate() { const output = await JsonSchema.validate(schema, "file:///home/runner/work/rdm-schema/rdm-schema/rdm-schema/examples/e1.20/DEVICE_INFO.json", JsonSchema.VERBOSE); console.log(output); + if (output.valid) { + console.log("File is valid :-)"); + } else { + console.log("File is invalid :-("); + process.exitCode = 1 + } } validate(); From d863a11c43fb8323fa9441af3d8290739ff87723 Mon Sep 17 00:00:00 2001 From: Peter Newman Date: Sat, 12 Sep 2020 23:32:09 +0100 Subject: [PATCH 10/64] Validate two files --- validate-schema.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/validate-schema.js b/validate-schema.js index c7f075a..f643125 100644 --- a/validate-schema.js +++ b/validate-schema.js @@ -1,20 +1,21 @@ const JsonSchema = require("@hyperjump/json-schema"); -async function validate() { +async function validate(filename) { // Fetch from file const schema = await JsonSchema.get("file:///home/runner/work/rdm-schema/rdm-schema/rdm-schema.json"); JsonSchema.setShouldMetaValidate(true); JsonSchema.setMetaOutputFormat(JsonSchema.VERBOSE); - const output = await JsonSchema.validate(schema, "file:///home/runner/work/rdm-schema/rdm-schema/rdm-schema/examples/e1.20/DEVICE_INFO.json", JsonSchema.VERBOSE); + const output = await JsonSchema.validate(schema, filename, JsonSchema.VERBOSE); console.log(output); if (output.valid) { - console.log("File is valid :-)"); + console.log("File " + filename + " is valid :-)"); } else { - console.log("File is invalid :-("); + console.log("File " + filename + " is invalid :-("); process.exitCode = 1 } } -validate(); +validate("file:///home/runner/work/rdm-schema/rdm-schema/rdm-schema/examples/e1.20/DEVICE_INFO.json"); +validate("file:///home/runner/work/rdm-schema/rdm-schema/rdm-schema/examples/e1.20/IDENTIFY_DEVICE.json"); From 723cdd227eb383e0a47b3fa04559024e246cdcd6 Mon Sep 17 00:00:00 2001 From: Peter Newman Date: Sat, 12 Sep 2020 23:50:52 +0100 Subject: [PATCH 11/64] Try validating all files --- validate-schema.js | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/validate-schema.js b/validate-schema.js index f643125..740dc2e 100644 --- a/validate-schema.js +++ b/validate-schema.js @@ -1,12 +1,7 @@ +const fs = require("fs"); const JsonSchema = require("@hyperjump/json-schema"); async function validate(filename) { - // Fetch from file - const schema = await JsonSchema.get("file:///home/runner/work/rdm-schema/rdm-schema/rdm-schema.json"); - - JsonSchema.setShouldMetaValidate(true); - JsonSchema.setMetaOutputFormat(JsonSchema.VERBOSE); - const output = await JsonSchema.validate(schema, filename, JsonSchema.VERBOSE); console.log(output); if (output.valid) { @@ -17,5 +12,25 @@ async function validate(filename) { } } -validate("file:///home/runner/work/rdm-schema/rdm-schema/rdm-schema/examples/e1.20/DEVICE_INFO.json"); -validate("file:///home/runner/work/rdm-schema/rdm-schema/rdm-schema/examples/e1.20/IDENTIFY_DEVICE.json"); +//From https://gist.github.com/kethinov/6658166#gistcomment-2037451 +function walkSync(dir) { + if (!fs.lstatSync(dir).isDirectory()) return dir; + + return fs.readdirSync(dir).map(f => walkSync(path.join(dir, f))); // `join("\n")` +} + +function validateAllFiles(path) { + // Fetch from file + const schema = await JsonSchema.get("file:///home/runner/work/rdm-schema/rdm-schema/rdm-schema.json"); + + JsonSchema.setShouldMetaValidate(true); + JsonSchema.setMetaOutputFormat(JsonSchema.VERBOSE); + + walkSync(path) + .filter((entry) => /\.json$/.test(entry)) + .forEach((entry) => { + validate(entry) + }); +} + +validateAllFiles("./examples"); From 4848bb3e5ac878f73673431b75e681dadf23c223 Mon Sep 17 00:00:00 2001 From: Peter Newman Date: Sat, 12 Sep 2020 23:53:19 +0100 Subject: [PATCH 12/64] Try and fix the async issue --- validate-schema.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/validate-schema.js b/validate-schema.js index 740dc2e..25004aa 100644 --- a/validate-schema.js +++ b/validate-schema.js @@ -21,7 +21,7 @@ function walkSync(dir) { function validateAllFiles(path) { // Fetch from file - const schema = await JsonSchema.get("file:///home/runner/work/rdm-schema/rdm-schema/rdm-schema.json"); + const schema = JsonSchema.get("file:///home/runner/work/rdm-schema/rdm-schema/rdm-schema.json"); JsonSchema.setShouldMetaValidate(true); JsonSchema.setMetaOutputFormat(JsonSchema.VERBOSE); From 223ef8dee88623312724a4be78095a92ef52f216 Mon Sep 17 00:00:00 2001 From: Peter Newman Date: Sat, 12 Sep 2020 23:56:31 +0100 Subject: [PATCH 13/64] Fix some variable names --- validate-schema.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/validate-schema.js b/validate-schema.js index 25004aa..23b9e9f 100644 --- a/validate-schema.js +++ b/validate-schema.js @@ -1,4 +1,5 @@ const fs = require("fs"); +const path = require("path"); const JsonSchema = require("@hyperjump/json-schema"); async function validate(filename) { @@ -16,17 +17,17 @@ async function validate(filename) { function walkSync(dir) { if (!fs.lstatSync(dir).isDirectory()) return dir; - return fs.readdirSync(dir).map(f => walkSync(path.join(dir, f))); // `join("\n")` + return fs.readdirSync(dir).map(f => walkSync(path.join(dir, f))); } -function validateAllFiles(path) { +function validateAllFiles(exampleDir) { // Fetch from file const schema = JsonSchema.get("file:///home/runner/work/rdm-schema/rdm-schema/rdm-schema.json"); JsonSchema.setShouldMetaValidate(true); JsonSchema.setMetaOutputFormat(JsonSchema.VERBOSE); - walkSync(path) + walkSync(exampleDir) .filter((entry) => /\.json$/.test(entry)) .forEach((entry) => { validate(entry) From b2a7f5700536cafdfd9d3fc9660e40adf1ea57a6 Mon Sep 17 00:00:00 2001 From: Peter Newman Date: Sat, 12 Sep 2020 23:58:45 +0100 Subject: [PATCH 14/64] Hopefully fix the variable scope --- validate-schema.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/validate-schema.js b/validate-schema.js index 23b9e9f..9f93742 100644 --- a/validate-schema.js +++ b/validate-schema.js @@ -2,6 +2,12 @@ const fs = require("fs"); const path = require("path"); const JsonSchema = require("@hyperjump/json-schema"); +// Fetch from file +const schema = JsonSchema.get("file:///home/runner/work/rdm-schema/rdm-schema/rdm-schema.json"); + +JsonSchema.setShouldMetaValidate(true); +JsonSchema.setMetaOutputFormat(JsonSchema.VERBOSE); + async function validate(filename) { const output = await JsonSchema.validate(schema, filename, JsonSchema.VERBOSE); console.log(output); @@ -21,12 +27,6 @@ function walkSync(dir) { } function validateAllFiles(exampleDir) { - // Fetch from file - const schema = JsonSchema.get("file:///home/runner/work/rdm-schema/rdm-schema/rdm-schema.json"); - - JsonSchema.setShouldMetaValidate(true); - JsonSchema.setMetaOutputFormat(JsonSchema.VERBOSE); - walkSync(exampleDir) .filter((entry) => /\.json$/.test(entry)) .forEach((entry) => { From 000a77b9de96e46466c1e480045d62b167667dae Mon Sep 17 00:00:00 2001 From: Peter Newman Date: Sun, 13 Sep 2020 00:00:09 +0100 Subject: [PATCH 15/64] Try and fix the sync issues --- validate-schema.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/validate-schema.js b/validate-schema.js index 9f93742..3796e29 100644 --- a/validate-schema.js +++ b/validate-schema.js @@ -26,11 +26,11 @@ function walkSync(dir) { return fs.readdirSync(dir).map(f => walkSync(path.join(dir, f))); } -function validateAllFiles(exampleDir) { +async function validateAllFiles(exampleDir) { walkSync(exampleDir) .filter((entry) => /\.json$/.test(entry)) .forEach((entry) => { - validate(entry) + await validate(entry) }); } From 63a1c9bf53a0b97fd0c9d9602116ad9abc7b749d Mon Sep 17 00:00:00 2001 From: Peter Newman Date: Sun, 13 Sep 2020 00:03:30 +0100 Subject: [PATCH 16/64] Try and make it all async --- validate-schema.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/validate-schema.js b/validate-schema.js index 3796e29..2517bab 100644 --- a/validate-schema.js +++ b/validate-schema.js @@ -19,11 +19,11 @@ async function validate(filename) { } } -//From https://gist.github.com/kethinov/6658166#gistcomment-2037451 -function walkSync(dir) { - if (!fs.lstatSync(dir).isDirectory()) return dir; +//Based on https://gist.github.com/kethinov/6658166#gistcomment-2037451 +function walk(dir) { + if (!fs.lstat(dir).isDirectory()) return dir; - return fs.readdirSync(dir).map(f => walkSync(path.join(dir, f))); + return fs.readdir(dir).map(f => walk(path.join(dir, f))); } async function validateAllFiles(exampleDir) { From 0d72dec3a4a186e307ae2d63fff15842b59643f0 Mon Sep 17 00:00:00 2001 From: Peter Newman Date: Sun, 13 Sep 2020 00:19:20 +0100 Subject: [PATCH 17/64] Try going sync again --- validate-schema.js | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/validate-schema.js b/validate-schema.js index 2517bab..fdaab6b 100644 --- a/validate-schema.js +++ b/validate-schema.js @@ -8,29 +8,28 @@ const schema = JsonSchema.get("file:///home/runner/work/rdm-schema/rdm-schema/rd JsonSchema.setShouldMetaValidate(true); JsonSchema.setMetaOutputFormat(JsonSchema.VERBOSE); -async function validate(filename) { - const output = await JsonSchema.validate(schema, filename, JsonSchema.VERBOSE); +function validate(filename) { + const output = JsonSchema.validate(schema, filename, JsonSchema.VERBOSE); console.log(output); if (output.valid) { console.log("File " + filename + " is valid :-)"); } else { - console.log("File " + filename + " is invalid :-("); - process.exitCode = 1 + console.log("File " + filename + " is invalid :-("); process.exitCode = 1 } } -//Based on https://gist.github.com/kethinov/6658166#gistcomment-2037451 -function walk(dir) { - if (!fs.lstat(dir).isDirectory()) return dir; +//From https://gist.github.com/kethinov/6658166#gistcomment-2037451 +function walkSync(dir) { + if (!fs.lstatSync(dir).isDirectory()) return dir; - return fs.readdir(dir).map(f => walk(path.join(dir, f))); + return fs.readdirSync(dir).map(f => walkSync(path.join(dir, f))); } -async function validateAllFiles(exampleDir) { +function validateAllFiles(exampleDir) { walkSync(exampleDir) .filter((entry) => /\.json$/.test(entry)) .forEach((entry) => { - await validate(entry) + validate(entry) }); } From 638931a2ff0170d87853128e5a0ea92eb6d714d6 Mon Sep 17 00:00:00 2001 From: Peter Newman Date: Sun, 13 Sep 2020 00:32:45 +0100 Subject: [PATCH 18/64] Try a better file list function --- validate-schema.js | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/validate-schema.js b/validate-schema.js index fdaab6b..1c0de07 100644 --- a/validate-schema.js +++ b/validate-schema.js @@ -18,11 +18,18 @@ function validate(filename) { } } -//From https://gist.github.com/kethinov/6658166#gistcomment-2037451 -function walkSync(dir) { - if (!fs.lstatSync(dir).isDirectory()) return dir; - - return fs.readdirSync(dir).map(f => walkSync(path.join(dir, f))); +//From https://gist.github.com/kethinov/6658166#gistcomment-1921157 +function walkSync(dir, filelist) { + files = fs.readdirSync(dir); + filelist = filelist || []; + files.forEach(function(file) { + if (fs.lstatSync(path.join(dir, file)).isDirectory()) { + filelist = walkSync(path.join(dir, file), filelist); + } else { + filelist.push(path.join(dir, file)); + } + }); + return filelist; } function validateAllFiles(exampleDir) { @@ -33,4 +40,4 @@ function validateAllFiles(exampleDir) { }); } -validateAllFiles("./examples"); +validateAllFiles("file:///home/runner/work/rdm-schema/rdm-schema/examples/"); From b16b1b0061a193b75780753c2fd7249049acf5f8 Mon Sep 17 00:00:00 2001 From: Peter Newman Date: Sun, 13 Sep 2020 00:38:06 +0100 Subject: [PATCH 19/64] Try to fix the path --- validate-schema.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/validate-schema.js b/validate-schema.js index 1c0de07..724f18c 100644 --- a/validate-schema.js +++ b/validate-schema.js @@ -40,4 +40,4 @@ function validateAllFiles(exampleDir) { }); } -validateAllFiles("file:///home/runner/work/rdm-schema/rdm-schema/examples/"); +validateAllFiles("file:///home/runner/work/rdm-schema/rdm-schema/examples"); From 0ac9704ace2c5b8d2cae719a6e9bf1fa41a92633 Mon Sep 17 00:00:00 2001 From: Peter Newman Date: Sun, 13 Sep 2020 00:39:23 +0100 Subject: [PATCH 20/64] Fix the paths --- validate-schema.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/validate-schema.js b/validate-schema.js index 724f18c..53f07d5 100644 --- a/validate-schema.js +++ b/validate-schema.js @@ -9,7 +9,7 @@ JsonSchema.setShouldMetaValidate(true); JsonSchema.setMetaOutputFormat(JsonSchema.VERBOSE); function validate(filename) { - const output = JsonSchema.validate(schema, filename, JsonSchema.VERBOSE); + const output = JsonSchema.validate(schema, "file://" + filename, JsonSchema.VERBOSE); console.log(output); if (output.valid) { console.log("File " + filename + " is valid :-)"); @@ -40,4 +40,4 @@ function validateAllFiles(exampleDir) { }); } -validateAllFiles("file:///home/runner/work/rdm-schema/rdm-schema/examples"); +validateAllFiles("/home/runner/work/rdm-schema/rdm-schema/examples/"); From 4518ed16633cde027570780457a55f9a61ae0f80 Mon Sep 17 00:00:00 2001 From: Peter Newman Date: Sun, 13 Sep 2020 00:43:12 +0100 Subject: [PATCH 21/64] Try asyncing again --- validate-schema.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/validate-schema.js b/validate-schema.js index 53f07d5..3d10865 100644 --- a/validate-schema.js +++ b/validate-schema.js @@ -8,8 +8,8 @@ const schema = JsonSchema.get("file:///home/runner/work/rdm-schema/rdm-schema/rd JsonSchema.setShouldMetaValidate(true); JsonSchema.setMetaOutputFormat(JsonSchema.VERBOSE); -function validate(filename) { - const output = JsonSchema.validate(schema, "file://" + filename, JsonSchema.VERBOSE); +async function validate(filename) { + const output = await JsonSchema.validate(schema, "file://" + filename, JsonSchema.VERBOSE); console.log(output); if (output.valid) { console.log("File " + filename + " is valid :-)"); @@ -32,11 +32,11 @@ function walkSync(dir, filelist) { return filelist; } -function validateAllFiles(exampleDir) { +async function validateAllFiles(exampleDir) { walkSync(exampleDir) .filter((entry) => /\.json$/.test(entry)) .forEach((entry) => { - validate(entry) + await validate(entry) }); } From 4037cca307529d0a157c7b06060930fcaa3ad79e Mon Sep 17 00:00:00 2001 From: Peter Newman Date: Sun, 13 Sep 2020 00:49:21 +0100 Subject: [PATCH 22/64] Try being a bit more async --- validate-schema.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/validate-schema.js b/validate-schema.js index 3d10865..2d89084 100644 --- a/validate-schema.js +++ b/validate-schema.js @@ -33,11 +33,11 @@ function walkSync(dir, filelist) { } async function validateAllFiles(exampleDir) { - walkSync(exampleDir) - .filter((entry) => /\.json$/.test(entry)) - .forEach((entry) => { - await validate(entry) - }); + var files = walkSync(exampleDir) + .filter((entry) => /\.json$/.test(entry)); + for await (const file of files) { + await validate(entry) + } } validateAllFiles("/home/runner/work/rdm-schema/rdm-schema/examples/"); From 56ec4db313ea231baf85c7651e26f881e5f5f46d Mon Sep 17 00:00:00 2001 From: Peter Newman Date: Sun, 13 Sep 2020 00:52:46 +0100 Subject: [PATCH 23/64] Fix a variable --- validate-schema.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/validate-schema.js b/validate-schema.js index 2d89084..91d602b 100644 --- a/validate-schema.js +++ b/validate-schema.js @@ -36,7 +36,7 @@ async function validateAllFiles(exampleDir) { var files = walkSync(exampleDir) .filter((entry) => /\.json$/.test(entry)); for await (const file of files) { - await validate(entry) + await validate(file) } } From ee0ee48b592fde9c2508f591b60d3ae90d1e1db1 Mon Sep 17 00:00:00 2001 From: Peter Newman Date: Sun, 13 Sep 2020 00:55:45 +0100 Subject: [PATCH 24/64] Async walk too --- validate-schema.js | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/validate-schema.js b/validate-schema.js index 91d602b..864e5da 100644 --- a/validate-schema.js +++ b/validate-schema.js @@ -18,25 +18,20 @@ async function validate(filename) { } } -//From https://gist.github.com/kethinov/6658166#gistcomment-1921157 -function walkSync(dir, filelist) { - files = fs.readdirSync(dir); - filelist = filelist || []; - files.forEach(function(file) { - if (fs.lstatSync(path.join(dir, file)).isDirectory()) { - filelist = walkSync(path.join(dir, file), filelist); - } else { - filelist.push(path.join(dir, file)); +//From https://gist.github.com/lovasoa/8691344#file-node-walk-es6 +async function* walk(dir) { + for await (const d of await fs.promises.opendir(dir)) { + const entry = path.join(dir, d.name); + if (d.isDirectory()) yield* walk(entry); + else if (d.isFile()) yield entry; } - }); - return filelist; } async function validateAllFiles(exampleDir) { - var files = walkSync(exampleDir) - .filter((entry) => /\.json$/.test(entry)); for await (const file of files) { - await validate(file) + if (/\.json$/.test(file)) { + await validate(file); + } } } From f4a91ea25562f097e35c6d16d0ea37d776a2db7e Mon Sep 17 00:00:00 2001 From: Peter Newman Date: Sun, 13 Sep 2020 00:57:24 +0100 Subject: [PATCH 25/64] Fix the variable names --- validate-schema.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/validate-schema.js b/validate-schema.js index 864e5da..41a5bb8 100644 --- a/validate-schema.js +++ b/validate-schema.js @@ -28,7 +28,7 @@ async function* walk(dir) { } async function validateAllFiles(exampleDir) { - for await (const file of files) { + for await (const file of walk(exampleDir)) { if (/\.json$/.test(file)) { await validate(file); } From cce903c20c394de4af8aa459c0cb364885517795 Mon Sep 17 00:00:00 2001 From: Peter Newman Date: Sun, 13 Sep 2020 00:59:51 +0100 Subject: [PATCH 26/64] Make sure we've fetched the base schema --- validate-schema.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/validate-schema.js b/validate-schema.js index 41a5bb8..bcb0c17 100644 --- a/validate-schema.js +++ b/validate-schema.js @@ -2,13 +2,13 @@ const fs = require("fs"); const path = require("path"); const JsonSchema = require("@hyperjump/json-schema"); -// Fetch from file -const schema = JsonSchema.get("file:///home/runner/work/rdm-schema/rdm-schema/rdm-schema.json"); - -JsonSchema.setShouldMetaValidate(true); -JsonSchema.setMetaOutputFormat(JsonSchema.VERBOSE); - async function validate(filename) { + // Fetch from file + const schema = JsonSchema.get("file:///home/runner/work/rdm-schema/rdm-schema/rdm-schema.json"); + + JsonSchema.setShouldMetaValidate(true); + JsonSchema.setMetaOutputFormat(JsonSchema.VERBOSE); + const output = await JsonSchema.validate(schema, "file://" + filename, JsonSchema.VERBOSE); console.log(output); if (output.valid) { From ceb9fdb8e878eb6bf35a04e84e35943517fa13db Mon Sep 17 00:00:00 2001 From: Peter Newman Date: Sun, 13 Sep 2020 01:00:40 +0100 Subject: [PATCH 27/64] Await the base schema --- validate-schema.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/validate-schema.js b/validate-schema.js index bcb0c17..438f40d 100644 --- a/validate-schema.js +++ b/validate-schema.js @@ -4,7 +4,7 @@ const JsonSchema = require("@hyperjump/json-schema"); async function validate(filename) { // Fetch from file - const schema = JsonSchema.get("file:///home/runner/work/rdm-schema/rdm-schema/rdm-schema.json"); + const schema = await JsonSchema.get("file:///home/runner/work/rdm-schema/rdm-schema/rdm-schema.json"); JsonSchema.setShouldMetaValidate(true); JsonSchema.setMetaOutputFormat(JsonSchema.VERBOSE); From ad75135de5e67292e7a180262f9c31573c53dc0b Mon Sep 17 00:00:00 2001 From: Peter Newman Date: Sun, 13 Sep 2020 01:19:19 +0100 Subject: [PATCH 28/64] Try loading two schemas --- validate-schema.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/validate-schema.js b/validate-schema.js index 438f40d..f29a7b9 100644 --- a/validate-schema.js +++ b/validate-schema.js @@ -4,7 +4,8 @@ const JsonSchema = require("@hyperjump/json-schema"); async function validate(filename) { // Fetch from file - const schema = await JsonSchema.get("file:///home/runner/work/rdm-schema/rdm-schema/rdm-schema.json"); + const baseSchema = await JsonSchema.get("https://json-schema.org/draft/2019-09/schema"); + const schema = await baseSchema.get("file:///home/runner/work/rdm-schema/rdm-schema/rdm-schema.json"); JsonSchema.setShouldMetaValidate(true); JsonSchema.setMetaOutputFormat(JsonSchema.VERBOSE); From 62ec77db5739e01fb8c4ba458f51ad49a5379b36 Mon Sep 17 00:00:00 2001 From: Peter Newman Date: Sun, 13 Sep 2020 01:22:01 +0100 Subject: [PATCH 29/64] Try a different way to load two schemas --- validate-schema.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/validate-schema.js b/validate-schema.js index f29a7b9..a18d2c5 100644 --- a/validate-schema.js +++ b/validate-schema.js @@ -4,8 +4,8 @@ const JsonSchema = require("@hyperjump/json-schema"); async function validate(filename) { // Fetch from file - const baseSchema = await JsonSchema.get("https://json-schema.org/draft/2019-09/schema"); - const schema = await baseSchema.get("file:///home/runner/work/rdm-schema/rdm-schema/rdm-schema.json"); + await JsonSchema.get("https://json-schema.org/draft/2019-09/schema"); + const schema = await JsonSchema.get("file:///home/runner/work/rdm-schema/rdm-schema/rdm-schema.json"); JsonSchema.setShouldMetaValidate(true); JsonSchema.setMetaOutputFormat(JsonSchema.VERBOSE); From e520a0c3aeba3331c140d77a729ef353a48073f2 Mon Sep 17 00:00:00 2001 From: Peter Newman Date: Sun, 13 Sep 2020 01:23:01 +0100 Subject: [PATCH 30/64] Skip the meta validation --- validate-schema.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/validate-schema.js b/validate-schema.js index a18d2c5..5d0f3b6 100644 --- a/validate-schema.js +++ b/validate-schema.js @@ -7,7 +7,7 @@ async function validate(filename) { await JsonSchema.get("https://json-schema.org/draft/2019-09/schema"); const schema = await JsonSchema.get("file:///home/runner/work/rdm-schema/rdm-schema/rdm-schema.json"); - JsonSchema.setShouldMetaValidate(true); + JsonSchema.setShouldMetaValidate(false); JsonSchema.setMetaOutputFormat(JsonSchema.VERBOSE); const output = await JsonSchema.validate(schema, "file://" + filename, JsonSchema.VERBOSE); From 808f39858518cfb52abf095979199056cb6e250c Mon Sep 17 00:00:00 2001 From: Peter Newman Date: Sun, 13 Sep 2020 01:24:47 +0100 Subject: [PATCH 31/64] Priorities? --- validate-schema.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/validate-schema.js b/validate-schema.js index 5d0f3b6..11fe155 100644 --- a/validate-schema.js +++ b/validate-schema.js @@ -3,12 +3,12 @@ const path = require("path"); const JsonSchema = require("@hyperjump/json-schema"); async function validate(filename) { + JsonSchema.setShouldMetaValidate(false); + JsonSchema.setMetaOutputFormat(JsonSchema.VERBOSE); + // Fetch from file await JsonSchema.get("https://json-schema.org/draft/2019-09/schema"); const schema = await JsonSchema.get("file:///home/runner/work/rdm-schema/rdm-schema/rdm-schema.json"); - - JsonSchema.setShouldMetaValidate(false); - JsonSchema.setMetaOutputFormat(JsonSchema.VERBOSE); const output = await JsonSchema.validate(schema, "file://" + filename, JsonSchema.VERBOSE); console.log(output); From 48bcb8a702efe2de114ff99b8d24e0404330de89 Mon Sep 17 00:00:00 2001 From: Peter Newman Date: Sun, 13 Sep 2020 01:35:10 +0100 Subject: [PATCH 32/64] Test fix type validation --- rdm-schema.json | 1 - 1 file changed, 1 deletion(-) diff --git a/rdm-schema.json b/rdm-schema.json index 99f1ecc..9504cf7 100644 --- a/rdm-schema.json +++ b/rdm-schema.json @@ -3,7 +3,6 @@ "$schema": "https://json-schema.org/draft/2019-09/schema", "title": "Parameter Message", "description": "The schema for the Parameter Metadata Language from Section 5 of E1.37-5. This schema is subject to change.", - "type": "object", "$ref": "#/$defs/commonPropertiesForNamed", "properties": { "pid": { From 2b682557917a506bfa9b962b9f73bc06faf89389 Mon Sep 17 00:00:00 2001 From: Bartel Eerdekens Date: Thu, 7 Jan 2021 14:26:48 +0100 Subject: [PATCH 33/64] Move to mjs. Use cfworker json-schema validator. --- .gitignore | 1 + validate-schema.js | 39 -------------------------------------- validate-schema.mjs | 46 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 47 insertions(+), 39 deletions(-) delete mode 100644 validate-schema.js create mode 100644 validate-schema.mjs diff --git a/.gitignore b/.gitignore index e43b0f9..9daa824 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ .DS_Store +node_modules diff --git a/validate-schema.js b/validate-schema.js deleted file mode 100644 index 11fe155..0000000 --- a/validate-schema.js +++ /dev/null @@ -1,39 +0,0 @@ -const fs = require("fs"); -const path = require("path"); -const JsonSchema = require("@hyperjump/json-schema"); - -async function validate(filename) { - JsonSchema.setShouldMetaValidate(false); - JsonSchema.setMetaOutputFormat(JsonSchema.VERBOSE); - - // Fetch from file - await JsonSchema.get("https://json-schema.org/draft/2019-09/schema"); - const schema = await JsonSchema.get("file:///home/runner/work/rdm-schema/rdm-schema/rdm-schema.json"); - - const output = await JsonSchema.validate(schema, "file://" + filename, JsonSchema.VERBOSE); - console.log(output); - if (output.valid) { - console.log("File " + filename + " is valid :-)"); - } else { - console.log("File " + filename + " is invalid :-("); process.exitCode = 1 - } -} - -//From https://gist.github.com/lovasoa/8691344#file-node-walk-es6 -async function* walk(dir) { - for await (const d of await fs.promises.opendir(dir)) { - const entry = path.join(dir, d.name); - if (d.isDirectory()) yield* walk(entry); - else if (d.isFile()) yield entry; - } -} - -async function validateAllFiles(exampleDir) { - for await (const file of walk(exampleDir)) { - if (/\.json$/.test(file)) { - await validate(file); - } - } -} - -validateAllFiles("/home/runner/work/rdm-schema/rdm-schema/examples/"); diff --git a/validate-schema.mjs b/validate-schema.mjs new file mode 100644 index 0000000..e66ff2b --- /dev/null +++ b/validate-schema.mjs @@ -0,0 +1,46 @@ +import { promises as fs } from 'fs'; +import * as path from "path" +// const path = require("path"); +// const JsonSchema = require("@cfworker/json-schema"); +import RdmSchema from "./rdm-schema.json" +import { Validator } from '@cfworker/json-schema'; + +const validator = new Validator(RdmSchema); +// validator.addSchema("https://json-schema.org/draft/2019-09/schema") + + +async function validate(filename) { + // JsonSchema.setShouldMetaValidate(true); + // JsonSchema.setMetaOutputFormat(JsonSchema.VERBOSE); + + // Fetch from file + const fileContent = await fs.readFile(path.resolve() + filename) + const output = validator.validate(JSON.parse(fileContent.toString())) + // const output = await JsonSchema.validate(schema, "file://" + filename, JsonSchema.VERBOSE); + // console.log(output); + if (output.valid) { + console.log("File " + filename + " is valid :-)"); + } else { + console.log("File " + filename + " is invalid :-(", output.errors); process.exitCode = 1 + } +} + +//From https://gist.github.com/lovasoa/8691344#file-node-walk-es6 +async function* walk(dir) { + for await (const d of await fs.promises.opendir(dir)) { + const entry = path.join(dir, d.name); + if (d.isDirectory()) yield* walk(entry); + else if (d.isFile()) yield entry; + } +} + +async function validateAllFiles(exampleDir) { + for await (const file of walk(exampleDir)) { + if (/\.json$/.test(file)) { + await validate(file); + } + } +} + +// validateAllFiles(__dirname + "/examples/"); +validate("/examples/e1.20/BOOT_SOFTWARE_VERSION_ID.json"); From 4df672b671ddd47249288d82c146a29e7be1ad43 Mon Sep 17 00:00:00 2001 From: Peter Newman Date: Sun, 27 Jun 2021 16:19:09 +0100 Subject: [PATCH 34/64] Try validating more files --- validate-schema.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/validate-schema.mjs b/validate-schema.mjs index e66ff2b..600849e 100644 --- a/validate-schema.mjs +++ b/validate-schema.mjs @@ -42,5 +42,5 @@ async function validateAllFiles(exampleDir) { } } -// validateAllFiles(__dirname + "/examples/"); validate("/examples/e1.20/BOOT_SOFTWARE_VERSION_ID.json"); +validateAllFiles(__dirname + "/examples/"); From 5f79fde5c070a28aed08ad72337c6698c56f322b Mon Sep 17 00:00:00 2001 From: Peter Newman Date: Sun, 27 Jun 2021 16:22:01 +0100 Subject: [PATCH 35/64] Run the new file --- .github/workflows/json-schema-validation.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/json-schema-validation.yml b/.github/workflows/json-schema-validation.yml index fb4c769..0d28bc7 100644 --- a/.github/workflows/json-schema-validation.yml +++ b/.github/workflows/json-schema-validation.yml @@ -14,4 +14,4 @@ jobs: node-version: '12' - name: Install dependencies run: npm install @hyperjump/json-schema - - run: node validate-schema.js + - run: node validate-schema.mjs From 955c8baa6245a507911b9f621dac2914c911241a Mon Sep 17 00:00:00 2001 From: Peter Newman Date: Sun, 27 Jun 2021 16:27:44 +0100 Subject: [PATCH 36/64] Install the correct module --- .github/workflows/json-schema-validation.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/json-schema-validation.yml b/.github/workflows/json-schema-validation.yml index 0d28bc7..13bbd7c 100644 --- a/.github/workflows/json-schema-validation.yml +++ b/.github/workflows/json-schema-validation.yml @@ -13,5 +13,5 @@ jobs: with: node-version: '12' - name: Install dependencies - run: npm install @hyperjump/json-schema + run: npm install @cfworker/json-schema - run: node validate-schema.mjs From 42c8ba488d69a362a25e1a26ac472a4decd6e67f Mon Sep 17 00:00:00 2001 From: Peter Newman Date: Sun, 27 Jun 2021 16:45:50 +0100 Subject: [PATCH 37/64] Try a new way to import the schema --- validate-schema.mjs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/validate-schema.mjs b/validate-schema.mjs index 600849e..d4dce28 100644 --- a/validate-schema.mjs +++ b/validate-schema.mjs @@ -2,7 +2,8 @@ import { promises as fs } from 'fs'; import * as path from "path" // const path = require("path"); // const JsonSchema = require("@cfworker/json-schema"); -import RdmSchema from "./rdm-schema.json" +//import RdmSchema from "./rdm-schema.json" +const { RdmSchema } = require('./rdm-schema.json'); import { Validator } from '@cfworker/json-schema'; const validator = new Validator(RdmSchema); From 3243e293c2a49760faf3f237e7a96fb29632397b Mon Sep 17 00:00:00 2001 From: Peter Newman Date: Sun, 27 Jun 2021 17:07:30 +0100 Subject: [PATCH 38/64] Third attempt at loading the JSON in --- validate-schema.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/validate-schema.mjs b/validate-schema.mjs index d4dce28..31aff53 100644 --- a/validate-schema.mjs +++ b/validate-schema.mjs @@ -3,7 +3,7 @@ import * as path from "path" // const path = require("path"); // const JsonSchema = require("@cfworker/json-schema"); //import RdmSchema from "./rdm-schema.json" -const { RdmSchema } = require('./rdm-schema.json'); +const { RdmSchema } = await JSON.parse(fs.readFile('./rdm-schema.json')); import { Validator } from '@cfworker/json-schema'; const validator = new Validator(RdmSchema); From b832acacbce23e8cdb74764094a37dff3c1be375 Mon Sep 17 00:00:00 2001 From: Peter Newman Date: Sun, 27 Jun 2021 20:41:46 +0100 Subject: [PATCH 39/64] Try and fix a syntax error --- validate-schema.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/validate-schema.mjs b/validate-schema.mjs index 31aff53..41e70df 100644 --- a/validate-schema.mjs +++ b/validate-schema.mjs @@ -3,7 +3,7 @@ import * as path from "path" // const path = require("path"); // const JsonSchema = require("@cfworker/json-schema"); //import RdmSchema from "./rdm-schema.json" -const { RdmSchema } = await JSON.parse(fs.readFile('./rdm-schema.json')); +const { RdmSchema } = JSON.parse(fs.readFile('./rdm-schema.json')); import { Validator } from '@cfworker/json-schema'; const validator = new Validator(RdmSchema); From 71d607d128780f6f06c72f4c1c813eadd0a79863 Mon Sep 17 00:00:00 2001 From: Peter Newman Date: Sun, 27 Jun 2021 20:46:22 +0100 Subject: [PATCH 40/64] Try another way to read the JSON --- validate-schema.mjs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/validate-schema.mjs b/validate-schema.mjs index 41e70df..02f6436 100644 --- a/validate-schema.mjs +++ b/validate-schema.mjs @@ -1,10 +1,15 @@ import { promises as fs } from 'fs'; +import { Validator } from '@cfworker/json-schema'; import * as path from "path" // const path = require("path"); // const JsonSchema = require("@cfworker/json-schema"); //import RdmSchema from "./rdm-schema.json" -const { RdmSchema } = JSON.parse(fs.readFile('./rdm-schema.json')); -import { Validator } from '@cfworker/json-schema'; +//const { RdmSchema } = JSON.parse(fs.readFile('./rdm-schema.json')); + +(async function() { + const data = JSON.parse(await fs.readFile("./rdm-schema.json")); + console.log(data); + })(); const validator = new Validator(RdmSchema); // validator.addSchema("https://json-schema.org/draft/2019-09/schema") From 03d220c9d80e73454bd42af8ce360c963d733a0d Mon Sep 17 00:00:00 2001 From: Peter Newman Date: Sun, 27 Jun 2021 20:47:27 +0100 Subject: [PATCH 41/64] Fix the variable name --- validate-schema.mjs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/validate-schema.mjs b/validate-schema.mjs index 02f6436..e448425 100644 --- a/validate-schema.mjs +++ b/validate-schema.mjs @@ -7,8 +7,8 @@ import * as path from "path" //const { RdmSchema } = JSON.parse(fs.readFile('./rdm-schema.json')); (async function() { - const data = JSON.parse(await fs.readFile("./rdm-schema.json")); - console.log(data); + const { RdmSchema } = JSON.parse(await fs.readFile("./rdm-schema.json")); + console.log(RdmSchema); })(); const validator = new Validator(RdmSchema); From a5e7812d18119753f1c8b3c381e0577df818f2a5 Mon Sep 17 00:00:00 2001 From: Peter Newman Date: Sun, 27 Jun 2021 20:51:50 +0100 Subject: [PATCH 42/64] Extract the data from the async function --- validate-schema.mjs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/validate-schema.mjs b/validate-schema.mjs index e448425..dc09f97 100644 --- a/validate-schema.mjs +++ b/validate-schema.mjs @@ -6,9 +6,10 @@ import * as path from "path" //import RdmSchema from "./rdm-schema.json" //const { RdmSchema } = JSON.parse(fs.readFile('./rdm-schema.json')); -(async function() { - const { RdmSchema } = JSON.parse(await fs.readFile("./rdm-schema.json")); - console.log(RdmSchema); +const RdmSchema = (async function() { + const { data } = JSON.parse(await fs.readFile("./rdm-schema.json")); + console.log(data); + yield data; })(); const validator = new Validator(RdmSchema); From 3d3897c940eb058cf4d49af442d2607f5b7c6f77 Mon Sep 17 00:00:00 2001 From: Peter Newman Date: Sun, 27 Jun 2021 20:54:51 +0100 Subject: [PATCH 43/64] Another way to try working around the errors --- validate-schema.mjs | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/validate-schema.mjs b/validate-schema.mjs index dc09f97..74d940d 100644 --- a/validate-schema.mjs +++ b/validate-schema.mjs @@ -6,17 +6,7 @@ import * as path from "path" //import RdmSchema from "./rdm-schema.json" //const { RdmSchema } = JSON.parse(fs.readFile('./rdm-schema.json')); -const RdmSchema = (async function() { - const { data } = JSON.parse(await fs.readFile("./rdm-schema.json")); - console.log(data); - yield data; - })(); - -const validator = new Validator(RdmSchema); -// validator.addSchema("https://json-schema.org/draft/2019-09/schema") - - -async function validate(filename) { +async function validate(validator, filename) { // JsonSchema.setShouldMetaValidate(true); // JsonSchema.setMetaOutputFormat(JsonSchema.VERBOSE); @@ -41,13 +31,20 @@ async function* walk(dir) { } } -async function validateAllFiles(exampleDir) { +async function validateAllFiles(validator, exampleDir) { for await (const file of walk(exampleDir)) { if (/\.json$/.test(file)) { - await validate(file); + await validate(validator, file); } } } -validate("/examples/e1.20/BOOT_SOFTWARE_VERSION_ID.json"); -validateAllFiles(__dirname + "/examples/"); +(async function() { + const { RdmSchema } = JSON.parse(await fs.readFile("./rdm-schema.json")); + console.log(RdmSchema); + +const validator = new Validator(RdmSchema); +// validator.addSchema("https://json-schema.org/draft/2019-09/schema") +validate(validator, "/examples/e1.20/BOOT_SOFTWARE_VERSION_ID.json"); +validateAllFiles(validator, __dirname + "/examples/"); + })(); From fa6383dcd62bd42bb9bede7b69ad43694dcfdd96 Mon Sep 17 00:00:00 2001 From: Peter Newman Date: Sun, 27 Jun 2021 21:01:36 +0100 Subject: [PATCH 44/64] Refer to the path in the new way --- validate-schema.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/validate-schema.mjs b/validate-schema.mjs index 74d940d..ec5ee5c 100644 --- a/validate-schema.mjs +++ b/validate-schema.mjs @@ -46,5 +46,5 @@ async function validateAllFiles(validator, exampleDir) { const validator = new Validator(RdmSchema); // validator.addSchema("https://json-schema.org/draft/2019-09/schema") validate(validator, "/examples/e1.20/BOOT_SOFTWARE_VERSION_ID.json"); -validateAllFiles(validator, __dirname + "/examples/"); +validateAllFiles(validator, new URL('/examples/', import.meta.url)); })(); From 29a6348c4860aa4ae016bfa41341957352e6f738 Mon Sep 17 00:00:00 2001 From: Peter Newman Date: Sun, 27 Jun 2021 21:03:37 +0100 Subject: [PATCH 45/64] Try and just use the local path --- validate-schema.mjs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/validate-schema.mjs b/validate-schema.mjs index ec5ee5c..f2aa9f8 100644 --- a/validate-schema.mjs +++ b/validate-schema.mjs @@ -45,6 +45,7 @@ async function validateAllFiles(validator, exampleDir) { const validator = new Validator(RdmSchema); // validator.addSchema("https://json-schema.org/draft/2019-09/schema") + validate(validator, "/examples/e1.20/BOOT_SOFTWARE_VERSION_ID.json"); -validateAllFiles(validator, new URL('/examples/', import.meta.url)); +validateAllFiles(validator, "/examples/")); })(); From 49358a4ccfe9597cc0f9dad42a91d64ddf0ad1c2 Mon Sep 17 00:00:00 2001 From: Peter Newman Date: Sun, 27 Jun 2021 21:04:24 +0100 Subject: [PATCH 46/64] Drop an errant bracket --- validate-schema.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/validate-schema.mjs b/validate-schema.mjs index f2aa9f8..d9ef21b 100644 --- a/validate-schema.mjs +++ b/validate-schema.mjs @@ -47,5 +47,5 @@ const validator = new Validator(RdmSchema); // validator.addSchema("https://json-schema.org/draft/2019-09/schema") validate(validator, "/examples/e1.20/BOOT_SOFTWARE_VERSION_ID.json"); -validateAllFiles(validator, "/examples/")); +validateAllFiles(validator, "/examples/"); })(); From f317da1380bf8b8c7a30db565ae32bb626c1735c Mon Sep 17 00:00:00 2001 From: Peter Newman Date: Sun, 27 Jun 2021 21:07:54 +0100 Subject: [PATCH 47/64] Die when validation fails --- .github/workflows/json-schema-validation.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/json-schema-validation.yml b/.github/workflows/json-schema-validation.yml index 13bbd7c..0000917 100644 --- a/.github/workflows/json-schema-validation.yml +++ b/.github/workflows/json-schema-validation.yml @@ -14,4 +14,4 @@ jobs: node-version: '12' - name: Install dependencies run: npm install @cfworker/json-schema - - run: node validate-schema.mjs + - run: node --unhandled-rejections=strict validate-schema.mjs From 8d4c2a07e95ca8202ae7d6fd7e5949c9d0c5e9e2 Mon Sep 17 00:00:00 2001 From: Peter Newman Date: Sun, 27 Jun 2021 21:11:17 +0100 Subject: [PATCH 48/64] Try and fix the warning --- validate-schema.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/validate-schema.mjs b/validate-schema.mjs index d9ef21b..8efe087 100644 --- a/validate-schema.mjs +++ b/validate-schema.mjs @@ -24,7 +24,7 @@ async function validate(validator, filename) { //From https://gist.github.com/lovasoa/8691344#file-node-walk-es6 async function* walk(dir) { - for await (const d of await fs.promises.opendir(dir)) { + for await (const d of await fs.opendir(dir)) { const entry = path.join(dir, d.name); if (d.isDirectory()) yield* walk(entry); else if (d.isFile()) yield entry; From c8cb9672eb7b8eda4513433c5f824424c315961e Mon Sep 17 00:00:00 2001 From: Peter Newman Date: Sun, 27 Jun 2021 21:12:20 +0100 Subject: [PATCH 49/64] Change to local ref --- validate-schema.mjs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/validate-schema.mjs b/validate-schema.mjs index 8efe087..179b6e9 100644 --- a/validate-schema.mjs +++ b/validate-schema.mjs @@ -46,6 +46,6 @@ async function validateAllFiles(validator, exampleDir) { const validator = new Validator(RdmSchema); // validator.addSchema("https://json-schema.org/draft/2019-09/schema") -validate(validator, "/examples/e1.20/BOOT_SOFTWARE_VERSION_ID.json"); -validateAllFiles(validator, "/examples/"); +validate(validator, "./examples/e1.20/BOOT_SOFTWARE_VERSION_ID.json"); +validateAllFiles(validator, "./examples/"); })(); From 27c059c2f37a876173907e7831d3be130b0c0be5 Mon Sep 17 00:00:00 2001 From: Peter Newman Date: Sun, 27 Jun 2021 21:14:53 +0100 Subject: [PATCH 50/64] Resolve all paths --- validate-schema.mjs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/validate-schema.mjs b/validate-schema.mjs index 179b6e9..eb39499 100644 --- a/validate-schema.mjs +++ b/validate-schema.mjs @@ -24,7 +24,7 @@ async function validate(validator, filename) { //From https://gist.github.com/lovasoa/8691344#file-node-walk-es6 async function* walk(dir) { - for await (const d of await fs.opendir(dir)) { + for await (const d of await fs.opendir(path.resolve() + dir)) { const entry = path.join(dir, d.name); if (d.isDirectory()) yield* walk(entry); else if (d.isFile()) yield entry; @@ -46,6 +46,6 @@ async function validateAllFiles(validator, exampleDir) { const validator = new Validator(RdmSchema); // validator.addSchema("https://json-schema.org/draft/2019-09/schema") -validate(validator, "./examples/e1.20/BOOT_SOFTWARE_VERSION_ID.json"); -validateAllFiles(validator, "./examples/"); +validate(validator, "examples/e1.20/BOOT_SOFTWARE_VERSION_ID.json"); +validateAllFiles(validator, "examples/"); })(); From c1b42bf56b5c3e8280df09ad3c9b112c55f367b6 Mon Sep 17 00:00:00 2001 From: Peter Newman Date: Sun, 27 Jun 2021 21:15:45 +0100 Subject: [PATCH 51/64] Fix all paths --- validate-schema.mjs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/validate-schema.mjs b/validate-schema.mjs index eb39499..355a710 100644 --- a/validate-schema.mjs +++ b/validate-schema.mjs @@ -46,6 +46,6 @@ async function validateAllFiles(validator, exampleDir) { const validator = new Validator(RdmSchema); // validator.addSchema("https://json-schema.org/draft/2019-09/schema") -validate(validator, "examples/e1.20/BOOT_SOFTWARE_VERSION_ID.json"); -validateAllFiles(validator, "examples/"); +validate(validator, "/examples/e1.20/BOOT_SOFTWARE_VERSION_ID.json"); +validateAllFiles(validator, "/examples/"); })(); From 54a94464620c2ac78d12a7fe89eb0c0f571d6e9d Mon Sep 17 00:00:00 2001 From: Peter Newman Date: Sun, 27 Jun 2021 21:22:28 +0100 Subject: [PATCH 52/64] Simplify tests --- validate-schema.mjs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/validate-schema.mjs b/validate-schema.mjs index 355a710..f9cf662 100644 --- a/validate-schema.mjs +++ b/validate-schema.mjs @@ -40,12 +40,16 @@ async function validateAllFiles(validator, exampleDir) { } (async function() { - const { RdmSchema } = JSON.parse(await fs.readFile("./rdm-schema.json")); - console.log(RdmSchema); + console.log("Loading schema"); + const { RdmSchema } = JSON.parse(await fs.readFile("./rdm-schema.json")); + console.log(RdmSchema); -const validator = new Validator(RdmSchema); -// validator.addSchema("https://json-schema.org/draft/2019-09/schema") + console.log("Prepping validator"); + const validator = new Validator(RdmSchema); + // validator.addSchema("https://json-schema.org/draft/2019-09/schema") -validate(validator, "/examples/e1.20/BOOT_SOFTWARE_VERSION_ID.json"); -validateAllFiles(validator, "/examples/"); + console.log("Validating single file"); + validate(validator, "/examples/e1.20/BOOT_SOFTWARE_VERSION_ID.json"); + // console.log("Validating all examples"); + // validateAllFiles(validator, "/examples/"); })(); From 1b29a8c1bf6d761f82fd133426e5cf67d02b4e48 Mon Sep 17 00:00:00 2001 From: Peter Newman Date: Sun, 27 Jun 2021 21:25:13 +0100 Subject: [PATCH 53/64] Simplify code --- validate-schema.mjs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/validate-schema.mjs b/validate-schema.mjs index f9cf662..e3be50b 100644 --- a/validate-schema.mjs +++ b/validate-schema.mjs @@ -12,14 +12,15 @@ async function validate(validator, filename) { // Fetch from file const fileContent = await fs.readFile(path.resolve() + filename) - const output = validator.validate(JSON.parse(fileContent.toString())) + console.log("Checking file " + filename"); +/* const output = validator.validate(JSON.parse(fileContent.toString())) // const output = await JsonSchema.validate(schema, "file://" + filename, JsonSchema.VERBOSE); // console.log(output); if (output.valid) { console.log("File " + filename + " is valid :-)"); } else { console.log("File " + filename + " is invalid :-(", output.errors); process.exitCode = 1 - } + }*/ } //From https://gist.github.com/lovasoa/8691344#file-node-walk-es6 From aa322fdfd4db3a192de11977dd2810e19de4b6c8 Mon Sep 17 00:00:00 2001 From: Peter Newman Date: Sun, 27 Jun 2021 21:27:06 +0100 Subject: [PATCH 54/64] Syntax! --- validate-schema.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/validate-schema.mjs b/validate-schema.mjs index e3be50b..226163f 100644 --- a/validate-schema.mjs +++ b/validate-schema.mjs @@ -12,7 +12,7 @@ async function validate(validator, filename) { // Fetch from file const fileContent = await fs.readFile(path.resolve() + filename) - console.log("Checking file " + filename"); + console.log("Checking file " + filename); /* const output = validator.validate(JSON.parse(fileContent.toString())) // const output = await JsonSchema.validate(schema, "file://" + filename, JsonSchema.VERBOSE); // console.log(output); From 4035e593e1ee9604bc2c110d3114bd0b42e25a5d Mon Sep 17 00:00:00 2001 From: Peter Newman Date: Sun, 27 Jun 2021 21:31:56 +0100 Subject: [PATCH 55/64] More debugging --- validate-schema.mjs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/validate-schema.mjs b/validate-schema.mjs index 226163f..72aa024 100644 --- a/validate-schema.mjs +++ b/validate-schema.mjs @@ -12,11 +12,13 @@ async function validate(validator, filename) { // Fetch from file const fileContent = await fs.readFile(path.resolve() + filename) - console.log("Checking file " + filename); -/* const output = validator.validate(JSON.parse(fileContent.toString())) + console.log("Checking file " + path.resolve() + filename); + console.log("Contents:"); + console.log(JSON.parse(fileContent.toString())); + const output = validator.validate(JSON.parse(fileContent.toString())) // const output = await JsonSchema.validate(schema, "file://" + filename, JsonSchema.VERBOSE); // console.log(output); - if (output.valid) { + /*if (output.valid) { console.log("File " + filename + " is valid :-)"); } else { console.log("File " + filename + " is invalid :-(", output.errors); process.exitCode = 1 From d96ae819aad8ecf39dda36d7037a6557b2a25b6d Mon Sep 17 00:00:00 2001 From: Peter Newman Date: Sun, 27 Jun 2021 21:37:41 +0100 Subject: [PATCH 56/64] Add the schema version --- validate-schema.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/validate-schema.mjs b/validate-schema.mjs index 72aa024..5eda014 100644 --- a/validate-schema.mjs +++ b/validate-schema.mjs @@ -48,7 +48,7 @@ async function validateAllFiles(validator, exampleDir) { console.log(RdmSchema); console.log("Prepping validator"); - const validator = new Validator(RdmSchema); + const validator = new Validator(RdmSchema, '2019-09'); // validator.addSchema("https://json-schema.org/draft/2019-09/schema") console.log("Validating single file"); From 037c831707b0431e07b0638d0b82b25a96e64552 Mon Sep 17 00:00:00 2001 From: Peter Newman Date: Sun, 27 Jun 2021 22:19:46 +0100 Subject: [PATCH 57/64] Don't validate for the minute --- validate-schema.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/validate-schema.mjs b/validate-schema.mjs index 5eda014..05ede5f 100644 --- a/validate-schema.mjs +++ b/validate-schema.mjs @@ -15,7 +15,7 @@ async function validate(validator, filename) { console.log("Checking file " + path.resolve() + filename); console.log("Contents:"); console.log(JSON.parse(fileContent.toString())); - const output = validator.validate(JSON.parse(fileContent.toString())) + // const output = validator.validate(JSON.parse(fileContent.toString())) // const output = await JsonSchema.validate(schema, "file://" + filename, JsonSchema.VERBOSE); // console.log(output); /*if (output.valid) { From 331433de851a1d46a1f266411f1b3c6b66f53fa3 Mon Sep 17 00:00:00 2001 From: Peter Newman Date: Sun, 27 Jun 2021 22:21:39 +0100 Subject: [PATCH 58/64] Format the path in a different way --- validate-schema.mjs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/validate-schema.mjs b/validate-schema.mjs index 05ede5f..9b745b9 100644 --- a/validate-schema.mjs +++ b/validate-schema.mjs @@ -44,7 +44,8 @@ async function validateAllFiles(validator, exampleDir) { (async function() { console.log("Loading schema"); - const { RdmSchema } = JSON.parse(await fs.readFile("./rdm-schema.json")); + const { RdmSchema } = JSON.parse(await fs.readFile(path.resolve() + "/rdm-schema.json")); + console.log("Got schema:"); console.log(RdmSchema); console.log("Prepping validator"); From 0c0ecaf533cfc4959057a5f944deb12928f13ea9 Mon Sep 17 00:00:00 2001 From: Peter Newman Date: Sun, 27 Jun 2021 22:30:54 +0100 Subject: [PATCH 59/64] Grab the raw schema first, then parse it --- validate-schema.mjs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/validate-schema.mjs b/validate-schema.mjs index 9b745b9..42f86aa 100644 --- a/validate-schema.mjs +++ b/validate-schema.mjs @@ -44,7 +44,10 @@ async function validateAllFiles(validator, exampleDir) { (async function() { console.log("Loading schema"); - const { RdmSchema } = JSON.parse(await fs.readFile(path.resolve() + "/rdm-schema.json")); + const rawSchema = await fs.readFile(path.resolve() + "/rdm-schema.json"); + console.log("Got raw schema:"); + console.log(rawSchema); + const { RdmSchema } = JSON.parse(rawSchema); console.log("Got schema:"); console.log(RdmSchema); From 20afb8c3ed2962e855043a94b9a58eb746c60b42 Mon Sep 17 00:00:00 2001 From: Peter Newman Date: Sun, 27 Jun 2021 22:33:10 +0100 Subject: [PATCH 60/64] Convert the schema buffer to a string --- validate-schema.mjs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/validate-schema.mjs b/validate-schema.mjs index 42f86aa..a8e8c95 100644 --- a/validate-schema.mjs +++ b/validate-schema.mjs @@ -46,8 +46,8 @@ async function validateAllFiles(validator, exampleDir) { console.log("Loading schema"); const rawSchema = await fs.readFile(path.resolve() + "/rdm-schema.json"); console.log("Got raw schema:"); - console.log(rawSchema); - const { RdmSchema } = JSON.parse(rawSchema); + console.log(rawSchema.toString()); + const { RdmSchema } = JSON.parse(rawSchema.toString()); console.log("Got schema:"); console.log(RdmSchema); From 7c985dca1d537599410d4b9a64a48c2ade301a7a Mon Sep 17 00:00:00 2001 From: Peter Newman Date: Sun, 27 Jun 2021 22:35:59 +0100 Subject: [PATCH 61/64] Try removing the curly brackets --- validate-schema.mjs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/validate-schema.mjs b/validate-schema.mjs index a8e8c95..ec735f8 100644 --- a/validate-schema.mjs +++ b/validate-schema.mjs @@ -47,7 +47,9 @@ async function validateAllFiles(validator, exampleDir) { const rawSchema = await fs.readFile(path.resolve() + "/rdm-schema.json"); console.log("Got raw schema:"); console.log(rawSchema.toString()); - const { RdmSchema } = JSON.parse(rawSchema.toString()); + console.log("Got parsed JSON:"); + console.log(JSON.parse(rawSchema.toString())) + const RdmSchema = JSON.parse(rawSchema.toString()); console.log("Got schema:"); console.log(RdmSchema); From 5cecb8d091ebd75baa50bc2d8d2b9aa89adfb891 Mon Sep 17 00:00:00 2001 From: Peter Newman Date: Sun, 27 Jun 2021 22:40:42 +0100 Subject: [PATCH 62/64] Tweak some logging --- validate-schema.mjs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/validate-schema.mjs b/validate-schema.mjs index ec735f8..de7c3f7 100644 --- a/validate-schema.mjs +++ b/validate-schema.mjs @@ -15,14 +15,14 @@ async function validate(validator, filename) { console.log("Checking file " + path.resolve() + filename); console.log("Contents:"); console.log(JSON.parse(fileContent.toString())); - // const output = validator.validate(JSON.parse(fileContent.toString())) + const output = validator.validate(JSON.parse(fileContent.toString())) // const output = await JsonSchema.validate(schema, "file://" + filename, JsonSchema.VERBOSE); - // console.log(output); - /*if (output.valid) { + // console.log(output); + if (output.valid) { console.log("File " + filename + " is valid :-)"); } else { console.log("File " + filename + " is invalid :-(", output.errors); process.exitCode = 1 - }*/ + } } //From https://gist.github.com/lovasoa/8691344#file-node-walk-es6 @@ -45,17 +45,17 @@ async function validateAllFiles(validator, exampleDir) { (async function() { console.log("Loading schema"); const rawSchema = await fs.readFile(path.resolve() + "/rdm-schema.json"); - console.log("Got raw schema:"); - console.log(rawSchema.toString()); - console.log("Got parsed JSON:"); - console.log(JSON.parse(rawSchema.toString())) + //console.log("Got raw schema:"); + //console.log(rawSchema.toString()); + //console.log("Got parsed JSON:"); + //console.log(JSON.parse(rawSchema.toString())) const RdmSchema = JSON.parse(rawSchema.toString()); console.log("Got schema:"); console.log(RdmSchema); console.log("Prepping validator"); const validator = new Validator(RdmSchema, '2019-09'); - // validator.addSchema("https://json-schema.org/draft/2019-09/schema") + validator.addSchema("https://json-schema.org/draft/2019-09/schema") console.log("Validating single file"); validate(validator, "/examples/e1.20/BOOT_SOFTWARE_VERSION_ID.json"); From e98ece9a542e5d06f8b68c82a891f8d10b35112d Mon Sep 17 00:00:00 2001 From: Peter Newman Date: Sun, 27 Jun 2021 22:42:23 +0100 Subject: [PATCH 63/64] Validate all the files --- validate-schema.mjs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/validate-schema.mjs b/validate-schema.mjs index de7c3f7..6d6a7a6 100644 --- a/validate-schema.mjs +++ b/validate-schema.mjs @@ -13,8 +13,8 @@ async function validate(validator, filename) { // Fetch from file const fileContent = await fs.readFile(path.resolve() + filename) console.log("Checking file " + path.resolve() + filename); - console.log("Contents:"); - console.log(JSON.parse(fileContent.toString())); + // console.log("Contents:"); + // console.log(JSON.parse(fileContent.toString())); const output = validator.validate(JSON.parse(fileContent.toString())) // const output = await JsonSchema.validate(schema, "file://" + filename, JsonSchema.VERBOSE); // console.log(output); @@ -59,6 +59,6 @@ async function validateAllFiles(validator, exampleDir) { console.log("Validating single file"); validate(validator, "/examples/e1.20/BOOT_SOFTWARE_VERSION_ID.json"); - // console.log("Validating all examples"); - // validateAllFiles(validator, "/examples/"); + console.log("Validating all examples"); + validateAllFiles(validator, "/examples/"); })(); From c0739129c0086ea173b28d9f663fec0bab6d3c44 Mon Sep 17 00:00:00 2001 From: Peter Newman Date: Tue, 10 May 2022 13:30:59 +0100 Subject: [PATCH 64/64] Standardise file and workflow names --- .../{json-schema-validation.yml => validation-json-schema.yml} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename .github/workflows/{json-schema-validation.yml => validation-json-schema.yml} (94%) diff --git a/.github/workflows/json-schema-validation.yml b/.github/workflows/validation-json-schema.yml similarity index 94% rename from .github/workflows/json-schema-validation.yml rename to .github/workflows/validation-json-schema.yml index 0000917..0a1b69c 100644 --- a/.github/workflows/json-schema-validation.yml +++ b/.github/workflows/validation-json-schema.yml @@ -1,6 +1,6 @@ # GitHub Action to validate schema and example files # https://github.com/codespell-project/actions-codespell -name: JSON-Schema Validation +name: Validation - JSON-Schema on: [push, pull_request] jobs: validate-schema: