-
Notifications
You must be signed in to change notification settings - Fork 17
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
Replace interaction affordances in directory TD with a single link to its API endpoint #179
Conversation
The Notification and Search APIs got sacrificed in the process? If we are going for a simple link, I think it should the absolute URL of the Directory API root endpoint. |
@farshidtz wrote:
I was wondering about that too. In an HTTP-only API it might be feasible for a client to optionally ask for an event stream rather than a static JSON array from the same endpoint, using content negotiation. In other words: Request:
Response:
Request:
Response:
This is probably a bit over-simplified as I'm not particularly familiar with how Server Sent Events work under the hood, but you get the idea. It should be fine for JSONPath and XPath queries to use the same endpoint, by appending URI variables. SPARQL is a bit trickier because of the fixed requirements around HTTP verbs and URI variables etc. and the potential for naming collisions, but it might be possible to further overload the same API endpoint for a SPARQL query by using a similar content negotiation approach as above. I haven't investigated that in detail, but I do note that the SPARQL specification actually recommends using HTTP content negotiation to request a particular response format. e.g.
You mean instead of specifying a base? I have no problem with that. |
Not sure why we have to redesign the API to make the TD look better. A suitable API specification format should be capable of specifying a well-designed API.
Sorry I didn't see the base. No, I meant the link should be to the root endpoint of the API. Considering base as Another link could point to the spec. E.g. without thinking too much about the relation types: {
"base": "https://tdd.example.com",
"links": [{
"rel": "hosts",
"href": "/",
"type": "application/tdd+json"
},
{
"rel": "describedby",
"href": "https://url-of-openapi-spec",
"type": "application/vnd.oai.openapi;version=3.0"
}],
...
} I am not supporting nor am I against this change. For our use-cases, the OpenAPI spec is used to describe and consume the API. A TD for directory is still necessary to self-describe the directory or register directories inside a central one (federated directories @AndreaCimminoArriaga ), but that doesn't require specification of the APIs inside the TD and a simple link does the job. |
@farshidtz wrote:
Yes, but WoT Thing Descriptions are not a general purpose API specification format for describing web services, they are designed for describing the affordances of WoT devices.
The purpose is not to make the TD "look better", it's to remove the API description from the TD since it turns out TDs aren't well suited to that job.
I agree that the link should ideally link to the top level endpoint of the Directory Service API, whatever the WoT Discovery specification defines that to be. A disadvantage of linking to a Maybe separate
Sure, though I'm not sure what Consumers would do with that link?
👍 |
First of all, I'm not against the proposal nor in favour, I'm positively not sure what is best. Nevertheless, let me add some comments:
|
Ah, yes that was a typo sorry.
For WebThings Gateway we'd ideally like to be able to expose a Thing Description for a gateway (the physical hub) which describes certain physical affordances (e.g. |
The consensus seems (at this point) that we will NOT do this, but that a directory should return a concrete TD based on the (to-be) TM in the standard. So I propose closing this PR, but before I do would like to get confirmation on this assumption. Discussion in mtg held June 14 - consensus was to close, but to give it a week for any further comments, and if no objections in that time, to close. |
No objections. I think this approach could have worked as an alternative, but the consensus seems to be to persevere with trying to describe the directory service API using forms. |
Fixes #172 and #178.
This is an alternative proposal for the Thing Description of a Directory which would make #158, #159 and #160 unnecessary.
The rationale is described in detail in #172 and #178, but it basically boils down to the fact that trying to describe the whole Directory Service API in a Thing Description (which are designed for describing devices, not general web services) isn't really working.
The proposal in this PR is to instead just provide a link to the top level endpoint of the Directory Service API and define the details of the API out of band in the WoT Discovery specification. The proposed link format uses the
hosts
link relation type defined in RFC6690 and a proposed newapplication/tdd+json
content type.At the simplest level, the
application/tdd+json
content type could be defined as a JSON array of Thing Descriptions (application/td+json
) and can be parsed as such. A Consumer implementing the full HTTP-based Directory Service API would also know how to create, update, delete and search the list of Things by implementing API defined in the prose of the specification, instead of parsing Forms in a Thing Description.With this approach, the Thing Description of a directory is just used for discovering a directory (using the various introduction mechanisms in the WoT Discovery spec) and linking to its top level endpoint. The actual API of the directory web service would be defined in the normative text of the WoT Discovery specification, which may also provide a machine-readable OpenAPI specification as a convenience for developers.
Preview | Diff