-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: added negative json examples to verify schemas negatively (#46)
* feat: added negative json examples to verify schemas negatively * fix: add safety pragmas * fix: remove unnecessary non-eamples * fix: add non-eamples for other etensions * fix: fixed the quality schema to actually validate the quality fields
- Loading branch information
1 parent
63d409b
commit f5acad2
Showing
8 changed files
with
227 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
{ | ||
"stac_version": "1.0.0", | ||
"stac_extensions": ["https://linz.github.io/stac/_STAC_VERSION_/camera/schema.json"], | ||
"description": "This is a non-conformant STAC example using the camera extension. The camera:sequence_number field is a string instead of an integer.", | ||
"type": "Feature", | ||
"id": "72360", | ||
"geometry": null, | ||
"properties": { | ||
"datetime": "1952-04-23T00:00:00.000Z", | ||
"platform": "Fixed-wing Aircraft", | ||
"instruments": ["EAGLE IV"], | ||
"mission": "SURVEY_1", | ||
"camera:sequence_number": "incorrect string", | ||
"camera:nominal_focal_length": 508 | ||
}, | ||
"links": [], | ||
"assets": { | ||
".his": { | ||
"href": "./72360.his", | ||
"file:checksum": "1220e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" | ||
}, | ||
"image/tiff; application=geotiff; profile=cloud-optimized": { | ||
"href": "./72360.tiff", | ||
"type": "image/tiff; application=geotiff; profile=cloud-optimized", | ||
"file:checksum": "1220b7deb18ad9dc6f3f94df60c26dd235a019946b8b6b7d1a36f100a8f9f1889130" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"stac_version": "1.0.0", | ||
"stac_extensions": ["https://linz.github.io/stac/_STAC_VERSION_/linz/schema.json"], | ||
"type": "Collection", | ||
"description": "This is a non-conformant STAC example using the linz extension. It is missing the mandatory updated, created and linz:security_classification fields.", | ||
"id": "collection", | ||
"title": "A title", | ||
"license": "Apache-2.0", | ||
"extent": { | ||
"spatial": { | ||
"bbox": [[172.9, 1.3, 173, 1.4]] | ||
}, | ||
"temporal": { | ||
"interval": [["2015-06-23T00:00:00Z", null]] | ||
} | ||
}, | ||
"summaries": { | ||
"datetime": { | ||
"minimum": "2015-06-23T00:00:00Z", | ||
"maximum": "2019-07-10T13:44:56Z" | ||
} | ||
}, | ||
"links": [] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
{ | ||
"stac_version": "1.0.0", | ||
"stac_extensions": [ | ||
"https://stac-extensions.github.io/item-assets/v1.0.0/schema.json", | ||
"https://linz.github.io/stac/_STAC_VERSION_/quality/schema.json" | ||
], | ||
"description": "This is a non-conformant STAC example using the quality extension. quality:description is an integer rather than string.", | ||
"type": "Collection", | ||
"id": "collection", | ||
"title": "A title", | ||
"license": "Apache-2.0", | ||
"extent": { | ||
"spatial": { | ||
"bbox": [[172.9, 1.3, 173, 1.4]] | ||
}, | ||
"temporal": { | ||
"interval": [["2015-06-23T00:00:00Z", null]] | ||
} | ||
}, | ||
"quality:description": 1234, | ||
"quality:horizontal_accuracy": 0.4, | ||
"quality:horizontal_accuracy_type": "Good", | ||
"assets": { | ||
"example": { | ||
"href": "https://example.com/examples/file.xyz" | ||
} | ||
}, | ||
"item_assets": { | ||
"data": { | ||
"roles": ["data"] | ||
} | ||
}, | ||
"summaries": { | ||
"datetime": { | ||
"minimum": "2015-06-23T00:00:00Z", | ||
"maximum": "2019-07-10T13:44:56Z" | ||
} | ||
}, | ||
"links": [ | ||
{ | ||
"href": "https://example.com/examples/collection.json", | ||
"rel": "self" | ||
}, | ||
{ | ||
"href": "https://example.com/examples/item.json", | ||
"rel": "item" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
{ | ||
"stac_version": "1.0.0", | ||
"stac_extensions": [ | ||
"https://stac-extensions.github.io/item-assets/v1.0.0/schema.json", | ||
"https://linz.github.io/stac/_STAC_VERSION_/template/schema.json" | ||
], | ||
"type": "Collection", | ||
"id": "collection", | ||
"title": "A title", | ||
"description": "This is a non-conformant STAC example using the template extension. The template:new_field is an integer rather than string.", | ||
"license": "Apache-2.0", | ||
"extent": { | ||
"spatial": { | ||
"bbox": [[172.9, 1.3, 173, 1.4]] | ||
}, | ||
"temporal": { | ||
"interval": [["2015-06-23T00:00:00Z", null]] | ||
} | ||
}, | ||
"template:new_field": 1234, | ||
"template:xyz": { | ||
"x": 1, | ||
"y": 2, | ||
"z": 3 | ||
}, | ||
"template:another_one": [1, 2, 3], | ||
"assets": { | ||
"example": { | ||
"href": "https://example.com/examples/file.xyz", | ||
"template:new_field": "test" | ||
} | ||
}, | ||
"item_assets": { | ||
"data": { | ||
"roles": ["data"], | ||
"template:new_field": "test" | ||
} | ||
}, | ||
"summaries": { | ||
"datetime": { | ||
"minimum": "2015-06-23T00:00:00Z", | ||
"maximum": "2019-07-10T13:44:56Z" | ||
} | ||
}, | ||
"links": [ | ||
{ | ||
"href": "https://example.com/examples/collection.json", | ||
"rel": "self" | ||
}, | ||
{ | ||
"href": "https://example.com/examples/item.json", | ||
"rel": "item" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
{ | ||
"stac_version": "1.0.0", | ||
"stac_extensions": ["https://linz.github.io/stac/_STAC_VERSION_/template/schema.json"], | ||
"type": "Feature", | ||
"description": "This is a non-conformant STAC example using the template extension. It is missing the mandatory template:new_field.", | ||
"id": "item", | ||
"bbox": [172.9, 1.3, 173, 1.4], | ||
"geometry": { | ||
"type": "Polygon", | ||
"coordinates": [ | ||
[ | ||
[172.9, 1.3], | ||
[173, 1.3], | ||
[173, 1.4], | ||
[172.9, 1.4], | ||
[172.9, 1.3] | ||
] | ||
] | ||
}, | ||
"properties": { | ||
"datetime": "2020-12-11T22:38:32Z", | ||
"template:xyz": { | ||
"x": 1, | ||
"y": 2, | ||
"z": 3 | ||
}, | ||
"template:another_one": [1, 2, 3] | ||
}, | ||
"links": [ | ||
{ | ||
"href": "https://example.com/examples/item.json", | ||
"rel": "self" | ||
} | ||
], | ||
"assets": { | ||
"data": { | ||
"href": "https://example.com/examples/file.xyz" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,24 @@ | ||
#!/usr/bin/env bash | ||
node_modules/.bin/stac-node-validator \ | ||
--schemaMap=https://linz.github.io/stac/_STAC_VERSION_/template/schema.json=extensions/template/schema.json \ | ||
--schemaMap=https://linz.github.io/stac/_STAC_VERSION_/camera/schema.json=extensions/camera/schema.json \ | ||
--schemaMap=https://linz.github.io/stac/_STAC_VERSION_/quality/schema.json=extensions/quality/schema.json \ | ||
--schemaMap=https://linz.github.io/stac/_STAC_VERSION_/linz/schema.json=extensions/linz/schema.json \ | ||
${@+"$@"} | ||
|
||
set -o errexit -o nounset | ||
shopt -s failglob | ||
|
||
validator_command=( | ||
node_modules/.bin/stac-node-validator | ||
--schemaMap=https://linz.github.io/stac/_STAC_VERSION_/template/schema.json=extensions/template/schema.json | ||
--schemaMap=https://linz.github.io/stac/_STAC_VERSION_/camera/schema.json=extensions/camera/schema.json | ||
--schemaMap=https://linz.github.io/stac/_STAC_VERSION_/quality/schema.json=extensions/quality/schema.json | ||
--schemaMap=https://linz.github.io/stac/_STAC_VERSION_/linz/schema.json=extensions/linz/schema.json | ||
) | ||
"${validator_command[@]}" extensions/*/examples/*.json | ||
|
||
for path in extensions/*/non-examples/*.json | ||
do | ||
if "${validator_command[@]}" "$path" | ||
then | ||
echo "Valid non-example: ${path}" >&2 | ||
exit_code=1 | ||
fi | ||
done | ||
|
||
exit "${exit_code-0}" |