Skip to content

Commit

Permalink
Fix references to link schemas
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
afrittoli committed Mar 6, 2024
1 parent 46702c3 commit a8eab81
Show file tree
Hide file tree
Showing 42 changed files with 52 additions and 43 deletions.
2 changes: 1 addition & 1 deletion schemas/artifactdeleted.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"minLength": 1
},
"links": {
"$ref": "links/embeddedlinksarray.json"
"$ref": "/schema/links/embeddedlinksarray.json"
}
},
"additionalProperties": false,
Expand Down
2 changes: 1 addition & 1 deletion schemas/artifactdownloaded.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"minLength": 1
},
"links": {
"$ref": "links/embeddedlinksarray.json"
"$ref": "/schema/links/embeddedlinksarray.json"
}
},
"additionalProperties": false,
Expand Down
2 changes: 1 addition & 1 deletion schemas/artifactpackaged.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"minLength": 1
},
"links": {
"$ref": "links/embeddedlinksarray.json"
"$ref": "/schema/links/embeddedlinksarray.json"
}
},
"additionalProperties": false,
Expand Down
2 changes: 1 addition & 1 deletion schemas/artifactpublished.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"minLength": 1
},
"links": {
"$ref": "links/embeddedlinksarray.json"
"$ref": "/schema/links/embeddedlinksarray.json"
}
},
"additionalProperties": false,
Expand Down
2 changes: 1 addition & 1 deletion schemas/artifactsigned.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"minLength": 1
},
"links": {
"$ref": "links/embeddedlinksarray.json"
"$ref": "/schema/links/embeddedlinksarray.json"
}
},
"additionalProperties": false,
Expand Down
2 changes: 1 addition & 1 deletion schemas/branchcreated.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"minLength": 1
},
"links": {
"$ref": "links/embeddedlinksarray.json"
"$ref": "/schema/links/embeddedlinksarray.json"
}
},
"additionalProperties": false,
Expand Down
2 changes: 1 addition & 1 deletion schemas/branchdeleted.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"minLength": 1
},
"links": {
"$ref": "links/embeddedlinksarray.json"
"$ref": "/schema/links/embeddedlinksarray.json"
}
},
"additionalProperties": false,
Expand Down
2 changes: 1 addition & 1 deletion schemas/buildfinished.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"minLength": 1
},
"links": {
"$ref": "links/embeddedlinksarray.json"
"$ref": "/schema/links/embeddedlinksarray.json"
}
},
"additionalProperties": false,
Expand Down
2 changes: 1 addition & 1 deletion schemas/buildqueued.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"minLength": 1
},
"links": {
"$ref": "links/embeddedlinksarray.json"
"$ref": "/schema/links/embeddedlinksarray.json"
}
},
"additionalProperties": false,
Expand Down
2 changes: 1 addition & 1 deletion schemas/buildstarted.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"minLength": 1
},
"links": {
"$ref": "links/embeddedlinksarray.json"
"$ref": "/schema/links/embeddedlinksarray.json"
}
},
"additionalProperties": false,
Expand Down
2 changes: 1 addition & 1 deletion schemas/changeabandoned.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"minLength": 1
},
"links": {
"$ref": "links/embeddedlinksarray.json"
"$ref": "/schema/links/embeddedlinksarray.json"
}
},
"additionalProperties": false,
Expand Down
2 changes: 1 addition & 1 deletion schemas/changecreated.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"minLength": 1
},
"links": {
"$ref": "links/embeddedlinksarray.json"
"$ref": "/schema/links/embeddedlinksarray.json"
}
},
"additionalProperties": false,
Expand Down
2 changes: 1 addition & 1 deletion schemas/changemerged.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"minLength": 1
},
"links": {
"$ref": "links/embeddedlinksarray.json"
"$ref": "/schema/links/embeddedlinksarray.json"
}
},
"additionalProperties": false,
Expand Down
2 changes: 1 addition & 1 deletion schemas/changereviewed.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"minLength": 1
},
"links": {
"$ref": "links/embeddedlinksarray.json"
"$ref": "/schema/links/embeddedlinksarray.json"
}
},
"additionalProperties": false,
Expand Down
2 changes: 1 addition & 1 deletion schemas/changeupdated.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"minLength": 1
},
"links": {
"$ref": "links/embeddedlinksarray.json"
"$ref": "/schema/links/embeddedlinksarray.json"
}
},
"additionalProperties": false,
Expand Down
2 changes: 1 addition & 1 deletion schemas/environmentcreated.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"minLength": 1
},
"links": {
"$ref": "links/embeddedlinksarray.json"
"$ref": "/schema/links/embeddedlinksarray.json"
}
},
"additionalProperties": false,
Expand Down
2 changes: 1 addition & 1 deletion schemas/environmentdeleted.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"minLength": 1
},
"links": {
"$ref": "links/embeddedlinksarray.json"
"$ref": "/schema/links/embeddedlinksarray.json"
}
},
"additionalProperties": false,
Expand Down
2 changes: 1 addition & 1 deletion schemas/environmentmodified.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"minLength": 1
},
"links": {
"$ref": "links/embeddedlinksarray.json"
"$ref": "/schema/links/embeddedlinksarray.json"
}
},
"additionalProperties": false,
Expand Down
2 changes: 1 addition & 1 deletion schemas/incidentdetected.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"minLength": 1
},
"links": {
"$ref": "links/embeddedlinksarray.json"
"$ref": "/schema/links/embeddedlinksarray.json"
}
},
"additionalProperties": false,
Expand Down
2 changes: 1 addition & 1 deletion schemas/incidentreported.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"minLength": 1
},
"links": {
"$ref": "links/embeddedlinksarray.json"
"$ref": "/schema/links/embeddedlinksarray.json"
}
},
"additionalProperties": false,
Expand Down
2 changes: 1 addition & 1 deletion schemas/incidentresolved.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"minLength": 1
},
"links": {
"$ref": "links/embeddedlinksarray.json"
"$ref": "/schema/links/embeddedlinksarray.json"
}
},
"additionalProperties": false,
Expand Down
2 changes: 1 addition & 1 deletion schemas/pipelinerunfinished.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"minLength": 1
},
"links": {
"$ref": "links/embeddedlinksarray.json"
"$ref": "/schema/links/embeddedlinksarray.json"
}
},
"additionalProperties": false,
Expand Down
2 changes: 1 addition & 1 deletion schemas/pipelinerunqueued.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"minLength": 1
},
"links": {
"$ref": "links/embeddedlinksarray.json"
"$ref": "/schema/links/embeddedlinksarray.json"
}
},
"additionalProperties": false,
Expand Down
2 changes: 1 addition & 1 deletion schemas/pipelinerunstarted.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"minLength": 1
},
"links": {
"$ref": "links/embeddedlinksarray.json"
"$ref": "/schema/links/embeddedlinksarray.json"
}
},
"additionalProperties": false,
Expand Down
2 changes: 1 addition & 1 deletion schemas/repositorycreated.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"minLength": 1
},
"links": {
"$ref": "links/embeddedlinksarray.json"
"$ref": "/schema/links/embeddedlinksarray.json"
}
},
"additionalProperties": false,
Expand Down
2 changes: 1 addition & 1 deletion schemas/repositorydeleted.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"minLength": 1
},
"links": {
"$ref": "links/embeddedlinksarray.json"
"$ref": "/schema/links/embeddedlinksarray.json"
}
},
"additionalProperties": false,
Expand Down
2 changes: 1 addition & 1 deletion schemas/repositorymodified.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"minLength": 1
},
"links": {
"$ref": "links/embeddedlinksarray.json"
"$ref": "/schema/links/embeddedlinksarray.json"
}
},
"additionalProperties": false,
Expand Down
2 changes: 1 addition & 1 deletion schemas/servicedeployed.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"minLength": 1
},
"links": {
"$ref": "links/embeddedlinksarray.json"
"$ref": "/schema/links/embeddedlinksarray.json"
}
},
"additionalProperties": false,
Expand Down
2 changes: 1 addition & 1 deletion schemas/servicepublished.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"minLength": 1
},
"links": {
"$ref": "links/embeddedlinksarray.json"
"$ref": "/schema/links/embeddedlinksarray.json"
}
},
"additionalProperties": false,
Expand Down
2 changes: 1 addition & 1 deletion schemas/serviceremoved.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"minLength": 1
},
"links": {
"$ref": "links/embeddedlinksarray.json"
"$ref": "/schema/links/embeddedlinksarray.json"
}
},
"additionalProperties": false,
Expand Down
2 changes: 1 addition & 1 deletion schemas/servicerolledback.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"minLength": 1
},
"links": {
"$ref": "links/embeddedlinksarray.json"
"$ref": "/schema/links/embeddedlinksarray.json"
}
},
"additionalProperties": false,
Expand Down
2 changes: 1 addition & 1 deletion schemas/serviceupgraded.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"minLength": 1
},
"links": {
"$ref": "links/embeddedlinksarray.json"
"$ref": "/schema/links/embeddedlinksarray.json"
}
},
"additionalProperties": false,
Expand Down
2 changes: 1 addition & 1 deletion schemas/taskrunfinished.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"minLength": 1
},
"links": {
"$ref": "links/embeddedlinksarray.json"
"$ref": "/schema/links/embeddedlinksarray.json"
}
},
"additionalProperties": false,
Expand Down
2 changes: 1 addition & 1 deletion schemas/taskrunstarted.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"minLength": 1
},
"links": {
"$ref": "links/embeddedlinksarray.json"
"$ref": "/schema/links/embeddedlinksarray.json"
}
},
"additionalProperties": false,
Expand Down
2 changes: 1 addition & 1 deletion schemas/testcaserunfinished.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"minLength": 1
},
"links": {
"$ref": "links/embeddedlinksarray.json"
"$ref": "/schema/links/embeddedlinksarray.json"
}
},
"additionalProperties": false,
Expand Down
2 changes: 1 addition & 1 deletion schemas/testcaserunqueued.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"minLength": 1
},
"links": {
"$ref": "links/embeddedlinksarray.json"
"$ref": "/schema/links/embeddedlinksarray.json"
}
},
"additionalProperties": false,
Expand Down
2 changes: 1 addition & 1 deletion schemas/testcaserunstarted.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"minLength": 1
},
"links": {
"$ref": "links/embeddedlinksarray.json"
"$ref": "/schema/links/embeddedlinksarray.json"
}
},
"additionalProperties": false,
Expand Down
2 changes: 1 addition & 1 deletion schemas/testoutputpublished.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"minLength": 1
},
"links": {
"$ref": "links/embeddedlinksarray.json"
"$ref": "/schema/links/embeddedlinksarray.json"
}
},
"additionalProperties": false,
Expand Down
2 changes: 1 addition & 1 deletion schemas/testsuiterunfinished.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"minLength": 1
},
"links": {
"$ref": "links/embeddedlinksarray.json"
"$ref": "/schema/links/embeddedlinksarray.json"
}
},
"additionalProperties": false,
Expand Down
2 changes: 1 addition & 1 deletion schemas/testsuiterunqueued.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"minLength": 1
},
"links": {
"$ref": "links/embeddedlinksarray.json"
"$ref": "/schema/links/embeddedlinksarray.json"
}
},
"additionalProperties": false,
Expand Down
2 changes: 1 addition & 1 deletion schemas/testsuiterunstarted.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"minLength": 1
},
"links": {
"$ref": "links/embeddedlinksarray.json"
"$ref": "/schema/links/embeddedlinksarray.json"
}
},
"additionalProperties": false,
Expand Down
13 changes: 11 additions & 2 deletions tools/verify-examples.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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/[email protected]

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
Expand All @@ -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

Expand Down

0 comments on commit a8eab81

Please sign in to comment.