diff --git a/templates/webofthings/node.js.mustache b/templates/webofthings/node.js.mustache index bab03d2..a388c71 100644 --- a/templates/webofthings/node.js.mustache +++ b/templates/webofthings/node.js.mustache @@ -478,7 +478,8 @@ module.exports = function (RED) { const urivars = prop.hasOwnProperty("uriVariables") ? msg.payload : {}; if (prop.uriVariables) { const ajv = new Ajv({allErrors: true, strict: false, validateFormats: false}); - if (!ajv.validate(prop.uriVariables, urivars)) { + const uvschema = { type: "object", properties: prop.uriVariables }; + if (!ajv.validate(uvschema, urivars)) { node.warn(`input schema validation error: ${ajv.errorsText()}`, msg); } } @@ -512,7 +513,8 @@ module.exports = function (RED) { const urivars = prop.hasOwnProperty("uriVariables") ? msg.payload : {}; if (prop.uriVariables) { const ajv = new Ajv({allErrors: true, strict: false, validateFormats: false}); - if (!ajv.validate(prop.uriVariables, urivars)) { + const uvschema = { type: "object", properties: prop.uriVariables }; + if (!ajv.validate(uvschema, urivars)) { node.warn(`input schema validation error: ${ajv.errorsText()}`, msg); } } @@ -533,7 +535,8 @@ module.exports = function (RED) { const urivars = act.hasOwnProperty("uriVariables") ? msg.payload : {}; if (act.uriVariables) { const ajv = new Ajv({allErrors: true, strict: false, validateFormats: false}); - if (!ajv.validate(act.uriVariables, urivars)) { + const uvschema = { type: "object", properties: act.uriVariables }; + if (!ajv.validate(uvschema, urivars)) { node.warn(`input schema validation error: ${ajv.errorsText()}`, msg); } } @@ -556,7 +559,8 @@ module.exports = function (RED) { const urivars = ev.hasOwnProperty("uriVariables") ? msg.payload : {}; if (ev.uriVariables) { const ajv = new Ajv({allErrors: true, strict: false, validateFormats: false}); - if (!ajv.validate(ev.uriVariables, urivars)) { + const uvschema = { type: "object", properties: ev.uriVariables }; + if (!ajv.validate(uvschema, urivars)) { node.warn(`input schema validation error: ${ajv.errorsText()}`, msg); } } diff --git a/templates/webofthings/package.json.mustache b/templates/webofthings/package.json.mustache index d8b2020..a134e96 100644 --- a/templates/webofthings/package.json.mustache +++ b/templates/webofthings/package.json.mustache @@ -20,7 +20,7 @@ "https-proxy-agent": "5.0.0", "request": "2.88.2", "ws": "8.5.0", - "url-template": "3.0.0", + "url-template": "2.0.8", "ajv": "8.10.0", "coap": "1.0.3" },