diff --git a/packages/core/examples/tds/invalid/emptyOpArray.json b/packages/core/examples/tds/invalid/emptyOpArray.json new file mode 100644 index 000000000..1d704d56b --- /dev/null +++ b/packages/core/examples/tds/invalid/emptyOpArray.json @@ -0,0 +1,32 @@ +{ + "id": "urn:simple", + "@context": "https://www.w3.org/2022/wot/td/v1.1", + "title": "MyLampThing", + "description": "Valid TD copied from the spec's first example", + "securityDefinitions": { + "basic_sc": { "scheme": "basic", "in": "header" } + }, + "security": ["basic_sc"], + "properties": { + "status": { + "type": "string", + "forms": [{ "href": "https://mylamp.example.com/status", "op":[] }] + } + }, + "actions": { + "toggle": { + "forms": [{ "href": "https://mylamp.example.com/toggle" }] + } + }, + "events": { + "overheating": { + "data": { "type": "string" }, + "forms": [ + { + "href": "https://mylamp.example.com/oh", + "subprotocol": "longpoll" + } + ] + } + } +} diff --git a/packages/core/td-schema-full.json b/packages/core/td-schema-full.json index f6bc5ce02..4eda6921b 100644 --- a/packages/core/td-schema-full.json +++ b/packages/core/td-schema-full.json @@ -1,6 +1,6 @@ { "title": "Thing Description", - "version": "1.1-10-June-2022", + "version": "1.1-05-July-2023", "description": "JSON Schema for validating TD instances against the TD information model. For a TD to validate this schema it must contain all the default terms defined in Section 5.4", "$schema": "http://json-schema.org/draft-07/schema#", "definitions": { @@ -376,7 +376,8 @@ "items": { "type": "string", "enum": ["readproperty", "writeproperty", "observeproperty", "unobserveproperty"] - } + }, + "minItems": 1 } ] } @@ -402,7 +403,8 @@ "items": { "type": "string", "enum": ["invokeaction", "queryaction", "cancelaction"] - } + }, + "minItems": 1 } ] } @@ -428,7 +430,8 @@ "items": { "type": "string", "enum": ["subscribeevent", "unsubscribeevent"] - } + }, + "minItems": 1 } ] } @@ -474,7 +477,8 @@ "subscribeallevents", "unsubscribeallevents" ] - } + }, + "minItems": 1 } ] } diff --git a/packages/core/td-schema.json b/packages/core/td-schema.json index 4f69f8696..4eb9236bb 100644 --- a/packages/core/td-schema.json +++ b/packages/core/td-schema.json @@ -1,6 +1,6 @@ { "title": "Thing Description", - "version": "1.1-05-September-2022", + "version": "1.1-05-July-2023", "description": "JSON Schema for validating TD instances against the TD information model. TD instances can be with or without terms that have default values", "$schema": "http://json-schema.org/draft-07/schema#", "$id": "https://raw.githubusercontent.com/w3c/wot-thing-description/main/validation/td-json-schema-validation.json", @@ -55,7 +55,11 @@ }, "subprotocol": { "type": "string", - "examples": ["longpoll", "websub", "sse"] + "examples": [ + "longpoll", + "websub", + "sse" + ] }, "thing-context-td-uri-v1": { "type": "string", @@ -147,7 +151,7 @@ } }, { - "$comment": "Only the new context URI", + "$comment": "Only the old context URI", "$ref": "#/definitions/thing-context-td-uri-v1" } ] @@ -177,7 +181,15 @@ }, "dataSchema-type": { "type": "string", - "enum": ["boolean", "integer", "number", "string", "object", "array", "null"] + "enum": [ + "boolean", + "integer", + "number", + "string", + "object", + "array", + "null" + ] }, "dataSchema": { "type": "object", @@ -306,7 +318,10 @@ } }, "multipleOfDefinition": { - "type": ["integer", "number"], + "type": [ + "integer", + "number" + ], "exclusiveMinimum": 0 }, "expectedResponse": { @@ -315,7 +330,10 @@ "contentType": { "type": "string" } - } + }, + "required": [ + "contentType" + ] }, "form_element_base": { "type": "object", @@ -358,25 +376,42 @@ "$ref": "#/definitions/additionalResponsesDefinition" } }, - "required": ["href"], + "required": [ + "href" + ], "additionalProperties": true }, "form_element_property": { - "allOf": [{ "$ref": "#/definitions/form_element_base" }], + "allOf": [ + { + "$ref": "#/definitions/form_element_base" + } + ], "type": "object", "properties": { "op": { "oneOf": [ { "type": "string", - "enum": ["readproperty", "writeproperty", "observeproperty", "unobserveproperty"] + "enum": [ + "readproperty", + "writeproperty", + "observeproperty", + "unobserveproperty" + ] }, { "type": "array", "items": { "type": "string", - "enum": ["readproperty", "writeproperty", "observeproperty", "unobserveproperty"] - } + "enum": [ + "readproperty", + "writeproperty", + "observeproperty", + "unobserveproperty" + ] + }, + "minItems": 1 } ] } @@ -384,21 +419,34 @@ "additionalProperties": true }, "form_element_action": { - "allOf": [{ "$ref": "#/definitions/form_element_base" }], + "allOf": [ + { + "$ref": "#/definitions/form_element_base" + } + ], "type": "object", "properties": { "op": { "oneOf": [ { "type": "string", - "enum": ["invokeaction", "queryaction", "cancelaction"] + "enum": [ + "invokeaction", + "queryaction", + "cancelaction" + ] }, { "type": "array", "items": { "type": "string", - "enum": ["invokeaction", "queryaction", "cancelaction"] - } + "enum": [ + "invokeaction", + "queryaction", + "cancelaction" + ] + }, + "minItems": 1 } ] } @@ -406,21 +454,32 @@ "additionalProperties": true }, "form_element_event": { - "allOf": [{ "$ref": "#/definitions/form_element_base" }], + "allOf": [ + { + "$ref": "#/definitions/form_element_base" + } + ], "type": "object", "properties": { "op": { "oneOf": [ { "type": "string", - "enum": ["subscribeevent", "unsubscribeevent"] + "enum": [ + "subscribeevent", + "unsubscribeevent" + ] }, { "type": "array", "items": { "type": "string", - "enum": ["subscribeevent", "unsubscribeevent"] - } + "enum": [ + "subscribeevent", + "unsubscribeevent" + ] + }, + "minItems": 1 } ] } @@ -428,7 +487,11 @@ "additionalProperties": true }, "form_element_root": { - "allOf": [{ "$ref": "#/definitions/form_element_base" }], + "allOf": [ + { + "$ref": "#/definitions/form_element_base" + } + ], "type": "object", "properties": { "op": { @@ -462,21 +525,32 @@ "subscribeallevents", "unsubscribeallevents" ] - } + }, + "minItems": 1 } ] } }, "additionalProperties": true, - "required": ["op"] + "required": [ + "op" + ] }, "form": { "$comment": "This is NOT for validation purposes but for automatic generation of TS types. For more info, please see: https://github.com/w3c/wot-thing-description/pull/1319#issuecomment-994950057", "oneOf": [ - { "$ref": "#/definitions/form_element_property" }, - { "$ref": "#/definitions/form_element_action" }, - { "$ref": "#/definitions/form_element_event" }, - { "$ref": "#/definitions/form_element_root" } + { + "$ref": "#/definitions/form_element_property" + }, + { + "$ref": "#/definitions/form_element_action" + }, + { + "$ref": "#/definitions/form_element_event" + }, + { + "$ref": "#/definitions/form_element_root" + } ] }, "property_element": { @@ -597,7 +671,9 @@ } } }, - "required": ["forms"], + "required": [ + "forms" + ], "additionalProperties": true }, "action_element": { @@ -647,7 +723,9 @@ "type": "boolean" } }, - "required": ["forms"], + "required": [ + "forms" + ], "additionalProperties": true }, "event_element": { @@ -694,7 +772,9 @@ "$ref": "#/definitions/dataSchema" } }, - "required": ["forms"], + "required": [ + "forms" + ], "additionalProperties": true }, "base_link_element": { @@ -714,7 +794,9 @@ }, "hreflang": { "anyOf": [ - { "$ref": "#/definitions/bcp47_string" }, + { + "$ref": "#/definitions/bcp47_string" + }, { "type": "array", "items": { @@ -724,7 +806,9 @@ ] } }, - "required": ["href"], + "required": [ + "href" + ], "additionalProperties": true }, "link_element": { @@ -739,7 +823,9 @@ "properties": { "sizes": {} }, - "required": ["sizes"] + "required": [ + "sizes" + ] } }, { @@ -747,10 +833,15 @@ "description": "A basic link element should not contain icon or tm:extends", "properties": { "rel": { - "enum": ["icon", "tm:extends"] + "enum": [ + "icon", + "tm:extends" + ] } }, - "required": ["rel"] + "required": [ + "rel" + ] } } ] @@ -770,7 +861,9 @@ "pattern": "[0-9]*x[0-9]+" } }, - "required": ["rel"] + "required": [ + "rel" + ] } ] }, @@ -782,7 +875,10 @@ "scheme": "ace:ACESecurityScheme", "ace:as": "coaps://as.example.com/token", "ace:audience": "coaps://rs.example.com", - "ace:scopes": ["limited", "special"], + "ace:scopes": [ + "limited", + "special" + ], "ace:cnonce": true } ], @@ -805,7 +901,9 @@ "pattern": ".+:.*" } }, - "required": ["scheme"], + "required": [ + "scheme" + ], "additionalProperties": true }, "noSecurityScheme": { @@ -825,10 +923,14 @@ }, "scheme": { "type": "string", - "enum": ["nosec"] + "enum": [ + "nosec" + ] } }, - "required": ["scheme"], + "required": [ + "scheme" + ], "additionalProperties": true }, "autoSecurityScheme": { @@ -848,13 +950,19 @@ }, "scheme": { "type": "string", - "enum": ["auto"] + "enum": [ + "auto" + ] } }, "not": { - "required": ["name"] + "required": [ + "name" + ] }, - "required": ["scheme"], + "required": [ + "scheme" + ], "additionalProperties": true }, "comboSecurityScheme": { @@ -876,7 +984,9 @@ }, "scheme": { "type": "string", - "enum": ["combo"] + "enum": [ + "combo" + ] }, "oneOf": { "type": "array", @@ -886,7 +996,10 @@ } } }, - "required": ["scheme", "oneOf"], + "required": [ + "scheme", + "oneOf" + ], "additionalProperties": true }, { @@ -906,7 +1019,9 @@ }, "scheme": { "type": "string", - "enum": ["combo"] + "enum": [ + "combo" + ] }, "allOf": { "type": "array", @@ -916,7 +1031,10 @@ } } }, - "required": ["scheme", "allOf"], + "required": [ + "scheme", + "allOf" + ], "additionalProperties": true } ] @@ -938,17 +1056,27 @@ }, "scheme": { "type": "string", - "enum": ["basic"] + "enum": [ + "basic" + ] }, "in": { "type": "string", - "enum": ["header", "query", "body", "cookie", "auto"] + "enum": [ + "header", + "query", + "body", + "cookie", + "auto" + ] }, "name": { "type": "string" } }, - "required": ["scheme"], + "required": [ + "scheme" + ], "additionalProperties": true }, "digestSecurityScheme": { @@ -968,21 +1096,34 @@ }, "scheme": { "type": "string", - "enum": ["digest"] + "enum": [ + "digest" + ] }, "qop": { "type": "string", - "enum": ["auth", "auth-int"] + "enum": [ + "auth", + "auth-int" + ] }, "in": { "type": "string", - "enum": ["header", "query", "body", "cookie", "auto"] + "enum": [ + "header", + "query", + "body", + "cookie", + "auto" + ] }, "name": { "type": "string" } }, - "required": ["scheme"], + "required": [ + "scheme" + ], "additionalProperties": true }, "apiKeySecurityScheme": { @@ -1002,17 +1143,28 @@ }, "scheme": { "type": "string", - "enum": ["apikey"] + "enum": [ + "apikey" + ] }, "in": { "type": "string", - "enum": ["header", "query", "body", "cookie", "uri", "auto"] + "enum": [ + "header", + "query", + "body", + "cookie", + "uri", + "auto" + ] }, "name": { "type": "string" } }, - "required": ["scheme"], + "required": [ + "scheme" + ], "additionalProperties": true }, "bearerSecurityScheme": { @@ -1032,7 +1184,9 @@ }, "scheme": { "type": "string", - "enum": ["bearer"] + "enum": [ + "bearer" + ] }, "authorization": { "$ref": "#/definitions/anyUri" @@ -1045,13 +1199,21 @@ }, "in": { "type": "string", - "enum": ["header", "query", "body", "cookie", "auto"] + "enum": [ + "header", + "query", + "body", + "cookie", + "auto" + ] }, "name": { "type": "string" } }, - "required": ["scheme"], + "required": [ + "scheme" + ], "additionalProperties": true }, "pskSecurityScheme": { @@ -1071,13 +1233,17 @@ }, "scheme": { "type": "string", - "enum": ["psk"] + "enum": [ + "psk" + ] }, "identity": { "type": "string" } }, - "required": ["scheme"], + "required": [ + "scheme" + ], "additionalProperties": true }, "oAuth2SecurityScheme": { @@ -1097,7 +1263,9 @@ }, "scheme": { "type": "string", - "enum": ["oauth2"] + "enum": [ + "oauth2" + ] }, "authorization": { "$ref": "#/definitions/anyUri" @@ -1128,12 +1296,17 @@ }, { "type": "string", - "enum": ["code", "client", "device"] + "enum": [ + "code", + "client" + ] } ] } }, - "required": ["scheme"], + "required": [ + "scheme" + ], "additionalProperties": true }, "securityScheme": { @@ -1214,7 +1387,9 @@ "type": "string" } }, - "required": ["instance"] + "required": [ + "instance" + ] }, "links": { "type": "array", @@ -1305,6 +1480,11 @@ "$ref": "#/definitions/thing-context" } }, - "required": ["title", "security", "securityDefinitions", "@context"], + "required": [ + "title", + "security", + "securityDefinitions", + "@context" + ], "additionalProperties": true -} +} \ No newline at end of file diff --git a/packages/core/tm-schema.json b/packages/core/tm-schema.json index 4cbf5efc1..cad49ae6f 100644 --- a/packages/core/tm-schema.json +++ b/packages/core/tm-schema.json @@ -1,6 +1,6 @@ { "title": "Thing Model", - "version": "1.1-05-September-2022", + "version": "1.1-05-July-2023", "description": "JSON Schema for validating Thing Models. This is automatically generated from the WoT TD Schema.", "$schema": "http://json-schema.org/draft-07/schema#", "$id": "https://raw.githubusercontent.com/w3c/wot-thing-description/main/validation/tm-json-schema-validation.json", @@ -64,7 +64,11 @@ }, "subprotocol": { "type": "string", - "examples": ["longpoll", "websub", "sse"] + "examples": [ + "longpoll", + "websub", + "sse" + ] }, "thing-context-td-uri-v1": { "type": "string", @@ -156,7 +160,7 @@ } }, { - "$comment": "Only the new context URI", + "$comment": "Only the old context URI", "$ref": "#/definitions/thing-context-td-uri-v1" } ] @@ -182,7 +186,15 @@ "type": "string", "anyOf": [ { - "enum": ["boolean", "integer", "number", "string", "object", "array", "null"] + "enum": [ + "boolean", + "integer", + "number", + "string", + "object", + "array", + "null" + ] }, { "$ref": "#/definitions/placeholder-pattern" @@ -396,7 +408,10 @@ "multipleOfDefinition": { "anyOf": [ { - "type": ["integer", "number"], + "type": [ + "integer", + "number" + ], "exclusiveMinimum": 0 }, { @@ -479,7 +494,12 @@ "type": "string", "anyOf": [ { - "enum": ["readproperty", "writeproperty", "observeproperty", "unobserveproperty"] + "enum": [ + "readproperty", + "writeproperty", + "observeproperty", + "unobserveproperty" + ] }, { "$ref": "#/definitions/placeholder-pattern" @@ -503,7 +523,8 @@ "$ref": "#/definitions/placeholder-pattern" } ] - } + }, + "minItems": 1 } ] }, @@ -532,7 +553,11 @@ "type": "string", "anyOf": [ { - "enum": ["invokeaction", "queryaction", "cancelaction"] + "enum": [ + "invokeaction", + "queryaction", + "cancelaction" + ] }, { "$ref": "#/definitions/placeholder-pattern" @@ -545,13 +570,18 @@ "type": "string", "anyOf": [ { - "enum": ["invokeaction", "queryaction", "cancelaction"] + "enum": [ + "invokeaction", + "queryaction", + "cancelaction" + ] }, { "$ref": "#/definitions/placeholder-pattern" } ] - } + }, + "minItems": 1 } ] }, @@ -580,7 +610,10 @@ "type": "string", "anyOf": [ { - "enum": ["subscribeevent", "unsubscribeevent"] + "enum": [ + "subscribeevent", + "unsubscribeevent" + ] }, { "$ref": "#/definitions/placeholder-pattern" @@ -593,13 +626,17 @@ "type": "string", "anyOf": [ { - "enum": ["subscribeevent", "unsubscribeevent"] + "enum": [ + "subscribeevent", + "unsubscribeevent" + ] }, { "$ref": "#/definitions/placeholder-pattern" } ] - } + }, + "minItems": 1 } ] }, @@ -667,7 +704,8 @@ "$ref": "#/definitions/placeholder-pattern" } ] - } + }, + "minItems": 1 } ] }, @@ -1102,7 +1140,9 @@ "properties": { "sizes": {} }, - "required": ["sizes"] + "required": [ + "sizes" + ] } }, { @@ -1112,7 +1152,9 @@ "rel": { "anyOf": [ { - "enum": ["icon"] + "enum": [ + "icon" + ] }, { "$ref": "#/definitions/placeholder-pattern" @@ -1120,7 +1162,9 @@ ] } }, - "required": ["rel"] + "required": [ + "rel" + ] } } ] @@ -1140,7 +1184,9 @@ "pattern": "[0-9]*x[0-9]+" } }, - "required": ["rel"] + "required": [ + "rel" + ] } ] }, @@ -1152,7 +1198,10 @@ "scheme": "ace:ACESecurityScheme", "ace:as": "coaps://as.example.com/token", "ace:audience": "coaps://rs.example.com", - "ace:scopes": ["limited", "special"], + "ace:scopes": [ + "limited", + "special" + ], "ace:cnonce": true } ], @@ -1201,7 +1250,9 @@ "type": "string", "anyOf": [ { - "enum": ["nosec"] + "enum": [ + "nosec" + ] }, { "$ref": "#/definitions/placeholder-pattern" @@ -1238,7 +1289,9 @@ "type": "string", "anyOf": [ { - "enum": ["auto"] + "enum": [ + "auto" + ] }, { "$ref": "#/definitions/placeholder-pattern" @@ -1247,7 +1300,9 @@ } }, "not": { - "required": ["name"] + "required": [ + "name" + ] }, "additionalProperties": true, "propertyNames": { @@ -1277,7 +1332,9 @@ "type": "string", "anyOf": [ { - "enum": ["combo"] + "enum": [ + "combo" + ] }, { "$ref": "#/definitions/placeholder-pattern" @@ -1316,7 +1373,9 @@ "type": "string", "anyOf": [ { - "enum": ["combo"] + "enum": [ + "combo" + ] }, { "$ref": "#/definitions/placeholder-pattern" @@ -1357,7 +1416,9 @@ "type": "string", "anyOf": [ { - "enum": ["basic"] + "enum": [ + "basic" + ] }, { "$ref": "#/definitions/placeholder-pattern" @@ -1368,7 +1429,13 @@ "type": "string", "anyOf": [ { - "enum": ["header", "query", "body", "cookie", "auto"] + "enum": [ + "header", + "query", + "body", + "cookie", + "auto" + ] }, { "$ref": "#/definitions/placeholder-pattern" @@ -1408,7 +1475,9 @@ "type": "string", "anyOf": [ { - "enum": ["digest"] + "enum": [ + "digest" + ] }, { "$ref": "#/definitions/placeholder-pattern" @@ -1419,7 +1488,10 @@ "type": "string", "anyOf": [ { - "enum": ["auth", "auth-int"] + "enum": [ + "auth", + "auth-int" + ] }, { "$ref": "#/definitions/placeholder-pattern" @@ -1430,7 +1502,13 @@ "type": "string", "anyOf": [ { - "enum": ["header", "query", "body", "cookie", "auto"] + "enum": [ + "header", + "query", + "body", + "cookie", + "auto" + ] }, { "$ref": "#/definitions/placeholder-pattern" @@ -1470,7 +1548,9 @@ "type": "string", "anyOf": [ { - "enum": ["apikey"] + "enum": [ + "apikey" + ] }, { "$ref": "#/definitions/placeholder-pattern" @@ -1481,7 +1561,14 @@ "type": "string", "anyOf": [ { - "enum": ["header", "query", "body", "cookie", "uri", "auto"] + "enum": [ + "header", + "query", + "body", + "cookie", + "uri", + "auto" + ] }, { "$ref": "#/definitions/placeholder-pattern" @@ -1521,7 +1608,9 @@ "type": "string", "anyOf": [ { - "enum": ["bearer"] + "enum": [ + "bearer" + ] }, { "$ref": "#/definitions/placeholder-pattern" @@ -1541,7 +1630,13 @@ "type": "string", "anyOf": [ { - "enum": ["header", "query", "body", "cookie", "auto"] + "enum": [ + "header", + "query", + "body", + "cookie", + "auto" + ] }, { "$ref": "#/definitions/placeholder-pattern" @@ -1581,7 +1676,9 @@ "type": "string", "anyOf": [ { - "enum": ["psk"] + "enum": [ + "psk" + ] }, { "$ref": "#/definitions/placeholder-pattern" @@ -1621,7 +1718,9 @@ "type": "string", "anyOf": [ { - "enum": ["oauth2"] + "enum": [ + "oauth2" + ] }, { "$ref": "#/definitions/placeholder-pattern" @@ -1659,7 +1758,10 @@ "type": "string", "anyOf": [ { - "enum": ["code", "client", "device"] + "enum": [ + "code", + "client" + ] }, { "$ref": "#/definitions/placeholder-pattern" @@ -1830,7 +1932,9 @@ "type": "string" } }, - "required": ["instance"] + "required": [ + "instance" + ] } }, { @@ -1949,5 +2053,8 @@ "$ref": "#/definitions/placeholder-pattern" } }, - "required": ["@context", "@type"] -} + "required": [ + "@context", + "@type" + ] +} \ No newline at end of file