Skip to content

Instantly share code, notes, and snippets.

@fgalan
Created April 9, 2019 11:16
Show Gist options
  • Save fgalan/e115e7179b6bc3b2215de4813075ba9e to your computer and use it in GitHub Desktop.
Save fgalan/e115e7179b6bc3b2215de4813075ba9e to your computer and use it in GitHub Desktop.
Fixed JSON Schema for NGSIv2
$ diff -u ngsiv2-draft-schema.orig.json ngsiv2-draft-schema.json
--- ngsiv2-draft-schema.orig.json 2019-04-08 12:23:44.103171653 +0200
+++ ngsiv2-draft-schema.json 2019-04-09 13:05:47.637837620 +0200
@@ -10,26 +10,6 @@
"maxLength": 256,
"pattern": "^[\\w\\-\\.\\{\\}\\$\\+\\*\\[\\]`|~^@!,:\\\\]+$"
},
- "Name": {
- "allOf": [
- {
- "$ref": "#/definitions/Identifier"
- },
- {
- "not": {
- "type": "string",
- "const": "geo:distance"
- }
- },
- {
- "not": {
- "type": "string",
- "const": "*"
- }
- }
- ],
- "description": "NGSIv2 Name"
- },
"Value": {
"type": [
"number",
@@ -40,13 +20,13 @@
"string"
]
},
- "TypeValue": {
+ "AttributeTypeValue": {
"type": "object",
"properties": {
"type": {
"allOf": [
{
- "$ref": "#/definitions/Name"
+ "$ref": "#/definitions/Identifier"
},
{
"not": {
@@ -68,6 +48,30 @@
"value"
]
},
+ "MetadataTypeValue": {
+ "type": "object",
+ "properties": {
+ "type": {
+ "allOf": [
+ {
+ "$ref": "#/definitions/Identifier"
+ },
+ {
+ "not": {
+ "const": "DateTime"
+ }
+ }
+ ]
+ },
+ "value": {
+ "$ref": "#/definitions/Value"
+ }
+ },
+ "required": [
+ "value"
+ ]
+ },
+
"DateTimeValue": {
"type": "string",
"format": "date-time"
@@ -114,7 +118,7 @@
"$ref": "#/definitions/DateTimeTypeValue"
},
"previousValue": {
- "$ref": "#/definitions/TypeValue"
+ "$ref": "#/definitions/AttributeTypeValue"
},
"actionType": {
"type": "object",
@@ -141,7 +145,7 @@
"additionalProperties": {
"anyOf": [
{
- "$ref": "#/definitions/TypeValue"
+ "$ref": "#/definitions/MetadataTypeValue"
},
{
"$ref": "#/definitions/DateTimeTypeValue"
@@ -151,7 +155,10 @@
"propertyNames": {
"allOf": [
{
- "$ref": "#/definitions/Name"
+ "not": {
+ "type": "string",
+ "const": "*"
+ }
}
]
}
@@ -162,6 +169,9 @@
"dateModified": {
"$ref": "#/definitions/DateTimeTypeValue"
},
+ "dateExpires": {
+ "$ref": "#/definitions/DateTimeTypeValue"
+ },
"Attribute": {
"allOf": [
{
@@ -173,7 +183,7 @@
"$ref": "#/definitions/GeoTypeValue"
},
{
- "$ref": "#/definitions/TypeValue"
+ "$ref": "#/definitions/AttributeTypeValue"
}
]
},
@@ -196,7 +206,7 @@
"type": {
"allOf": [
{
- "$ref": "#/definitions/Name"
+ "$ref": "#/definitions/Identifier"
},
{
"default": "Thing"
@@ -208,10 +218,26 @@
},
"dateModified": {
"$ref": "#/definitions/dateModified"
+ },
+ "dateExpires": {
+ "$ref": "#/definitions/dateExpires"
}
},
"propertyNames": {
- "$ref": "#/definitions/Name"
+ "allOf": [
+ {
+ "not": {
+ "type": "string",
+ "const": "geo:distance"
+ }
+ },
+ {
+ "not": {
+ "type": "string",
+ "const": "*"
+ }
+ }
+ ]
},
"additionalProperties": {
"anyOf": [
{
"$schema": "http://json-schema.org/schema#",
"id": "https://fiware.github.io/dataModels/Entity-ngsiv2-datamodels-schema.json",
"title": "NGSIv2 Entity. Normalized Format for FIWARE Data Models",
"description": "NGSIv2 Entity. Normalized Format aligned with the usage given by FIWARE Data Models. Restrictions: geo:point, geo:line, geo:polygon, geo:box not covered. keyValues representation not covered",
"definitions": {
"Identifier": {
"type": "string",
"minLength": 1,
"maxLength": 256,
"pattern": "^[\\w\\-\\.\\{\\}\\$\\+\\*\\[\\]`|~^@!,:\\\\]+$"
},
"Value": {
"type": [
"number",
"boolean",
"array",
"object",
"null",
"string"
]
},
"AttributeTypeValue": {
"type": "object",
"properties": {
"type": {
"allOf": [
{
"$ref": "#/definitions/Identifier"
},
{
"not": {
"const": "DateTime"
}
},
{
"not": {
"const": "geo:json"
}
}
]
},
"value": {
"$ref": "#/definitions/Value"
}
},
"required": [
"value"
]
},
"MetadataTypeValue": {
"type": "object",
"properties": {
"type": {
"allOf": [
{
"$ref": "#/definitions/Identifier"
},
{
"not": {
"const": "DateTime"
}
}
]
},
"value": {
"$ref": "#/definitions/Value"
}
},
"required": [
"value"
]
},
"DateTimeValue": {
"type": "string",
"format": "date-time"
},
"DateTimeTypeValue": {
"type": "object",
"properties": {
"type": {
"type": "string",
"const": "DateTime"
},
"value": {
"$ref": "#/definitions/DateTimeValue"
}
},
"required": [
"type",
"value"
]
},
"GeoTypeValue": {
"type": "object",
"properties": {
"type": {
"type": "string",
"const": "geo:json"
},
"value": {
"$ref": "http://json-schema.org/geojson/geometry.json#"
}
},
"required": [
"type",
"value"
]
},
"Metadata": {
"type": "object",
"properties": {
"dateCreated": {
"$ref": "#/definitions/DateTimeTypeValue"
},
"dateModified": {
"$ref": "#/definitions/DateTimeTypeValue"
},
"previousValue": {
"$ref": "#/definitions/AttributeTypeValue"
},
"actionType": {
"type": "object",
"properties": {
"type": {
"type": "string",
"const": "Text"
},
"value": {
"type": "string",
"enum": [
"update",
"delete",
"append"
]
}
},
"required": [
"type",
"value"
]
}
},
"additionalProperties": {
"anyOf": [
{
"$ref": "#/definitions/MetadataTypeValue"
},
{
"$ref": "#/definitions/DateTimeTypeValue"
}
]
},
"propertyNames": {
"allOf": [
{
"not": {
"type": "string",
"const": "*"
}
}
]
}
},
"dateCreated": {
"$ref": "#/definitions/DateTimeTypeValue"
},
"dateModified": {
"$ref": "#/definitions/DateTimeTypeValue"
},
"dateExpires": {
"$ref": "#/definitions/DateTimeTypeValue"
},
"Attribute": {
"allOf": [
{
"oneOf": [
{
"$ref": "#/definitions/DateTimeTypeValue"
},
{
"$ref": "#/definitions/GeoTypeValue"
},
{
"$ref": "#/definitions/AttributeTypeValue"
}
]
},
{
"type": "object",
"properties": {
"metadata": {
"$ref": "#/definitions/Metadata"
}
}
}
]
},
"EntityFragment": {
"type": "object",
"properties": {
"id": {
"$ref": "#/definitions/Identifier"
},
"type": {
"allOf": [
{
"$ref": "#/definitions/Identifier"
},
{
"default": "Thing"
}
]
},
"dateCreated": {
"$ref": "#/definitions/dateCreated"
},
"dateModified": {
"$ref": "#/definitions/dateModified"
},
"dateExpires": {
"$ref": "#/definitions/dateExpires"
}
},
"propertyNames": {
"allOf": [
{
"not": {
"type": "string",
"const": "geo:distance"
}
},
{
"not": {
"type": "string",
"const": "*"
}
}
]
},
"additionalProperties": {
"anyOf": [
{
"$ref": "#/definitions/Attribute"
}
]
}
},
"Entity": {
"allOf": [
{
"required": [
"id",
"type"
]
},
{
"$ref": "#/definitions/EntityFragment"
}
]
}
},
"allOf": [
{
"$ref": "#/definitions/Entity"
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment