Skip to content

Should schema.type be always defined?  #546

@relu91

Description

@relu91

TODO: introduce better the problem @JKRhb

Regarding the use cases, please find a brief first attempt (that definitely needs more work) for the four terms below:

oneOf

Relevant when a device described by a TD offers two different representations of the same resource (e.g., a property or an action output). A concrete example is the things property in the Thing Description Directory API, where – depending on the URI variable format – the directory can return TDs either as an array or a "collection", i.e. as part of a JSON object.

const

As a developer, I might want to specify that a Thing always returns a certain value when an action is performed. A simple example could be a value like "Success". Combined with oneOf, we could describe that an interaction (in this case an action) always either returns "Success" or "Operation failed" like so:

{
  "actions": {
    "exampleAction": {
      "output": {
        "oneOf": [
          {
            "const": "Success"
          },
          {
            "const": "Operation failed"
          }
        ]
      }
    }
  }
}

default

As a developer, I want to save bandwidth, especially in resource-constrained environments. Therefore, I want to be able to specify a default value that has to be assumed by a TD consumer if the response sent after an operation has been completed does not contain a value.

enum

As a developer, I want to constrain the values that are valid as an interaction output to a set of values. This could be used to describe the allowed states of a smart light ("on" or "off"), for example.

Originally posted by @JKRhb in #534 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    propose closingSolutions exists and labelled as to be closed soon

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions