Skip to content

Commit

Permalink
feat: better validation errors from CLI
Browse files Browse the repository at this point in the history
  • Loading branch information
gadomski committed Sep 22, 2023
1 parent 95eea7b commit 22ca55e
Show file tree
Hide file tree
Showing 3 changed files with 112 additions and 1 deletion.
1 change: 1 addition & 0 deletions stac-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ console = "0.15"
indicatif = "0.17"
reqwest = "0.11"
serde = "1"
serde_json = "1"
stac = { version = "0.5", path = "../stac" }
stac-async = { version = "0.4", path = "../stac-async" }
stac-validate = { version = "0.1", path = "../stac-validate" }
Expand Down
2 changes: 1 addition & 1 deletion stac-cli/src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ impl Command {
}
}
Validate { href } => {
let value: Value = stac_async::read(href).await?;
let value: serde_json::Value = stac_async::read_json(&href).await?;
let result = {
let value = value.clone();
tokio::task::spawn_blocking(move || value.validate()).await?
Expand Down
110 changes: 110 additions & 0 deletions stac-cli/tests/data/collection-bad-temporal.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
{
"id": "simple-collection",
"type": "Collection",
"stac_extensions": [
"https://stac-extensions.github.io/eo/v1.0.0/schema.json",
"https://stac-extensions.github.io/projection/v1.0.0/schema.json",
"https://stac-extensions.github.io/view/v1.0.0/schema.json"
],
"stac_version": "1.0.0",
"description": "A simple collection demonstrating core catalog fields with links to a couple of items",
"title": "Simple Example Collection",
"providers": [
{
"name": "Remote Data, Inc",
"description": "Producers of awesome spatiotemporal assets",
"roles": [
"producer",
"processor"
],
"url": "http://remotedata.io"
}
],
"extent": {
"spatial": {
"bbox": [
[
172.91173669923782,
1.3438851951615003,
172.95469614953714,
1.3690476620161975
]
]
},
"temporal": [
[
"2020-12-11T22:38:32.125Z",
"2020-12-14T18:02:31.437Z"
]
]
},
"license": "CC-BY-4.0",
"summaries": {
"platform": [
"cool_sat1",
"cool_sat2"
],
"constellation": [
"ion"
],
"instruments": [
"cool_sensor_v1",
"cool_sensor_v2"
],
"gsd": {
"minimum": 0.512,
"maximum": 0.66
},
"eo:cloud_cover": {
"minimum": 1.2,
"maximum": 1.2
},
"proj:epsg": {
"minimum": 32659,
"maximum": 32659
},
"view:sun_elevation": {
"minimum": 54.9,
"maximum": 54.9
},
"view:off_nadir": {
"minimum": 3.8,
"maximum": 3.8
},
"view:sun_azimuth": {
"minimum": 135.7,
"maximum": 135.7
}
},
"links": [
{
"rel": "root",
"href": "./collection.json",
"type": "application/json",
"title": "Simple Example Collection"
},
{
"rel": "item",
"href": "./simple-item.json",
"type": "application/geo+json",
"title": "Simple Item"
},
{
"rel": "item",
"href": "./core-item.json",
"type": "application/geo+json",
"title": "Core Item"
},
{
"rel": "item",
"href": "./extended-item.json",
"type": "application/geo+json",
"title": "Extended Item"
},
{
"rel": "self",
"href": "https://raw.githubusercontent.com/radiantearth/stac-spec/v1.0.0/examples/collection.json",
"type": "application/json"
}
]
}

0 comments on commit 22ca55e

Please sign in to comment.