WebThingsIO / api

Web Thing API Specification
http://iot.mozilla.org/wot/
Other
164 stars 25 forks source link

Should the href on Property, Action and Event resources become a links array? #73

Open benfrancis opened 6 years ago

benfrancis commented 6 years ago

The latest W3C proposals use "links" for properties and events (and forms for actions but let's save that for a separate discussion).

Currently we just define a href as a string for each property, action and event URL.

A links array would be considerably more verbose, but also more flexible. For example it would allow multiple URLs to be specified for different protocols and data formats.

...
  "properties": {
    "on": {
      "type": "boolean",
      "links" [{
        "href": "/things/lamp/properties/on",
        "mediaType": "application/json"
      }]
    },
  }
...

You can also argue that our current approach is much simpler and that when a JSON Thing Description is fetched over HTTP a default assumption can be that property, action and event URLs are also JSON over HTTP.

benfrancis commented 6 years ago

One advantage of this approach is that, as in the experimental simplified TD example, the links can be more or less conformant with the links format in JSON Hyper-Schema, which is used by JSON Schema.

The whole example property definition above is actually valid JSON Schema (except I think they use targetMediaType rather than mediaType because they have various different types of mediaType to account for).

benfrancis commented 6 years ago

Note that the W3C spec seems to be moving in the direction of calling this "forms" rather than "links". (for properties and events too, not just actions as per #79). I personally think the forms concept is very strange.

If anyone has any further arguments why this should be links and not forms, you might want to make those arguments here https://github.com/w3c/wot-thing-description/issues/88