From 4852d8007234aa3b46fe54c8433e031e40a4d537 Mon Sep 17 00:00:00 2001 From: Jose Manuel Cantera Date: Tue, 13 Nov 2018 13:18:50 +0100 Subject: [PATCH] Refining more and more. Now using RegExp for Names --- schema/ContextSourceRegistration.json | 4 ++-- schema/Entity.json | 8 +------- schema/EntityList.json | 3 +-- schema/EntityTemporal.json | 4 ++-- schema/EntityTemporalList.json | 10 ++++++++++ schema/Entity_keyValues.json | 2 +- schema/Subscription.json | 3 +-- schema/common.json | 9 +++++++-- scripts/validate_schema.sh | 2 ++ 9 files changed, 27 insertions(+), 18 deletions(-) create mode 100644 schema/EntityTemporalList.json diff --git a/schema/ContextSourceRegistration.json b/schema/ContextSourceRegistration.json index 0b668bd..84a570e 100644 --- a/schema/ContextSourceRegistration.json +++ b/schema/ContextSourceRegistration.json @@ -21,7 +21,7 @@ "type": "array", "minItems": 1, "items": { - "type": "string" + "$ref": "https://forge.etsi.org/gitlab/NGSI-LD/NGSI-LD/raw/master/schema/common.json#/definitions/Name" }, "uniqueItems": true }, @@ -29,7 +29,7 @@ "type": "array", "minItems": 1, "items": { - "type": "string" + "$ref": "https://forge.etsi.org/gitlab/NGSI-LD/NGSI-LD/raw/master/schema/common.json#/definitions/Name" }, "uniqueItems": true } diff --git a/schema/Entity.json b/schema/Entity.json index 6210124..c98fd98 100644 --- a/schema/Entity.json +++ b/schema/Entity.json @@ -4,12 +4,6 @@ "title": "NGSI-LD Entity", "description": "NGSI-LD Entity", "definitions": { - "EntityType": { - "type": "string", - "pattern": "^(\\d|[a-zA-Z]|_)+$", - "minLength": 1, - "description": "NGSI Entity type" - }, "datasetId": { "type": "string", "format": "uri" @@ -150,7 +144,7 @@ "format": "uri" }, "type": { - "$ref": "#/definitions/EntityType" + "$ref": "https://forge.etsi.org/gitlab/NGSI-LD/NGSI-LD/raw/master/schema/common.json#/definitions/Name" }, "@context": { "$ref": "https://forge.etsi.org/gitlab/NGSI-LD/NGSI-LD/raw/master/schema/common.json#/definitions/LdContext" diff --git a/schema/EntityList.json b/schema/EntityList.json index a9f54de..6c4ed68 100644 --- a/schema/EntityList.json +++ b/schema/EntityList.json @@ -6,6 +6,5 @@ "type": "array", "items": { "$ref": "https://forge.etsi.org/gitlab/NGSI-LD/NGSI-LD/raw/master/schema/Entity.json#" - }, - "minItems": 1 + } } diff --git a/schema/EntityTemporal.json b/schema/EntityTemporal.json index b34b50c..526326b 100644 --- a/schema/EntityTemporal.json +++ b/schema/EntityTemporal.json @@ -1,6 +1,6 @@ { "$schema": "http://json-schema.org/schema#", - "id": "https://uri.etsi.org/ngsi-ld/schema/EntityTemporal.json", + "id": "https://forge.etsi.org/gitlab/NGSI-LD/NGSI-LD/raw/master/schema/EntityTemporal.json", "title": "NGSI-LD Entity", "description": "NGSI-LD Temporal Representation of an Entity", "type": "object", @@ -10,7 +10,7 @@ "format": "uri" }, "type": { - "$ref": "https://forge.etsi.org/gitlab/NGSI-LD/NGSI-LD/raw/master/schema/Entity.json#/definitions/EntityType" + "$ref": "https://forge.etsi.org/gitlab/NGSI-LD/NGSI-LD/raw/master/schema/common.json#/definitions/Name" }, "@context": { "$ref": "https://forge.etsi.org/gitlab/NGSI-LD/NGSI-LD/raw/master/schema/common.json#/definitions/LdContext" diff --git a/schema/EntityTemporalList.json b/schema/EntityTemporalList.json new file mode 100644 index 0000000..22b7de0 --- /dev/null +++ b/schema/EntityTemporalList.json @@ -0,0 +1,10 @@ +{ + "$schema": "http://json-schema.org/schema#", + "id": "https://uri.etsi.org/ngsi-ld/schema/EntityTemporalList.json", + "title": "NGSI-LD Entity", + "description": "NGSI-LD Temporal Representation List", + "type": "array", + "items": { + "$ref": "https://forge.etsi.org/gitlab/NGSI-LD/NGSI-LD/raw/master/schema/EntityTemporal.json#" + } +} diff --git a/schema/Entity_keyValues.json b/schema/Entity_keyValues.json index e207b58..e78d348 100644 --- a/schema/Entity_keyValues.json +++ b/schema/Entity_keyValues.json @@ -10,7 +10,7 @@ "format": "uri" }, "type": { - "$ref": "https://forge.etsi.org/gitlab/NGSI-LD/NGSI-LD/raw/master/schema/Entity.json#/definitions/EntityType" + "$ref": "https://forge.etsi.org/gitlab/NGSI-LD/NGSI-LD/raw/master/schema/common.json#/definitions/Name" }, "@context": { "$ref": "https://forge.etsi.org/gitlab/NGSI-LD/NGSI-LD/raw/master/schema/common.json#/definitions/LdContext" diff --git a/schema/Subscription.json b/schema/Subscription.json index 8bce8b5..eb1ee75 100644 --- a/schema/Subscription.json +++ b/schema/Subscription.json @@ -142,8 +142,7 @@ "type": "array", "minItems": 1, "items": { - "type": "string", - "minLength": 1 + "$ref": "https://forge.etsi.org/gitlab/NGSI-LD/NGSI-LD/raw/master/schema/common.json#/definitions/Name" }, "uniqueItems": true }, diff --git a/schema/common.json b/schema/common.json index 189327f..664fa1c 100644 --- a/schema/common.json +++ b/schema/common.json @@ -4,6 +4,12 @@ "title": "NGSI-LD Common Definitions", "description": "NGSI-LD Common", "definitions": { + "Name": { + "type": "string", + "pattern": "^(\\d|[a-zA-Z]|_)+$", + "minLength": 1, + "description": "NGSI-LD Name" + }, "observedAt": { "type": "string", "format": "date-time" @@ -69,8 +75,7 @@ "format": "uri" }, "type": { - "type": "string", - "minLength": 1 + "$ref": "#/definitions/Name" }, "idPattern": { "type": "string", diff --git a/scripts/validate_schema.sh b/scripts/validate_schema.sh index c41c811..32517e6 100755 --- a/scripts/validate_schema.sh +++ b/scripts/validate_schema.sh @@ -14,6 +14,8 @@ ajv compile -s $SCHEMAS/ContextSourceNotification.json -r $SCHEMAS/common.json - ajv compile -s $SCHEMAS/EntityList.json -r $SCHEMAS/common.json -r $SCHEMAS/geometry-schema.json -r $SCHEMAS/Entity.json +ajv compile -s $SCHEMAS/EntityTemporalList.json -r $SCHEMAS/EntityTemporal.json -r $SCHEMAS/Entity.json -r $SCHEMAS/common.json -r $SCHEMAS/geometry-schema.json + ajv compile -s $SCHEMAS/BatchOperationResult.json -r $SCHEMAS/common.json ajv compile -s $SCHEMAS/UpdateResult.json -- GitLab