-
Notifications
You must be signed in to change notification settings - Fork 130
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
Comments on Simplified WoT Thing Description #393
Comments
@benfrancis a few responses on JSON [Hyper-]Schema:
A big focus for the current draft-08 work is to make JSON Schema more modular, so that projects can both more easily extend JSON Schema with new vocabularies, and restrict or embed JSON Schema. If there is a readily identifiable JSON Schema subset that is of interest that would be useful input to the draft-08 work.
Yes, these were moved from hyper-schema into validation in draft-07 because many uses of JSON Schema validation use them without using hyper-schema. Draft-07 was published in November, so this probably wasn't the case when decisions about readOnly in the TD were first being considered.
I've been trying to figure out how Hyper-Schema might fit in, and there have been some discussions in w3c/wot-thing-description#94 and w3c/wot-binding-templates#13. When TD links/forms were first being designed, Hyper-Schema was on draft-04 which had a number of problems and was not a complete system. We removed most of the problems in draft-06 in April 2017, but only really produced a complete system in draft-07 in November 2017. I think it is worth another look now, but I'm obviously biased.
I'm with you on that. One of the big problems in JSON Hyper-Schema draft-04 was over-emphasis on individually specifying protocol methods. Which also led to people getting confused about Indicating what protocol operations are available can be done through
Hyper-Schema also uses an array of links, as it turns out to be fairly easy to have different links with the same We feel that the array approach is more flexible and encourages a more general link design mentality. Applications are, of course, free to parse the list into an object indexed by whatever key works for their application. For some applications, The alternative was to make an object of lists, since either way you organize it you have to deal with multiple links of the same relation type. There's still some discussion on allowing this, although it doesn't seem to have a strong advocate at this point. The |
Use of link inside interaction with only generic mediaType does not convey enough information. JSON is not self-describing to any WoT application like HTML is to a browser DOM. We need to understand how to best bridge this gap, and for now we are experimenting with explicit controls, in a well-defined module within the TD mediatype, using some external vocabularies to configure a small set of transfer options. We decided to call this an extension to the concept of "Form" because it is a control that tells the client how to submit state changes to the server. Let's split the discussion of "Form" into two parts; Maybe it is a small extension but I think we are creating a new extension to REST where state changes on the server are orchestrated by the client; the so-called "Action" pattern. We mostly seem to agree that it is more than simply setting resource state. Second, how does the mediatype implement the concept of the client sending state updates to the server. Is it simply a description of the payload and a convention as to the method and options? Or do we decide to accommodate regional variations in use with different SDOs, vendors, and integrators? We are also creating an extension for Events and property notifications, which can have a few common transfer layer mappings (subProtocols). There are complaints about this also. But they exist and it may not be in the WoT charter to pick one and only one. There is also a hybrid approach where TD can simply link to a more descriptive external mediatype for interactions, which implements a well-known transfer-interaction model, e.g. mapping for PUT/POST, etc. and pre-selected subProtocols. For example there could be "link": { Where wot+json tells the client to use a particular pre-defined protocol binding for the http scheme. |
@handrews: Thank you, that's useful information. @mjkoster wrote:
I recognise that an
I don't think we're inventing anything new here, there is an established pattern for representing actions in REST APIs by POSTing to an action queue. It's not a standard, but it is a widely used design pattern which could be used by one.
As described above, a concrete REST binding could specify both the methods and payloads used. I understand the motivation for designing an abstract mechanism which can encompass a range of existing IoT protocols as it feels like we're creating interoperability by gluing existing standards together. Whilst that approach possibly creates business opportunities to provide gateways and cloud adapters to convert between all of those different protocols, it doesn't allow for true ad-hoc interoperability. It's likely to require a client to download additional software for each new protocol it encounters, which is exactly the problem I was hoping the Web of Things could solve.
I agree that this is an extension to REST, and I think this is a good reason to leave the door open for web protocols to evolve to accommodate this use case. There are range of existing solutions to this problem including webhooks (which is a bit of hack), Server Sent Events (which doesn't yet have very broad browser support), CoAP (which defines additional methods to those HTTP has, but is a whole new protocol) and WebSockets (which isn't very RESTful and requires defining a web thing sub-protocol). In my ideal world we'll eventually see an HTTP/3 which provides a solution to this problem, perhaps something along the lines of CoAP but which is supported natively by web browsers. In the meantime I propose defining a web thing sub-protocol for WebSockets, because this is already supported by web browsers and many other web clients.
I think this is basically what I mean by a concrete REST API specification. |
@mjkoster @mkovatsc [edit: thanks for the feedback @benfrancis] could either of y'all give me a hint as to whether the Hyper-Schema stuff might be of interest, and if so what further questions need to be considered to decide whether to investigate it more deeply? You've both been kind enough to engage me on this topic in issues elsewhere, but I can't tell whether we're at "hmm... this might be useful" or "that's nice but we're not reconsidering this at all". I really don't want to keep wasting everyone's time with long comments if it's not helpful. I'm certainly not going to be offended if you're not interested, but from the small amount of discussion recently it really does feel like you're going very similar places to draft-07.
Based on not just this group but others that I participate in more directly, this is the challenge of hypermedia right now. All of the most difficult discussions of designing hypermedia systems come back to it, and it's certainly something I'm looking at for hyper-schema. I'll post more on this shortly if it's of interest. |
[EDIT: I have not dug into the TD's actions work recently so if this is either preaching to the choir or totally off-base, that's why]
OK I know I just said I'd wait for an indication of interest but I have to reply to this :-) My view on actions is to think of them as "data transitions". Typical hypermedia focuses on transitions from resource to resource, which I think of as "location transitions". I've been kicking around adding data transition support to hyper-schema by adding a list of possible data transitions to a link description object, which indicate what updates are significant and why. These could be expressed through things like patch media types (JSON Patch or JSON Merge Patch), potentially with form controls on top of them. The results could be applied locally and sent as a PUT, or sent directly as a PATCH (for http/coap). The point is to associate a vocabulary term of some sort with specific data transitions, which may be either hardcoded (closing an issue is implemented by setting the "status" field to "close") or templatized through form controls (assigning an issue is implemented by setting the "author" field to a client-supplied value that validates against schema {...} or is of semantic type ...). This is quite different than taking actions out to the fringes of REST via POST and making what is essentially an RPC queue. It maps actions back into state transitions within the uniform interface of REST. |
Let's say we create a mediatype which we call for the sake of brevity "application/wot+json". This mediatype is used to describe a href target within an interaction. It could be used in "link" because the mediatype describes the transfer layer interaction model. The "application/wot+json" mediatype defines a serialization constraint on JSON if needed (e.g. using a map for action parameters) and a transfer layer mapping for events, actions, and properties, to http methods, options, and subProtocols. For example: Property payloads consist of name-value pairs in a map Action payloads are a map as in properties: Events return a map as in properties: A Thing Description would, for example, be of mediatype "application/wot-td+json" and could contain links to the "application/wot+json" mediatype within its interactions or maybe specified as a default base. Here is an example of such a case where a default protocol binding could be defined by the mediatype in the interaction links:
|
Here is the same example using the proposed progressive simplified JSON TD format, with object structured interactions but with a "link" array pointing to resources that use the application/wot+json content format:
|
@benfrancis Please also have a look at the text in the proposal, which already gives explanations for many of the design choices. I am updating the text based on your questions. I try to give quick answers here, although a focused discussion will be hard after the generalization of the issue.
|
I'm aware that I haven't been all that attentive here, as much as I wish otherwise, but I did not know that we'd given up on this. Being able to integrate semantic annotations is one of several use cases driving the modularity work that is the primary focus of draft-08. Which has finally gotten unblocked after a month of wrestling with a particularly difficult problem. I still hope to have it published by late May. I don't know if you want to go into details here, but what is the incompatibility that makes it flat-out impossible to use JSON Schema as specified? I had thought we'd decided that they could be mixed pretty freely. [or we could continue this part of the discussion in json-schema-org/json-schema-spec#309] |
Please understand my above comment for the status quo in the TD spec. I am not done with the simplified proposal and we actually just discussed a further push of hopefully stable JSON-LD 1.1 features, which allow for a virtually identical syntax. JSON Schema validators would only need to be instructed to ignore The incompatibility has been JSON-LD 1.0. It will be quite a gamble to start a dependency on JSON-LD 1.1. Need to figure out how to deal with this, but JSON-LD 1.1 is really much better... Are you coming to IETF 101? |
@mkovatsc oh, great- sorry, I just woke up, my apologies for misreading :-) JSON Schema should already ignore Regarding IETF 101, no, I won't be there. JSON Schema is the only IETF-related thing I'm doing right now, and when we floated the idea of looking at JSON Schema to the recently-concluded JSON working group, they were quite dismissive of us, and said any such effort would almost certainly not adopt our drafts in anything resembling their current form. No clear reason was given. We're exploring our options, including the possibility of going through W3C for standardization. In fact I think @draggett might have been on a call with @Relequestual on this topic? Ironically, another IETF working group just asked us why we weren't on a standards track :-P We pointed them to the working group email thread where we were discouraged from that and haven't heard back. So right now I'm just focusing on meeting our community's needs with draft-08. |
@mkovatsc one more point:
They are not part of JSON Schema validation. Draft-07 and draft-08 are making annotations first-class citizens alongside of assertions (which are what implement validation). Simple annotations such as As we make JSON Schema more modular and extensible, I expect people to extend it mostly with annotations to convey application-specific or usage-specific information. A few people will not doubt make custom validation extensions for cases that are not generic enough to go into the standard validation. Once we have that it's probably worth looking at best practices for how to integrate semantic information with structural information. Perhaps JSON Schema just considered JSON-LD terms to be annotations (which would be the default behavior if they're not ignored entirely). It might also be worth re-considering JSON Schema's So semantic annotations would be in scope for JSON Schema as a generic system (as defined by the Core spec) once we have modular vocabularies. It would just not be in scope for JSON Schema Validation, and there would be no need to re-defined JSON-LD in the context of JSON Schema. We'd just reference it somehow. |
This matches my expectations. Units are not part of data validation, they are application-specific and should be annotations as mentioned above. Thanks. |
BTW: JSON Schema has We have only Is there a way forward besides making one format ugly? :) |
JSON Schema already had Write-only properties have several use cases, the two obvious being passwords or similarly sensitive information, and yes, action-ish controls. For those of us who prefer to model actions through state, that is a very important use case and needs to be supported. State need not be exposed to be valid resource state. One way state transfer makes sense in either direction. I'm not trying to sell you on this as much as emphasize that there's a demand for this independent of the TD's views on how to solve the "actions" problem.
Can you elaborate a bit on ugly vs not-ugly? At this point I stare at so much JSON Schema that I have no idea what looks off to most people :P |
Yes, I am aware that they are now part of JSON Schema and I also understand the usage there, why I said it makes sense there :) For Things the logic is a bit differently, in particular at the top level: When a Thing offers a Property, it is because it wants to expose this internal state. If it is not readable, it would not be a Property in the first place; Action are for modifying state that is not exposed. Hence, Being read-only would be the default case for our Properties (e.g., Evrythng proposal and experience), so there is an expectation to be able to omit this information. Thus, we have the attribute When adopting I am not opposed to align with JSON Schema and OpenAPI, so it might be that we have to live with this. |
@mkovatsc thanks, that makes a lot of sense! I do get the point of how and why you ended up with What I am hoping is that we can make all of this more modular in a way that implementations can support pluggable vocabularies easily. This would be done by making the annotation collection process much more clear and formalized (until draft-07 there was no guidance at all on it), marking vocabularies at a more granular level, e.g.:
and also make it easier to overly constraints on a vocabulary. So you could express something like:
and then have There's a lot of hand-waving here but I'm filing the proposals that would implement this in the next week or two, so hopefully we'll make it more concrete very soon. |
@mjkoster wrote:
This is exactly the kind of concrete approach we have in mind, and is what we have started to specify as a Web Thing REST API, and have implemented in our Web of Things gateway implementation. I would like to continue to incubate this approach within the Interest Group, as an extension to the JSON-TD proposal. You could indeed argue that there should be one MIME type for the Thing Description and one MIME type for the HTTP request payloads. I had just been thinking of it all as part of a Web Thing API. |
I'm happy to split this out into separate issues for areas that warrant a more lengthy discussion. I may have also filed this issue in the wrong repository because I only just realised you put the Siemens proposal in the wot-thing-description repository whereas the other proposals are in this wot repo.
Fair question. I'd be inclined to support both a string and an array because I imagine a single context could be a common case if stable schema repositories like schema.org emerge.
It has never been my intention that the key names provide semantic information. Rather that a schema for a Web Thing type could define what properties a Thing has. An optional
I'm proposing that as a simplification the interactions level could be removed and that capabilities are either a property, action or event.
That doesn't answer my question. Why can't the Thing URL be used as as that identifier? Why is an additional URN needed?
OK. Perhaps base can be optional and the Thing URL could be used as a fallback, like in HTML and CSS.
I thought the idea of adding a pre-processing step was to remove the hard dependency on JSON-LD and RDF. If these constraints continue to exist, I think that alone justifies continuing to incubate a separate plain JSON serialisation which doesn't suffer from these constraints. I understand the need to change "properties" to "fields" in schema definitions to avoid confusion, but this serialisation of nested schemas with arrays rather than using JSON Schema object notation seems unnecessarily complex for a JSON serialisation.
The JSON-TD proposal suggests case-insensitive fulll names defined in the International System of Units, but I realise this could benefit from a more formal definition.
This is an interesting reference which explains a lot of the thinking in your approach, thanks. I'd be happy to see some incubation work to test out using this approach with IoT to prove that it allows for the kind of automatic ad-hoc interoperability you imply it does. I remain sceptical but am happy to be proven wrong. In the meantime I'd also like to continue to incubate an approach built only on links and concrete protocol bindings. |
Let me split up the issues in JSON tagged Issues in the WG TD repo. A quick info here: digging deeper into JSON-LD 1.1 and applying it allows for further simplifications. If everything works out, the schema of a JSON-LD 1.1 compliant TD might turn out identical to JSON Schema! |
@mkovatsc: Thanks for filing all those separate issues, next time I will do that in the first place! The experimental version making use of JSON-LD 1.1 flexibility is already looking interesting. |
Thank you to Siemens for presenting their Simplified WoT Thing Description proposal to us today in the TD Serialization call.
I'm going to discuss this proposal further with the Web of Things team at Mozilla this week, but I have some initial feedback to share.
Firstly, whilst this proposal is still more complex than the JSON-TD proposal from Mozilla, EVRYTHNG and Ambrosus Technologies, it is in my view a significant step forward over the current JSON-LD serialisation so thanks for going to the effort of working on this.
@context
@type
@type
and a capability (property, action and event) has a single@type
?@type
(thing type, capability type and data type) be reduced down to two? (thing type and capability type). E.g. Do we really needSwitchStatus
andSwitchData
or could we just have anOnOffProperty
capability type whose data type is defined to be boolean in the capability's JSON-LD schema?@id
/id
base
schema
forms
"rel": ["get", "set"]
does not match my understanding of how link relations are intended to be used. They are supposed to "describe how the current context is related to another resource", not what protocol methods can be used with that resource.http:SubProtocol
also feels like a bit of a hack"rel":"self"
could be omitted and assumed as a default, but is included here to show a more common use of a link relation):links
rel
instead of an object key to indicate the type of link, e.g."rel":"alternate"
to point to a WebSocket endpoint for a Thing. It could potentially also be used to provide a link to a custom web-based user interface for a Thing.Media Type
I'd suggest
application/td+json
as that is the format used by most registered MIME types for JSON-based formats.Objects vs. Arrays
As I've mentioned before, we'd prefer the object representation. You can easily iterate through keys of an object in JavaScript. Having an ID in an array element is doable, but
thing.properties[0]
is a lot more clunky thanthing.properties.on
.The text was updated successfully, but these errors were encountered: