-
Notifications
You must be signed in to change notification settings - Fork 22
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
Consider removing object wrapper from Property payload #143
Comments
I agree and confirm that the obsolete RFC 4627 is superseded by RFC 7159 which allows numbers, strings and such to be valid JSON. Besides the existing rational I would like to add some more minor reasons why you might want to remove the wrapper.
However, I have to admit that I am certainly not fully aware of all the problems/consequences such a change might cause. |
We're currently exploring a Web Things implementation designed for lab instrumentation, and have come up against this issue recently. Our existing code works like the W3C spec and removes the object wrapper. We would, however, obviously prefer to be more compatible with Mozilla Web Things. I'm realise such a massive change to the Mozilla spec is unlikely, but I'll follow this thread just in case. It'd be wonderful to have full compatibility, but as @danielpeintner said, I'm also not fully aware of the consiquences of such a change. |
This has been playing on my mind too as I work on a greenfield web thing implementation and wonder whether to follow the Mozilla or W3C specification. I'd like to help converge the two but I don't think this change can be made to the This is one issue I hope to address in the Web Thing Protocol Community Group so feel free to join that group if you are interested and I will try to get things kicked off at some point this year!! |
Thanks! I've joined the community group now. I agree that changing the Mozilla spec would have enough ramifications that it's likely infeasible, but I feel like the inconsistencies between the HTTP and WS APIs can be reconciled by treating the keys in the
The REST equivalent would be a pair of requests, first to the I do also agree that it doesn't make sense to change properties in isolation, but the same wrapper removal might also make sense for Actions especially, given that in the REST API the action name and
And for the REST API would be equivalent to a request to
I'm fumbling my way around the community group but hopefully there will be some kind of forum better suited for this discussion. I'm largely posting it here so it's out there before I forget... |
I am not sure if it helps but the only thing that needs to be clear is that Web Thing Descriptions and WoT TDs are not 100% the same. Having said that, for example a Web Thing Description property
maps to a WoT TD as follows.
I believe there are other differences besides type and |
The only other difference I know of off the top of my head is that the W3C spec schema requires the |
I have started to document the differences between the Mozilla and W3C specifications here. Please feel free to edit the wiki page if you find any other differences that need addressing. |
This is super useful, thank you for writing it up! I’m very new to following the W3C standardisation process, so am I right in thinking that the W3C TD spec is unlikely to change significantly now? I just wonder how prospective convergence is likely to work. |
Yes, this is correct :) The TD spec is in a maintenance round where a V1.1 will be introduced in 1-2 years (or maybe sooner) but will stay backward-compatible while adding some new features and fixing unclear or under-documented parts. This also means that if you want to propose new features, now is a good time ;) |
The hope of @mrstegeman and I is that the output of the Web Thing Protocol Community Group will fill in enough of the gaps (by defining a concrete sub-protocol for the Web of Things) that the Mozilla implementation will be able to migrate to that, and that if any changes are needed to the W3C Thing Description specification to make that work they should be quite minimal. I can't guarantee that the Mozilla implementation will ever support all W3C compliant Thing Descriptions (or all the features of Thing Descriptions) though, because IMO that's effectively impossible because of the way it is architected. FYI I put out a call for Use Cases & Requirements for the Web Thing Protocol yesterday on the public mailing list and you can see a first draft to start the conversation here. Another thing that might help is the W3C WoT Profiles work, which may make it possible to annotate a Thing Description to constrain it to using a particular (sub)-protocol. I am hoping to discuss that in the virtual face to face meeting today. |
Hi everyone, There is one other thing, that differs in Mozilla WebThing Description from TD.
But in Mozilla WebThing if an HTTP request to events URL is made. It returns the event history (not an event), synchronously, which should be a readOnly property not an event as logically. So the only way it should work is in forms (or links in Mozilla), it should give a WebSocket link rather than an HTTP link. By data types, there are 2 possibilities, 1-Change the return type from Object to value itself, or change the data type in Description as object and put the properties of objects correctly. I am working, with this problem in my master thesis and created an hybrid approach, to tackle this problem with ease. By using node-wot library and an helper that I wrote, I can consume and use a Mozilla WebThing with a W3c consumer in here. The helper;
|
This is quite off-topic now, but there are a couple of problems with that definition in the W3C specification IMO:
The Mozilla specification takes a pragmatic approach by using WebSockets to push event data to clients where possible and lets a client fall back to using HTTP GET requests to pull event data from the server when a WebSocket is not available. The W3C specification does not specify a default mechanism for events (the HTTP Protocol Binding section doesn't mention events at all), so every web thing does it slightly differently. I've added a note to the wiki page to say:
|
Currently for a property definition in a Web Thing Description as below:
a response to a GET request on the Property resource looks something like:
where the payload is a JSON object with a map representation of the property's name and value. The payloads of PUT requests and responses also follow the same format.
@egekorkan has pointed out that if parsed as a W3C Thing Description using the latest W3C specification (assuming the
links
were parsed asforms
) the default would be that the payload for the Property resource would just contain the value:21
I believe the rationale for originally wrapping this as an object in the Mozilla specification was:
In order to move closer to the W3C specification we could consider removing this object wrapper for Property resources (which is now valid JSON). The Properties resource would still use a map for requests and responses, as is already the default for top level forms with readallproperties, writeallproperties, readmultipleproperties, or writemultipleproperties operations in the W3C spec.
Problems I can forsee with this are:
The text was updated successfully, but these errors were encountered: