-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Is it OK to not have output
specified in a profile TD
#259
Comments
This is a good question because I think it highlights some of the shortcomings in Thing Descriptions that the Profile work has uncovered. The first thing to say is that a WoT Consumer which doesn't implement the protocol binding in the HTTP Baseline Profile unfortunately won't be able to consume all of the actions API it describes. This is because it's not possible to completely describe it in a Thing Description (see the long discussions in w3c/wot-thing-description#1408, w3c/wot-thing-description#899, #91 and others). I tried in #91 (see rendered example here) but I wasn't able to figure out a way to describe the action queue due to missing features in the Thing Description specification. Any WoT Consumer should be able to invoke an action on a Thing which conforms with the HTTP Baseline Profile, but it may not be able to read its output and definitely won't know how to query the status of an ongoing asynchronous action unless it explicitly implements the protocol binding defined in the HTTP Baseline Profile. To address your specific question, the reason there is no We could add an example of an action which does have an output (e.g. an integer) to make it clear what that would look like. Note that I am differentiating here between the output of the action and the response to the invokeaction HTTP POST request in the protocol binding, because I don't think they're the same thing. In the protocol binding the output of an action (if any) may be contained in the response (in the The following four examples are all valid responses to an {
"status": "pending",
"href": "/things/lamp/actions/fade/123e4567-e89b-12d3-a456-426655"
} {
"status": "completed"
} {
"status": "failed"
} {
"status": "completed",
"output": 42
} A key missing feature needed to describe the data schema of a response, as distinct from the data schema of the output of an action, is a schema term in ExpectedResponse. There was a PR for this feature, but it was postponed until 2.0. In conclusion:
|
I think your statement helps me to see the misunderstanding (or different understanding) I am having here. From the TD point of view Hence
Note: there are two Do you see what I mean? |
@danielpeintner wrote:
The HTTP Baseline Profile is not just a subset of the TD (see #243). The profile includes operations in the actions protocol binding which can not be described declaratively in a Thing Description using a protocol binding template. There was a work item in the current charter to fix this:
Unfortunately, whilst the first point was arguably delivered by the (at risk) Whilst I agree it would be neat if everything in a profile could alternatively be described declaratively in a Thing Description (as I tried to do in #91) so that even non-conformant Consumers could fully consume them, it's not strictly necessary. Profiles can go beyond what's possible with declarative protocol binding templates, and non-conformant Consumers will still be able to consume a subset of their functionality by just following the already established defaults in the Thing Description specification.
Yes, I see what you mean, and yes I am talking about the inner output in your example. But I think your example conflates the data schema of the action output with the protocol binding. What if that same action has multiple forms for different protocols with different payload formats? Events are another example of this. The HTTP SSE Profile includes the event data in the
The (WIP) HTTP Webhook Profile provides event data in the
In both cases, the event data following the data schema for the event provided in the Thing Description is only part of the whole payload, which differs between protocol bindings. Another example would be a WebSocket sub-protocol where there are no built-in semantics at all and every operation will need a payload format which wraps around the actual data described in the data schema. Do you see the problem? In my view these are the kinds of limitations of Thing Descriptions that Profiles can help overcome, using concrete protocol bindings defined in a specification. |
I am still not sure if some of those things we are discussing here should be allowed or used in a profile. |
I think what is missing here is the information wheather the action is asynchronous (in TD In combination of the Profile and the asynchronous flag implicit assumption can be made such as that the input dataSchema is identical to 'inner' output dataSchema in addition to the mandatory status term and the optional href term. However, based on the example above this is not the case since it returns only a (level?) value without any context. I think, this is useless for the client application since it has no context what the inner output value means. I think, there are several options in the BaselineProfile with the asynchronous actions context:
|
@sebastiankb wrote:
Good idea, I can create a PR for that.
I'm not sure I understand. In Example 3 the input schema is an object with level and duration fields. This would not map to the output member of the ActionStatus object because it is input, not output. If the action returned an output it would most likely be different to the input.
If I understand correctly, this is what we do today.
We could do that for actions, yes. That would mean that every Thing Description which conforms with the profile would have to include that duplicate wrapper data schema in every ActionAffordance. In my view a goal of profiles is to avoid the need for these verbose declarative protocol bindings by providing a concrete protocol binding in a specification which applies a set of assumptions for conforming implementations. Also, I don't think this approach would not work for events, since different protocol bindings use different payload structures.
There is only one I do agree with @danielpeintner in that that I think it would be nice if Consumers which don't implement the profile could understand the output of actions, at least for synchronous actions where this is possible. One other option is that we change the protocol binding so that when The downside of having synchronous actions just return an output would be that you lose:
I think that would be OK. It would just mean that synchronous actions which don't complete within the duration of an HTTP timeout would have to return a 408 Request Timeout response. Synchronous Action TD: "actions": {
"collectWidgets": {
"description": "Collect all the widgets",
"synchronous": true
"output": {
"type": "object",
"properties": {
"widgetsCollected": {
"type": "integer"
},
"timeTaken": {
"type": "number",
"unit": "seconds"
}
}
},
"forms": [{"href": "/actions/collectWidgets"}]
}
} Request:
Response:
Asynchronous Action TD: "actions": {
"collectWidgets": {
"description": "Collect all the widgets",
"synchronous": false
"output": {
"type": "object",
"properties": {
"widgetsCollected": {
"type": "integer"
},
"timeTaken": {
"type": "number",
"unit": "seconds"
}
}
},
"forms": [{"href": "/actions/collectWidgets"}]
}
} Request:
Response:
I can create a PR which:
Do you think I should also change the protocol binding for synchronous actions, as described above? |
@danielpeintner @sebastiankb I've created a draft PR (#266) which uses the |
The examples (e.g,. Example 3) describe actions without describing
output
.The result of an action in the Profile is always ActionStatus. The Profile TD does not describe that situation using
output
.I understand the idea to reduce TD verbosity but wouldn't it be better to have at least
A generic implementation of a WoT runtime otherwise would not expect any result.
Side-note: It may depend on the interpretation but 7.2.5.1 Mandatory fields mentions only title being mandatory. Is this correct? Don't we always need output ... even if being implicit?
The text was updated successfully, but these errors were encountered: