-
Notifications
You must be signed in to change notification settings - Fork 13
Interaction not shown in serialized TD #81
Comments
@danielpeintner The whole architecture is unfortunately a bit messed up, as there is mix of using the software object and using the TD representation: ConsumedThing delegated to its I think the whole idea of ExposedThing extending ConsumedThing is just introducing confusion unless the software object is really a common base. I guess this can get better in the next iteration (see w3c/wot-scripting-api#96) I guess for now, we just go for a hotfix.. |
I just pulled the latest version of node-wot and the bug seems to be still in there... |
Not sure what version you are using. 08d7599 fixed the missing interactions:
|
It turned out that the sample above has some non valid (e.g., type) or missing TD elements (e.g., observable) in the properties. Rewrtiting the sample above to: const node_wot = require('../../packages/core');
const HttpServer = require('../../packages/binding-http').default;
const srv = new node_wot.Servient();
srv.addServer(new HttpServer());
srv.start().then(wot => {
let testThing = wot.produce({name: "TestThing"});
testThing.addProperty({
name: "Size",
schema : '{ "type": "number"}',
value: 10,
writable: true,
observable: true
}).addProperty({
name: "IsOn",
schema : '{ "type": "boolean"}',
value: false,
writable: true,
observable: true
}).addAction({
name: "TurnOn"
}).addAction({
name: "TurnOff"
});
}); The expected TD with interaction is generated: {
"@context": ["https://w3c.github.io/wot/w3c-wot-td-context.jsonld"],
"@type": ["Thing"],
"name": "TestThing",
"security": {"description": "node-wot development Servient, no security"},
"interaction": [
{
"name": "Size",
"@type": ["Property"],
"schema": {"type": "number"},
"writable": true,
"observable": true,
"form": [{
"href": "http://192.168.2.76:8080/TestThing/properties/Size",
"mediaType": "application/json"
}]
},
{
"name": "IsOn",
"@type": ["Property"],
"schema": {"type": "boolean"},
"writable": true,
"observable": true,
"form": [{
"href": "http://192.168.2.76:8080/TestThing/properties/IsOn",
"mediaType": "application/json"
}]
},
{
"name": "TurnOn",
"@type": ["Action"],
"form": [{
"href": "http://192.168.2.76:8080/TestThing/actions/TurnOn",
"mediaType": "application/json"
}]
},
{
"name": "TurnOff",
"@type": ["Action"],
"form": [{
"href": "http://192.168.2.76:8080/TestThing/actions/TurnOff",
"mediaType": "application/json"
}]
}
]
} However, another problem occurs: The generated TD contains also the security field (why?) which is also not valid regarding TD specification (must be in array style). I will close this issue an reopen another one that points out this new problem. |
Hello,
I created a test thing using the API to get acquainted with it, and ran an HTTP server to view my thing in the browser. The code of my index.js file is shown below:
This is inspired by the examples availables in the repo. My thing normally has 2 properties:
Size
(number) andIsOn
(boolean), and 2 actionsTurnOn
andTurnOff
.However, when I run my index using
node index.js
, then go to the root of my TestThing to get the serialized JSON TD athttp://localhost:8080/TestThing
I get the output:As you can see, there are no interactions listed in the TD. But if I go directly to an interaction using the URI, for instance
http://localhost:8080/TestThing/properties/Size
, I get the expected result:So my interactions seem to be added to the thing, but the serialized TD does not show them. Did I miss something there or is there a bug in TD serialization?
Thank you for your help. If you need more information about the test case, I will be happy to provide them.
Additional information
master
branch (I pulled it right before posting this issue to make sure it was up to date).node --version
gives mev6.9.1
as output.npm run test
at the root of the repository does not show any error so my build seems to be working properly.Here are the complete logs of my servient:
The text was updated successfully, but these errors were encountered: