Skip to content

Commit fe1bc6a

Browse files
Merge pull request #129 from k-toumura/wot-urivar-fix
fix uri-schema handling in WoT TD
2 parents ea470e5 + 8552333 commit fe1bc6a

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

templates/webofthings/node.js.mustache

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,8 @@ module.exports = function (RED) {
478478
const urivars = prop.hasOwnProperty("uriVariables") ? msg.payload : {};
479479
if (prop.uriVariables) {
480480
const ajv = new Ajv({allErrors: true, strict: false, validateFormats: false});
481-
if (!ajv.validate(prop.uriVariables, urivars)) {
481+
const uvschema = { type: "object", properties: prop.uriVariables };
482+
if (!ajv.validate(uvschema, urivars)) {
482483
node.warn(`input schema validation error: ${ajv.errorsText()}`, msg);
483484
}
484485
}
@@ -512,7 +513,8 @@ module.exports = function (RED) {
512513
const urivars = prop.hasOwnProperty("uriVariables") ? msg.payload : {};
513514
if (prop.uriVariables) {
514515
const ajv = new Ajv({allErrors: true, strict: false, validateFormats: false});
515-
if (!ajv.validate(prop.uriVariables, urivars)) {
516+
const uvschema = { type: "object", properties: prop.uriVariables };
517+
if (!ajv.validate(uvschema, urivars)) {
516518
node.warn(`input schema validation error: ${ajv.errorsText()}`, msg);
517519
}
518520
}
@@ -533,7 +535,8 @@ module.exports = function (RED) {
533535
const urivars = act.hasOwnProperty("uriVariables") ? msg.payload : {};
534536
if (act.uriVariables) {
535537
const ajv = new Ajv({allErrors: true, strict: false, validateFormats: false});
536-
if (!ajv.validate(act.uriVariables, urivars)) {
538+
const uvschema = { type: "object", properties: act.uriVariables };
539+
if (!ajv.validate(uvschema, urivars)) {
537540
node.warn(`input schema validation error: ${ajv.errorsText()}`, msg);
538541
}
539542
}
@@ -556,7 +559,8 @@ module.exports = function (RED) {
556559
const urivars = ev.hasOwnProperty("uriVariables") ? msg.payload : {};
557560
if (ev.uriVariables) {
558561
const ajv = new Ajv({allErrors: true, strict: false, validateFormats: false});
559-
if (!ajv.validate(ev.uriVariables, urivars)) {
562+
const uvschema = { type: "object", properties: ev.uriVariables };
563+
if (!ajv.validate(uvschema, urivars)) {
560564
node.warn(`input schema validation error: ${ajv.errorsText()}`, msg);
561565
}
562566
}

templates/webofthings/package.json.mustache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"https-proxy-agent": "5.0.0",
2121
"request": "2.88.2",
2222
"ws": "8.5.0",
23-
"url-template": "3.0.0",
23+
"url-template": "2.0.8",
2424
"ajv": "8.10.0",
2525
"coap": "1.0.3"
2626
},

0 commit comments

Comments
 (0)