From a8eab81d3f950faad7c91e636db69d380e17ef67 Mon Sep 17 00:00:00 2001 From: Andrea Frittoli Date: Wed, 6 Mar 2024 11:18:18 +0000 Subject: [PATCH] Fix references to link schemas Make the references start with a / and include the whole path relative to the main schema base URL. See https://json-schema.org/understanding-json-schema/structuring#dollarref Schemas from the PR may not be published yet, so adapt the CI job to look for local files instead. Signed-off-by: Andrea Frittoli --- schemas/artifactdeleted.json | 2 +- schemas/artifactdownloaded.json | 2 +- schemas/artifactpackaged.json | 2 +- schemas/artifactpublished.json | 2 +- schemas/artifactsigned.json | 2 +- schemas/branchcreated.json | 2 +- schemas/branchdeleted.json | 2 +- schemas/buildfinished.json | 2 +- schemas/buildqueued.json | 2 +- schemas/buildstarted.json | 2 +- schemas/changeabandoned.json | 2 +- schemas/changecreated.json | 2 +- schemas/changemerged.json | 2 +- schemas/changereviewed.json | 2 +- schemas/changeupdated.json | 2 +- schemas/environmentcreated.json | 2 +- schemas/environmentdeleted.json | 2 +- schemas/environmentmodified.json | 2 +- schemas/incidentdetected.json | 2 +- schemas/incidentreported.json | 2 +- schemas/incidentresolved.json | 2 +- schemas/pipelinerunfinished.json | 2 +- schemas/pipelinerunqueued.json | 2 +- schemas/pipelinerunstarted.json | 2 +- schemas/repositorycreated.json | 2 +- schemas/repositorydeleted.json | 2 +- schemas/repositorymodified.json | 2 +- schemas/servicedeployed.json | 2 +- schemas/servicepublished.json | 2 +- schemas/serviceremoved.json | 2 +- schemas/servicerolledback.json | 2 +- schemas/serviceupgraded.json | 2 +- schemas/taskrunfinished.json | 2 +- schemas/taskrunstarted.json | 2 +- schemas/testcaserunfinished.json | 2 +- schemas/testcaserunqueued.json | 2 +- schemas/testcaserunstarted.json | 2 +- schemas/testoutputpublished.json | 2 +- schemas/testsuiterunfinished.json | 2 +- schemas/testsuiterunqueued.json | 2 +- schemas/testsuiterunstarted.json | 2 +- tools/verify-examples.sh | 13 +++++++++++-- 42 files changed, 52 insertions(+), 43 deletions(-) diff --git a/schemas/artifactdeleted.json b/schemas/artifactdeleted.json index c9ecd10f..767a3b7e 100644 --- a/schemas/artifactdeleted.json +++ b/schemas/artifactdeleted.json @@ -38,7 +38,7 @@ "minLength": 1 }, "links": { - "$ref": "links/embeddedlinksarray.json" + "$ref": "/schema/links/embeddedlinksarray.json" } }, "additionalProperties": false, diff --git a/schemas/artifactdownloaded.json b/schemas/artifactdownloaded.json index 15bb421e..854d435e 100644 --- a/schemas/artifactdownloaded.json +++ b/schemas/artifactdownloaded.json @@ -38,7 +38,7 @@ "minLength": 1 }, "links": { - "$ref": "links/embeddedlinksarray.json" + "$ref": "/schema/links/embeddedlinksarray.json" } }, "additionalProperties": false, diff --git a/schemas/artifactpackaged.json b/schemas/artifactpackaged.json index 3088a0e1..5a17b938 100644 --- a/schemas/artifactpackaged.json +++ b/schemas/artifactpackaged.json @@ -38,7 +38,7 @@ "minLength": 1 }, "links": { - "$ref": "links/embeddedlinksarray.json" + "$ref": "/schema/links/embeddedlinksarray.json" } }, "additionalProperties": false, diff --git a/schemas/artifactpublished.json b/schemas/artifactpublished.json index 98e70920..c30a1f14 100644 --- a/schemas/artifactpublished.json +++ b/schemas/artifactpublished.json @@ -38,7 +38,7 @@ "minLength": 1 }, "links": { - "$ref": "links/embeddedlinksarray.json" + "$ref": "/schema/links/embeddedlinksarray.json" } }, "additionalProperties": false, diff --git a/schemas/artifactsigned.json b/schemas/artifactsigned.json index b08b482a..d0b8f74b 100644 --- a/schemas/artifactsigned.json +++ b/schemas/artifactsigned.json @@ -38,7 +38,7 @@ "minLength": 1 }, "links": { - "$ref": "links/embeddedlinksarray.json" + "$ref": "/schema/links/embeddedlinksarray.json" } }, "additionalProperties": false, diff --git a/schemas/branchcreated.json b/schemas/branchcreated.json index ea0c6d37..3f2bab6f 100644 --- a/schemas/branchcreated.json +++ b/schemas/branchcreated.json @@ -38,7 +38,7 @@ "minLength": 1 }, "links": { - "$ref": "links/embeddedlinksarray.json" + "$ref": "/schema/links/embeddedlinksarray.json" } }, "additionalProperties": false, diff --git a/schemas/branchdeleted.json b/schemas/branchdeleted.json index 6f467f2e..e5b6901b 100644 --- a/schemas/branchdeleted.json +++ b/schemas/branchdeleted.json @@ -38,7 +38,7 @@ "minLength": 1 }, "links": { - "$ref": "links/embeddedlinksarray.json" + "$ref": "/schema/links/embeddedlinksarray.json" } }, "additionalProperties": false, diff --git a/schemas/buildfinished.json b/schemas/buildfinished.json index b3e37239..043edae6 100644 --- a/schemas/buildfinished.json +++ b/schemas/buildfinished.json @@ -38,7 +38,7 @@ "minLength": 1 }, "links": { - "$ref": "links/embeddedlinksarray.json" + "$ref": "/schema/links/embeddedlinksarray.json" } }, "additionalProperties": false, diff --git a/schemas/buildqueued.json b/schemas/buildqueued.json index d04f1c82..3bbdc479 100644 --- a/schemas/buildqueued.json +++ b/schemas/buildqueued.json @@ -38,7 +38,7 @@ "minLength": 1 }, "links": { - "$ref": "links/embeddedlinksarray.json" + "$ref": "/schema/links/embeddedlinksarray.json" } }, "additionalProperties": false, diff --git a/schemas/buildstarted.json b/schemas/buildstarted.json index fe4206d4..a4187730 100644 --- a/schemas/buildstarted.json +++ b/schemas/buildstarted.json @@ -38,7 +38,7 @@ "minLength": 1 }, "links": { - "$ref": "links/embeddedlinksarray.json" + "$ref": "/schema/links/embeddedlinksarray.json" } }, "additionalProperties": false, diff --git a/schemas/changeabandoned.json b/schemas/changeabandoned.json index 7cf19e86..3d0efcf2 100644 --- a/schemas/changeabandoned.json +++ b/schemas/changeabandoned.json @@ -38,7 +38,7 @@ "minLength": 1 }, "links": { - "$ref": "links/embeddedlinksarray.json" + "$ref": "/schema/links/embeddedlinksarray.json" } }, "additionalProperties": false, diff --git a/schemas/changecreated.json b/schemas/changecreated.json index 07b8fde3..fabd921e 100644 --- a/schemas/changecreated.json +++ b/schemas/changecreated.json @@ -38,7 +38,7 @@ "minLength": 1 }, "links": { - "$ref": "links/embeddedlinksarray.json" + "$ref": "/schema/links/embeddedlinksarray.json" } }, "additionalProperties": false, diff --git a/schemas/changemerged.json b/schemas/changemerged.json index ace43683..6d129a6f 100644 --- a/schemas/changemerged.json +++ b/schemas/changemerged.json @@ -38,7 +38,7 @@ "minLength": 1 }, "links": { - "$ref": "links/embeddedlinksarray.json" + "$ref": "/schema/links/embeddedlinksarray.json" } }, "additionalProperties": false, diff --git a/schemas/changereviewed.json b/schemas/changereviewed.json index 5912c7a1..ad159d84 100644 --- a/schemas/changereviewed.json +++ b/schemas/changereviewed.json @@ -38,7 +38,7 @@ "minLength": 1 }, "links": { - "$ref": "links/embeddedlinksarray.json" + "$ref": "/schema/links/embeddedlinksarray.json" } }, "additionalProperties": false, diff --git a/schemas/changeupdated.json b/schemas/changeupdated.json index 403ce784..eee7499b 100644 --- a/schemas/changeupdated.json +++ b/schemas/changeupdated.json @@ -38,7 +38,7 @@ "minLength": 1 }, "links": { - "$ref": "links/embeddedlinksarray.json" + "$ref": "/schema/links/embeddedlinksarray.json" } }, "additionalProperties": false, diff --git a/schemas/environmentcreated.json b/schemas/environmentcreated.json index 89b44d8a..2cd5530f 100644 --- a/schemas/environmentcreated.json +++ b/schemas/environmentcreated.json @@ -38,7 +38,7 @@ "minLength": 1 }, "links": { - "$ref": "links/embeddedlinksarray.json" + "$ref": "/schema/links/embeddedlinksarray.json" } }, "additionalProperties": false, diff --git a/schemas/environmentdeleted.json b/schemas/environmentdeleted.json index 929e09a4..fed91fa3 100644 --- a/schemas/environmentdeleted.json +++ b/schemas/environmentdeleted.json @@ -38,7 +38,7 @@ "minLength": 1 }, "links": { - "$ref": "links/embeddedlinksarray.json" + "$ref": "/schema/links/embeddedlinksarray.json" } }, "additionalProperties": false, diff --git a/schemas/environmentmodified.json b/schemas/environmentmodified.json index 839566a9..6e8c9cfb 100644 --- a/schemas/environmentmodified.json +++ b/schemas/environmentmodified.json @@ -38,7 +38,7 @@ "minLength": 1 }, "links": { - "$ref": "links/embeddedlinksarray.json" + "$ref": "/schema/links/embeddedlinksarray.json" } }, "additionalProperties": false, diff --git a/schemas/incidentdetected.json b/schemas/incidentdetected.json index 2d30a071..dcddd4fb 100644 --- a/schemas/incidentdetected.json +++ b/schemas/incidentdetected.json @@ -38,7 +38,7 @@ "minLength": 1 }, "links": { - "$ref": "links/embeddedlinksarray.json" + "$ref": "/schema/links/embeddedlinksarray.json" } }, "additionalProperties": false, diff --git a/schemas/incidentreported.json b/schemas/incidentreported.json index 85584fb4..53543e49 100644 --- a/schemas/incidentreported.json +++ b/schemas/incidentreported.json @@ -38,7 +38,7 @@ "minLength": 1 }, "links": { - "$ref": "links/embeddedlinksarray.json" + "$ref": "/schema/links/embeddedlinksarray.json" } }, "additionalProperties": false, diff --git a/schemas/incidentresolved.json b/schemas/incidentresolved.json index 8513564c..46ab6a1f 100644 --- a/schemas/incidentresolved.json +++ b/schemas/incidentresolved.json @@ -38,7 +38,7 @@ "minLength": 1 }, "links": { - "$ref": "links/embeddedlinksarray.json" + "$ref": "/schema/links/embeddedlinksarray.json" } }, "additionalProperties": false, diff --git a/schemas/pipelinerunfinished.json b/schemas/pipelinerunfinished.json index 6e6e8e31..ffcb45c6 100644 --- a/schemas/pipelinerunfinished.json +++ b/schemas/pipelinerunfinished.json @@ -38,7 +38,7 @@ "minLength": 1 }, "links": { - "$ref": "links/embeddedlinksarray.json" + "$ref": "/schema/links/embeddedlinksarray.json" } }, "additionalProperties": false, diff --git a/schemas/pipelinerunqueued.json b/schemas/pipelinerunqueued.json index 00562abf..899beb21 100644 --- a/schemas/pipelinerunqueued.json +++ b/schemas/pipelinerunqueued.json @@ -38,7 +38,7 @@ "minLength": 1 }, "links": { - "$ref": "links/embeddedlinksarray.json" + "$ref": "/schema/links/embeddedlinksarray.json" } }, "additionalProperties": false, diff --git a/schemas/pipelinerunstarted.json b/schemas/pipelinerunstarted.json index e3d9c9a5..257e13d6 100644 --- a/schemas/pipelinerunstarted.json +++ b/schemas/pipelinerunstarted.json @@ -38,7 +38,7 @@ "minLength": 1 }, "links": { - "$ref": "links/embeddedlinksarray.json" + "$ref": "/schema/links/embeddedlinksarray.json" } }, "additionalProperties": false, diff --git a/schemas/repositorycreated.json b/schemas/repositorycreated.json index a9551102..edb91bd0 100644 --- a/schemas/repositorycreated.json +++ b/schemas/repositorycreated.json @@ -38,7 +38,7 @@ "minLength": 1 }, "links": { - "$ref": "links/embeddedlinksarray.json" + "$ref": "/schema/links/embeddedlinksarray.json" } }, "additionalProperties": false, diff --git a/schemas/repositorydeleted.json b/schemas/repositorydeleted.json index b45c69aa..1e8852ce 100644 --- a/schemas/repositorydeleted.json +++ b/schemas/repositorydeleted.json @@ -38,7 +38,7 @@ "minLength": 1 }, "links": { - "$ref": "links/embeddedlinksarray.json" + "$ref": "/schema/links/embeddedlinksarray.json" } }, "additionalProperties": false, diff --git a/schemas/repositorymodified.json b/schemas/repositorymodified.json index bdc35486..7a3fdbc7 100644 --- a/schemas/repositorymodified.json +++ b/schemas/repositorymodified.json @@ -38,7 +38,7 @@ "minLength": 1 }, "links": { - "$ref": "links/embeddedlinksarray.json" + "$ref": "/schema/links/embeddedlinksarray.json" } }, "additionalProperties": false, diff --git a/schemas/servicedeployed.json b/schemas/servicedeployed.json index 0fe98639..6cbab4c0 100644 --- a/schemas/servicedeployed.json +++ b/schemas/servicedeployed.json @@ -38,7 +38,7 @@ "minLength": 1 }, "links": { - "$ref": "links/embeddedlinksarray.json" + "$ref": "/schema/links/embeddedlinksarray.json" } }, "additionalProperties": false, diff --git a/schemas/servicepublished.json b/schemas/servicepublished.json index 2bc3ed6e..f9ed5b3e 100644 --- a/schemas/servicepublished.json +++ b/schemas/servicepublished.json @@ -38,7 +38,7 @@ "minLength": 1 }, "links": { - "$ref": "links/embeddedlinksarray.json" + "$ref": "/schema/links/embeddedlinksarray.json" } }, "additionalProperties": false, diff --git a/schemas/serviceremoved.json b/schemas/serviceremoved.json index ce92eca6..1875cd87 100644 --- a/schemas/serviceremoved.json +++ b/schemas/serviceremoved.json @@ -38,7 +38,7 @@ "minLength": 1 }, "links": { - "$ref": "links/embeddedlinksarray.json" + "$ref": "/schema/links/embeddedlinksarray.json" } }, "additionalProperties": false, diff --git a/schemas/servicerolledback.json b/schemas/servicerolledback.json index 992e9357..debcd535 100644 --- a/schemas/servicerolledback.json +++ b/schemas/servicerolledback.json @@ -38,7 +38,7 @@ "minLength": 1 }, "links": { - "$ref": "links/embeddedlinksarray.json" + "$ref": "/schema/links/embeddedlinksarray.json" } }, "additionalProperties": false, diff --git a/schemas/serviceupgraded.json b/schemas/serviceupgraded.json index c69bb207..b00bb448 100644 --- a/schemas/serviceupgraded.json +++ b/schemas/serviceupgraded.json @@ -38,7 +38,7 @@ "minLength": 1 }, "links": { - "$ref": "links/embeddedlinksarray.json" + "$ref": "/schema/links/embeddedlinksarray.json" } }, "additionalProperties": false, diff --git a/schemas/taskrunfinished.json b/schemas/taskrunfinished.json index c8f46a49..b5b77d29 100644 --- a/schemas/taskrunfinished.json +++ b/schemas/taskrunfinished.json @@ -38,7 +38,7 @@ "minLength": 1 }, "links": { - "$ref": "links/embeddedlinksarray.json" + "$ref": "/schema/links/embeddedlinksarray.json" } }, "additionalProperties": false, diff --git a/schemas/taskrunstarted.json b/schemas/taskrunstarted.json index e1221ceb..95de4c35 100644 --- a/schemas/taskrunstarted.json +++ b/schemas/taskrunstarted.json @@ -38,7 +38,7 @@ "minLength": 1 }, "links": { - "$ref": "links/embeddedlinksarray.json" + "$ref": "/schema/links/embeddedlinksarray.json" } }, "additionalProperties": false, diff --git a/schemas/testcaserunfinished.json b/schemas/testcaserunfinished.json index 50f9bca2..3bcbd2ef 100644 --- a/schemas/testcaserunfinished.json +++ b/schemas/testcaserunfinished.json @@ -37,7 +37,7 @@ "minLength": 1 }, "links": { - "$ref": "links/embeddedlinksarray.json" + "$ref": "/schema/links/embeddedlinksarray.json" } }, "additionalProperties": false, diff --git a/schemas/testcaserunqueued.json b/schemas/testcaserunqueued.json index 484abfcd..40b54d08 100644 --- a/schemas/testcaserunqueued.json +++ b/schemas/testcaserunqueued.json @@ -37,7 +37,7 @@ "minLength": 1 }, "links": { - "$ref": "links/embeddedlinksarray.json" + "$ref": "/schema/links/embeddedlinksarray.json" } }, "additionalProperties": false, diff --git a/schemas/testcaserunstarted.json b/schemas/testcaserunstarted.json index aa2232bb..7b598e41 100644 --- a/schemas/testcaserunstarted.json +++ b/schemas/testcaserunstarted.json @@ -37,7 +37,7 @@ "minLength": 1 }, "links": { - "$ref": "links/embeddedlinksarray.json" + "$ref": "/schema/links/embeddedlinksarray.json" } }, "additionalProperties": false, diff --git a/schemas/testoutputpublished.json b/schemas/testoutputpublished.json index 904edc03..6f86d4e7 100644 --- a/schemas/testoutputpublished.json +++ b/schemas/testoutputpublished.json @@ -37,7 +37,7 @@ "minLength": 1 }, "links": { - "$ref": "links/embeddedlinksarray.json" + "$ref": "/schema/links/embeddedlinksarray.json" } }, "additionalProperties": false, diff --git a/schemas/testsuiterunfinished.json b/schemas/testsuiterunfinished.json index e00488de..05f4b82b 100644 --- a/schemas/testsuiterunfinished.json +++ b/schemas/testsuiterunfinished.json @@ -37,7 +37,7 @@ "minLength": 1 }, "links": { - "$ref": "links/embeddedlinksarray.json" + "$ref": "/schema/links/embeddedlinksarray.json" } }, "additionalProperties": false, diff --git a/schemas/testsuiterunqueued.json b/schemas/testsuiterunqueued.json index 9720306f..612dfe9b 100644 --- a/schemas/testsuiterunqueued.json +++ b/schemas/testsuiterunqueued.json @@ -37,7 +37,7 @@ "minLength": 1 }, "links": { - "$ref": "links/embeddedlinksarray.json" + "$ref": "/schema/links/embeddedlinksarray.json" } }, "additionalProperties": false, diff --git a/schemas/testsuiterunstarted.json b/schemas/testsuiterunstarted.json index 236be346..25854b30 100644 --- a/schemas/testsuiterunstarted.json +++ b/schemas/testsuiterunstarted.json @@ -37,7 +37,7 @@ "minLength": 1 }, "links": { - "$ref": "links/embeddedlinksarray.json" + "$ref": "/schema/links/embeddedlinksarray.json" } }, "additionalProperties": false, diff --git a/tools/verify-examples.sh b/tools/verify-examples.sh index 522acbb6..8ae978dc 100755 --- a/tools/verify-examples.sh +++ b/tools/verify-examples.sh @@ -37,9 +37,17 @@ EXAMPLES_FOLDER="${ROOT}/examples" SCHEMAS_FOLDER="${ROOT}/schemas" # Install the tool -cd ${ROOT}/tools +cd "${ROOT}/tools" go install github.com/neilpa/yajsv@v1.4.1 +function local_schema() { + local SCHEMA=$1 + + # Draft version schemas may have not been published yet + # Rewrite referenced IDs to the corresponding local files + sed 's,"$ref": "/schema,"$ref": "file://'${ROOT}'/schemas,g' "${SCHEMA}" > "${SCHEMA}.local" +} + # Loop over all example files # - examples are subject_predicate.json # - schemas are subjectpredicate.json @@ -52,9 +60,10 @@ for example in $(find "${EXAMPLES_FOLDER}" -type f -name '*json'); do SUBJECT=${splitArray[0]} PREDICATE=${splitArray[1]} SCHEMA_FILE=${SCHEMAS_FOLDER}/${SUBJECT}${PREDICATE}.json + local_schema "${SCHEMA_FILE}" echo "==> $SUBJECT $PREDICATE" echo yajsv -s "$SCHEMA_FILE" "$example" - yajsv -s "$SCHEMA_FILE" "$example" || num_failed=$(( num_failed + 1 )) + yajsv -s "${SCHEMA_FILE}.local" "$example" || num_failed=$(( num_failed + 1 )) echo done