From d05d3f90c15e5523d8fe0a648f91bda0ad1ad64d Mon Sep 17 00:00:00 2001 From: Nate Ferrell Date: Sat, 2 Nov 2024 18:07:32 -0500 Subject: [PATCH] feat: #comment shifted location-identifier to central definition in core schema --- .../mistyped-osid-location-identifier.json | 2 +- examples/full/valid/core-schema-example.json | 2 +- schema/core-schema.json | 17 ++++++++++------- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/examples/full/invalid/mistyped-osid-location-identifier.json b/examples/full/invalid/mistyped-osid-location-identifier.json index df882eb..80abc17 100644 --- a/examples/full/invalid/mistyped-osid-location-identifier.json +++ b/examples/full/invalid/mistyped-osid-location-identifier.json @@ -1,5 +1,5 @@ { - "$schema": "https://raw.githubusercontent.com/opensupplyhub/supplychaindata.exchange/refs/heads/main/schema/core-schema.json", + "$schema": "../../../schema/core-schema.json", "locations": [ { "guid": "82d39ac8-1a12-4801-835a-85d319927548", diff --git a/examples/full/valid/core-schema-example.json b/examples/full/valid/core-schema-example.json index 70d9d87..ab4f70c 100644 --- a/examples/full/valid/core-schema-example.json +++ b/examples/full/valid/core-schema-example.json @@ -1,5 +1,5 @@ { - "$schema": "https://raw.githubusercontent.com/opensupplyhub/supplychaindata.exchange/refs/heads/main/schema/core-schema.json", + "$schema": "../../../schema/core-schema.json", "locations": [ { "guid": "82d39ac8-1a12-4801-835a-85d319927548", diff --git a/schema/core-schema.json b/schema/core-schema.json index f2297c2..6668b81 100644 --- a/schema/core-schema.json +++ b/schema/core-schema.json @@ -27,16 +27,12 @@ "description": "Accepted location identifier, which can be a single string (e.g., 'osid:XXXXXXXX', 'gfid:XXXXXXXX') or an array of such strings (osid stands for open supply hub ID, and gfid for Global Field ID)", "anyOf": [ { - "type": "string", - "pattern": "^(osid|gfid):[A-Za-z0-9]+$", - "description": "A single location identifier string with a specific prefix (e.g., 'osid:' or 'gfid:')" + "$ref": "#/definitions/location-identifier" }, { "type": "array", "items": { - "type": "string", - "pattern": "^(osid|gfid):[A-Za-z0-9]+$", - "description": "Each item in the array must be a location identifier string with a specific prefix" + "$ref": "#/definitions/location-identifier" }, "minItems": 1, "description": "An array of location identifier strings" @@ -259,5 +255,12 @@ }, "required": [ "locations" - ] + ], + "definitions": { + "location-identifier": { + "type": "string", + "pattern": "^(osid|gfid):[A-Za-z0-9]+$", + "description": "A location identifier string with a specific prefix (e.g., 'osid:', 'gfid:')" + } + } } \ No newline at end of file