-
Notifications
You must be signed in to change notification settings - Fork 65
Common Definitions Simplification #2173
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
Conversation
|
Some discussion points:
|
|
TD call today:
|
|
I have implemented the feedback and this is aligned more with @benfrancis proposal. Some thoughts:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is a huge improvement, thank you for all the hard work @egekorkan. I just have one remaining comment.
I think the case where formDefaults has an array of strings as a value is confusing. It took me a long time to figure out that formDefaults actually means defaultForms in this case, i.e. not the default values for the members of Form, but a default set of Form objects to be applied to every InteractionAffordance.
If this is in fact the intention it raises a lot of questions for me, e.g.:
- The remark next to the
formDefaultsvocabulary term says "the items have an OR relationship key". In what way is this an OR relationship? - When a Form in an InteractionAffordance overrides a value, does it always have to override that value in all of the default set of Forms?
- What if an InteractionAffordance has two Forms with different values for the same member, which one wins in the expanded TD?
- What if different protocols support different subsets of operations? Presumably that's not possible with
formDefaults, so that term is only useful if all protocols support the same set of operations, or only the default values ofopfor each Form? - If there is one InteractionAffordance which should not have one of the default set of Forms, presumably there is no way to express that? So this only works when every InteractionAffordance needs the full set of Forms?
- What if there are no overrides needed to the default set of Forms? As I understand it currently the
formsmember is mandatory and can not be an empty array. - If you can have an array of strings, why not also an Array of Objects with inline definitions?
I get why in theory having a default set of Forms is useful when you are using multiple protocols/payload formats/IP addresses and want all affordances to use all of the protocols/payload formats/IP addresses without having to add multiple Forms for each InteractionAffordance, but I think it's confusing and in practice only works for very limited use cases where you have a default set of Forms that apply to all InteractionAffordances and all Forms use the same set of operations, or only the default set of operations for that type of affordance.
Instead of allowing formDefaults to be an array, my suggestion would be that formDefaults (or defaultForm) only contains a single set of default terms (i.e. a single default Form), either as an Object providing an inline Form definition, or a string referencing one of the formDefinitions. These defaults are applied to (but can be overridden by) every Form in the Thing description, even if there are multiple Forms for one InteractionAffordance. If you want to define multiple re-usable Forms you would use formDefinitions.
That would mean that if you have multiple protocols/payloadformats/IP addresses you always need to include multiple Forms in each InteractionAffordance, but at least it is more explicit and makes it possible to add different overrides for different Forms. Currently I think the idea that one Form expands out into multiple Forms if formDefaults is an Array is non-obvious.
If the current behaviour is kept, the term should probably be called defaultForms rather than formDefaults, but I think the questions above would need answering.
Please let me know if I've misunderstood.
P.S. As an aside, I'm curious about the use cases for schemaDefaults, but that doesn't relate to this PR.
|
Thanks for the review @benfrancis . The multi ip address is a use case we have for this feature so that is why it is an array in the first place and going in the direction of the proposal after your questions makes that more difficult to implement. The simple case is indeed more common but that does not make it too difficult to use from my point of view. If we go in the direction, I would propose getting rid of the definitions as well and just allow one default form to be defined. Otherwise, here are the answers:
A Consumer can use one of the forms. E.g., can use coap or http based on the Consumer's capabilities.
No.
No winner :) Both are visible in the expanded TD. This goes in the matrix multiplication discussion.
See https://github.com/w3c/wot-thing-description/blob/ege-cd-simplification/proposals/common-definitions/tooling/tds.js#L569 (or example 10 if it moves around). As you can see,
Kind of but you can override with
You would still need the href or a way to identify the resource. In case of WebThing WS Subprotocol, it would look rather empty unless
Good point. We can discuss it today. It just adds more variation. We can discuss avoiding
That is basically going to be the whole data mapping topic. E.g. all affordance values wrapped in a {value:myVal} |
| @@ -771,42 +401,49 @@ const recommendedTDs = [ | |||
| }, | |||
| // 7. readproperty and writeproperty defaults that are not the defaults of the binding (GET and POST) | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Feedback from @relu91 in the call: it would be helpful for this case to allow formDefaults in the affordance level. all properties would have formDefaults:[read,write] and all actions would have formDefaults:[invoke]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or just use formDefinitions instead of formDefaults in this use case...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did not see this feedback before. Could you elaborate?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rather than complicate formDefaults usage further, as a rule of thumb where there are multiple default Forms involved I suggest that a Thing Description author should use formDefinitions rather than formDefaults. In this case there would be one definition for reading and writing properties and one definition for invoking actions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK I see but without form in individual forms?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, with form in individual Forms (though I think there might be a better name for that term).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
feedback from @relu91 : What about having href in a form definition and in none of the forms in the compact TD. That would be relevant for WebThing WS subprotocol or any protocol where the resource identifier is the same as affordance name. This can be relevant for defining the default for http binding where the Thing has pattern of properties/myPropertyName. Relevant to address #2087
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about having href in a form definition and in none of the forms in the compact TD.
Yes, currently the forms member of an InteractionAffordance is mandatory, can not be an empty array and href is a mandatory member of Form. This means that even if the href is the same as the default for every Form you would have to include a href with the same value in every Form. If formDefaults is specified then maybe forms and href should not be mandatory.
That would be relevant for WebThing WS subprotocol or any protocol where the resource identifier is the same as affordance name.
This is usually not the case in the Web Thing Protocol WebSocket sub-protocol, where the same URL is usually used for all affordances of a Thing.
This can be relevant for defining the default for http binding where the Thing has pattern of properties/myPropertyName
The URL structure is (intentionally) not specified in the HTTP Basic Profile, href can not be auto-generated from an affordance name. I don't think the default HTTP binding should prescribe a particular URL structure either.
This can be done with introducing oneOf and allOf in the security object and allowing schemes to be put in there. Example that can be in direction:
base can be allowed in the form level too |
|
I think I may be missing something about the way defaults can be overridden. @egekorkan wrote:
How would you override a value in only one of the default Forms from an individual Form instance? How does the Form identify which default Form to override?
Same question as above, how does an individual Form specify which default Form from
How would you prevent the EventAffordance being populated with the HTTP-based Form upon expansion?
Same question as above. How would you specify in an InteractionAffordance that one of the default Forms should not be included?
Right, it's a bit odd in that use case. Based on my current understanding, in all of the above use cases I would suggest it would be clearer to use
I think this provides weight to the idea that Am I missing something? |
Co-authored-by: danielpeintner <[email protected]>
|
TD Call today:
|
|
@egekorkan I'm sorry I'm not able to join calls at the moment, but thank you for your response.
Are you saying that if any of the Forms in an InteractionAffordance contains a |
Yes that is pretty much it. Is the non-intuitive part the general algorithm or looking at a TD like this feels weird? To me it looks kind of straightforward. It is the same mechanism as security and securityDefinitions we have at the moment. |
|
@egekorkan wrote:
Both - the implicit nature of single Forms that expand out into multiple Forms, and the algorithm for expanding a TD which behaves very differently depending on whether
I think the The parts that I find weird (again, if I've understood correctly) are:
IMO all of the above examples would be simpler or more explicit if you just used |
|
@benfrancis I will try to make a proposal in another PR but I have a better feeling about the complaint. Right now, we have the following 3 use cases and 1 is not working well in my opinion neither:
|
|
With the latest push, I think this PR is ready to merge. We have two feedbacks from @relu91 and some from @benfrancis that I will move out of this PR as they are not against this but asking for more simplification or usability improvements. To be discussed in today's call. |
|
I'm fine with this PR being merged because I think it's a huge improvement, and it's still just a proposal. I am happy to file a follow-up issue about further simplifying Edit: I have filed #2175. |
|
TD Call today:
|
Description of Changes
I am taking the proposal in #2165 and adapting to it. The best is to look at the diff in the tds.js file. Here are my takeaways:
formwithformDefaults.As a result, I like this approach more.
Related Issue
Closes #2165
Type of Change