From 4b8d82a4f59f13f4cf3a970af90abb3df0572b86 Mon Sep 17 00:00:00 2001 From: Victor Engmark Date: Fri, 18 Oct 2024 09:52:28 +1300 Subject: [PATCH] feat: Add `linz:slug` field TDE-1283 --- extensions/linz/examples/collection.json | 1 + extensions/linz/schema.json | 7 +++++++ extensions/linz/tests/linz_collection.test.mjs | 17 +++++++++++++++++ 3 files changed, 25 insertions(+) diff --git a/extensions/linz/examples/collection.json b/extensions/linz/examples/collection.json index ff44c167..d8e51084 100644 --- a/extensions/linz/examples/collection.json +++ b/extensions/linz/examples/collection.json @@ -70,6 +70,7 @@ "quality:horizontal_accuracy_type": "nominal", "linz:history": "This is an example dataset lineage description.", "linz:update_frequency": "P1Y", + "linz:slug": "new-zealand_2015_1m", "providers": [ { "name": "Example", diff --git a/extensions/linz/schema.json b/extensions/linz/schema.json index 4e09bf36..c41e06f6 100644 --- a/extensions/linz/schema.json +++ b/extensions/linz/schema.json @@ -114,6 +114,12 @@ "wellington", "west-coast" ] + }, + "linz:slug": { + "type": "string", + "minLength": 1, + "description": "The '--' part of the Open Data Registry path.", + "examples": ["banks-peninsula_2019-2020_0.075m", "new-zealand_2015_1m"] } } }, @@ -1088,6 +1094,7 @@ "type": "string", "enum": ["unclassified", "in-confidence", "sensitive", "restricted", "confidential", "secret", "top-secret"] }, + "linz:slug": {}, "linz:update_frequency": { "type": "string", "format": "duration" diff --git a/extensions/linz/tests/linz_collection.test.mjs b/extensions/linz/tests/linz_collection.test.mjs index 96d75141..11077791 100644 --- a/extensions/linz/tests/linz_collection.test.mjs +++ b/extensions/linz/tests/linz_collection.test.mjs @@ -579,4 +579,21 @@ o.spec('LINZ collection', () => { // then o(valid).equals(true); }); + + o("Collection with invalid 'linz:slug' value should fail validation", async () => { + // given + const example = JSON.parse(await fs.readFile(examplePath)); + example['linz:slug'] = ''; + + // when + let valid = validate(example); + + // then + o(valid).equals(false); + o( + validate.errors.some( + (error) => error.instancePath === '/linz:slug' && error.message === 'must NOT have fewer than 1 characters', + ), + ).equals(true)(JSON.stringify(validate.errors)); + }); });