From f27a46e11fa0cdb5fd0b73439f42e341c8b7b3f8 Mon Sep 17 00:00:00 2001 From: Jose Manuel Cantera Date: Tue, 13 Nov 2018 12:47:55 +0100 Subject: [PATCH] Entity Key Values --- schema/Entity.json | 10 ++++--- schema/EntityTemporal.json | 4 +-- schema/Entity_keyValues.json | 51 ++++++++++++++++++++++++++++++++++++ scripts/validate_schema.sh | 1 + 4 files changed, 60 insertions(+), 6 deletions(-) create mode 100644 schema/Entity_keyValues.json diff --git a/schema/Entity.json b/schema/Entity.json index a0c4acf..6210124 100644 --- a/schema/Entity.json +++ b/schema/Entity.json @@ -4,6 +4,12 @@ "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" @@ -144,9 +150,7 @@ "format": "uri" }, "type": { - "type": "string", - "description": "NGSI Entity type", - "minLength": 1 + "$ref": "#/definitions/EntityType" }, "@context": { "$ref": "https://forge.etsi.org/gitlab/NGSI-LD/NGSI-LD/raw/master/schema/common.json#/definitions/LdContext" diff --git a/schema/EntityTemporal.json b/schema/EntityTemporal.json index f362b4e..b34b50c 100644 --- a/schema/EntityTemporal.json +++ b/schema/EntityTemporal.json @@ -10,9 +10,7 @@ "format": "uri" }, "type": { - "type": "string", - "description": "NGSI Entity type", - "minLength": 1 + "$ref": "https://forge.etsi.org/gitlab/NGSI-LD/NGSI-LD/raw/master/schema/Entity.json#/definitions/EntityType" }, "@context": { "$ref": "https://forge.etsi.org/gitlab/NGSI-LD/NGSI-LD/raw/master/schema/common.json#/definitions/LdContext" diff --git a/schema/Entity_keyValues.json b/schema/Entity_keyValues.json new file mode 100644 index 0000000..e207b58 --- /dev/null +++ b/schema/Entity_keyValues.json @@ -0,0 +1,51 @@ +{ + "$schema": "http://json-schema.org/schema#", + "id": "https://uri.etsi.org/ngsi-ld/schema/Entity_keyValues.json", + "title": "NGSI-LD Entity Key Values", + "description": "NGSI-LD Entity Simplified Representation", + "type": "object", + "properties": { + "id": { + "type": "string", + "format": "uri" + }, + "type": { + "$ref": "https://forge.etsi.org/gitlab/NGSI-LD/NGSI-LD/raw/master/schema/Entity.json#/definitions/EntityType" + }, + "@context": { + "$ref": "https://forge.etsi.org/gitlab/NGSI-LD/NGSI-LD/raw/master/schema/common.json#/definitions/LdContext" + }, + "location": { + "$ref": "https://forge.etsi.org/gitlab/NGSI-LD/NGSI-LD/raw/master/schema/geometry-schema.json#" + }, + "observationSpace": { + "$ref": "https://forge.etsi.org/gitlab/NGSI-LD/NGSI-LD/raw/master/schema/geometry-schema.json#" + }, + "operationSpace": { + "$ref": "https://forge.etsi.org/gitlab/NGSI-LD/NGSI-LD/raw/master/schema/geometry-schema.json#" + }, + "createdAt": { + "$ref": "https://forge.etsi.org/gitlab/NGSI-LD/NGSI-LD/raw/master/schema/common.json#/definitions/createdAt" + }, + "modifiedAt": { + "$ref": "https://forge.etsi.org/gitlab/NGSI-LD/NGSI-LD/raw/master/schema/common.json#/definitions/modifiedAt" + } + }, + "required": [ + "type", + "id" + ], + "additionalProperties": { + "type": [ + "string", + "number", + "boolean", + "array", + "object" + ] + }, + "propertyNames": { + "type": "string", + "pattern": "^((\\d|[a-zA-Z]|_)+(#\\d+)?)$" + } +} diff --git a/scripts/validate_schema.sh b/scripts/validate_schema.sh index f5353b2..c41c811 100755 --- a/scripts/validate_schema.sh +++ b/scripts/validate_schema.sh @@ -18,3 +18,4 @@ ajv compile -s $SCHEMAS/BatchOperationResult.json -r $SCHEMAS/common.json ajv compile -s $SCHEMAS/UpdateResult.json +ajv compile -s $SCHEMAS/Entity_keyValues.json -r $SCHEMAS/common.json -r $SCHEMAS/geometry-schema.json -r $SCHEMAS/Entity.json -- GitLab