Skip to content
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

Thing Description for LinkSmart directory #36

Merged
merged 2 commits into from
Jul 13, 2020
Merged

Conversation

farshidtz
Copy link
Member

This is an improved version of the TD presented in F2F for the LinkSmart directory.

Copy link
Member

@benfrancis benfrancis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes for a bit of an awkward Thing Description, with the API of the directory being shoehorned into being described as properties and actions.

I made my own attempt at describing a directory with a Thing Description, with the list of things as a property rather than links, and that turned out quite awkward too.

I'm beginning to wonder whether trying to describe this API in terms of properties, actions and events is actually a good idea. Thing Descriptions are not great at describing collections of resources in general.

See #34 (comment)

Comment on lines 14 to 44
"td": {
"description": "Add, modify, or remove a Thing Description",
"uriVariables": {
"id": {
"title": "Thing Description ID",
"type": "string",
"format": "iri-reference"
}
},
"forms": [
{
"href": "/td",
"htv:methodName": "POST",
"contentType": "application/ld+json"
},
{
"href": "/td/{id}",
"htv:methodName": "PUT",
"contentType": "application/ld+json"
},
{
"href": "/td/{id}",
"htv:methodName": "PATCH",
"contentType": "application/ld+json"
},
{
"href": "/td/{id}",
"htv:methodName": "DELETE"
}
]
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a bit of a strange example of an action because it's really several different actions, as I think is revealed by the ambiguous name. I would usually expect an action to be describable with a verb or verb phrase.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had my concerns when mapping the OpenAPI specs to TD (see the last slide).

I agree that they are different actions, and separating them makes it clearer. However, I would keep the names equivalent to the HTTP methods, because they have their own semantics.

{
  ...
  "actions": {
    "postTD": {
      "description": "Add an anonymous Thing Description (without ID)",
      "forms": [
        {
          "href": "/td",
          "htv:methodName": "POST",
          "contentType": "application/ld+json"
          // how to specify that the response contains a system-generated id in Location header?
        }
      ]
    },
    "putTD": {
      "description": "Add or modify a Thing Description",
      "uriVariables": {
        "id": {
          "title": "Thing Description ID",
          "type": "string",
          "format": "iri-reference"
        }
      },
      "forms": [
        {
          "href": "/td/{id}",
          "htv:methodName": "PUT",
          "contentType": "application/ld+json"
        }
      ]
    },
    "patchTD": {
      "description": "Modify parts of a Thing Description",
      "uriVariables": {
        "id": {
          "title": "Thing Description ID",
          "type": "string",
          "format": "iri-reference"
        }
      },
      "forms": [
        {
          "href": "/td/{id}",
          "htv:methodName": "PATCH",
          "contentType": "application/ld+json"
        }
      ]
    },
    "deleteTD": {
      "description": "Remove a Thing Description",
      "uriVariables": {
        "id": {
          "title": "Thing Description ID",
          "type": "string",
          "format": "iri-reference"
        }
      },
      "forms": [
        {
          "href": "/td/{id}",
          "htv:methodName": "DELETE"
        }
      ]
    }
  }
  ...
}

Comment on lines +47 to +63
"td": {
"description": "Retrieve a Thing Description",
"uriVariables": {
"id": {
"title": "Thing Description ID",
"type": "string",
"format": "iri-reference"
}
},
"forms": [
{
"href": "/td/{id}",
"htv:methodName": "GET",
"contentType": "application/ld+json"
}
]
},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using URL templates in the form of a property description is also kind of odd, because it's really a collection of multiple resources which is being described rather than a single property resource.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO, TD has evolved for describing things and not collection services. Trying to use a TD to describe a collection API has its side effects. I decided to map "properties" to resources of the collection. I also thought about "getTD" and "listTD" as actions on the collection, but it seems contradictory to the specs because those operations don't manipulate the state of the collection.

"An Interaction Affordance that allows to invoke a function of the Thing, which manipulates state" [1]

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that getTD and ListTD don't make sense as actions.

@farshidtz farshidtz marked this pull request as draft July 11, 2020 10:36
@farshidtz farshidtz marked this pull request as ready for review July 13, 2020 14:37
@mmccool mmccool merged commit d8dc6c3 into w3c:master Jul 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants