Skip to content

Commit 41e22ca

Browse files
Merge pull request #25 from ESA-EarthCODE/fix-osc-validation
Fix OSC validation
2 parents 338a1df + 569f0c2 commit 41e22ca

6 files changed

Lines changed: 17 additions & 32 deletions

File tree

definitions.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ const EXTENSION_SCHEMES = {
22
themes: 'https://stac-extensions.github.io/themes/v1.0.0/schema.json',
33
contacts: 'https://stac-extensions.github.io/contacts/v0.1.1/schema.json',
44
// TODO add "Scientific Citation Extension Specification" for DOIs
5-
osc: 'https://stac-extensions.github.io/osc/v1.0.0-rc.3/schema.json'
5+
osc: 'https://stac-extensions.github.io/osc/v1.0.0/schema.json'
66
};
77

88
const ROOT_CHILDREN = [

schemas/experiments/children.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,6 @@
3030
"hidden": true
3131
}
3232
},
33-
"osc:name": {
34-
"$ref": "../collection.json#/definitions/osc_name"
35-
},
3633
"osc:status": {
3734
"$ref": "../collection.json#/definitions/osc_status"
3835
},

schemas/products/children.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,6 @@
2424
"hidden": true
2525
}
2626
},
27-
"osc:name": {
28-
"$ref": "../collection.json#/definitions/osc_name"
29-
},
3027
"osc:status": {
3128
"$ref": "../collection.json#/definitions/osc_status"
3229
},

schemas/projects/children.json

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,12 @@
1818
"hidden": true
1919
}
2020
},
21-
"osc:name": {
22-
"$ref": "../collection.json#/definitions/osc_name"
23-
},
2421
"osc:status": {
2522
"$ref": "../collection.json#/definitions/osc_status"
2623
},
2724
"osc:region": {
2825
"$ref": "../collection.json#/definitions/osc_region"
2926
},
30-
"osc:missions": {
31-
"$ref": "../collection.json#/definitions/osc_missions"
32-
},
3327
"themes": {
3428
"$ref": "../collection.json#/definitions/themes"
3529
},

schemas/workflows/children.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,6 @@
3030
"hidden": true
3131
}
3232
},
33-
"osc:name": {
34-
"$ref": "../collection.json#/definitions/osc_name"
35-
},
3633
"osc:status": {
3734
"$ref": "../collection.json#/definitions/osc_status"
3835
},

validate.js

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,15 @@ class ValidationRun {
249249
await this.requireParentLink("../catalog.json");
250250
await this.requireRootLink("../../catalog.json");
251251

252-
await this.checkOscExtension("product");
252+
this.t.equal(this.data["osc:type"], "product", `'osc:type' must be 'product'`);
253+
this.t.equal(typeof this.data["osc:project"], 'string', `'osc:project' must be a string`);
254+
if (typeof this.data["osc:project"] === 'string') {
255+
await this.checkOscCrossRef(this.data["osc:project"], "projects");
256+
}
257+
await this.checkOscCrossRefArray(this.data, "osc:variables", "variables");
258+
await this.checkOscCrossRefArray(this.data, "osc:missions", "eo-missions");
259+
260+
await this.checkThemes(this.data);
253261
}
254262

255263
async validateProject() {
@@ -263,7 +271,12 @@ class ValidationRun {
263271

264272
this.requireTechnicalOfficer();
265273

266-
await this.checkOscExtension("project");
274+
this.t.equal(this.data["osc:type"], "project", `'osc:type' must be 'project'`);
275+
this.t.truthy(typeof data['osc:project'] === 'undefined', `'osc:project' must be NOT be present`);
276+
this.t.truthy(typeof data['osc:variables'] === 'undefined', `'osc:variables' must be NOT be present`);
277+
this.t.truthy(typeof data['osc:missions'] === 'undefined', `'osc:missions' must be NOT be present`);
278+
279+
await this.checkThemes(this.data);
267280
}
268281

269282
async validateTheme() {
@@ -405,20 +418,6 @@ class ValidationRun {
405418
}
406419
}
407420

408-
async checkOscExtension(type) {
409-
this.t.equal(this.data["osc:type"], type, `'osc:type' must be '${type}'`);
410-
411-
if (type === "product") {
412-
this.t.equal(typeof this.data["osc:project"], 'string', `'osc:project' must be a string`);
413-
if (typeof this.data["osc:project"] === 'string') {
414-
await this.checkOscCrossRef(this.data["osc:project"], "projects");
415-
}
416-
await this.checkOscCrossRefArray(this.data, "osc:variables", "variables");
417-
}
418-
await this.checkOscCrossRefArray(this.data, "osc:missions", "eo-missions");
419-
await this.checkThemes(this.data);
420-
}
421-
422421
async checkThemes(data) {
423422
this.t.truthy(Array.isArray(data.themes), `'themes' must be present as an array`);
424423
this.t.truthy(typeof data['osc:themes'] === 'undefined', `'osc:themes' must be NOT be present any longer`);
@@ -433,6 +432,7 @@ class ValidationRun {
433432
const exists = await this.parent.fileExists(filepath);
434433
this.t.truthy(exists, `The referenced theme '${obj.id}' must exist at ${filepath}`);
435434
}));
435+
this.t.truthy(Array.isArray(data.links), `'links' must be present as an array`);
436436
theme.concepts.forEach((obj) => {
437437
const link = data.links.find(link => link.rel === "related" && link.href.endsWith(`/themes/${obj.id}/catalog.json`));
438438
this.t.truthy(link, `must have a 'related' link to the theme '${obj.id}'`);

0 commit comments

Comments
 (0)