w3c / w3c/wot-scripting-api

Proposal: use TD `default` values

Open
#537 4 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

use case
Dominant language
HTML
Stars
45
Forks
21
PR merge metrics
No merged PRs in 30d

Description

hello,
I'd like to propose the scripting API to define variables the consumer leaves undefined with the default values from the TD (or const values?).

A simple use-case would be a Thing, expecting a fixed payload parameter based on the Interaction Affordance, like in the TD below.

Now with the scripting API using the default values a user won't have to worry about knowing the correct commandId.

{
  "actions": {
    "move": {
      "type": "object",
      "properties": {
        "commandId": {
          "type": "integer",
          "default": 5
        },
        // other dynamic properties like coordinates
      }
    },
    "dimLight": {
      "type": "object",
      "properties": {
        "commandId": {
          "type": "integer",
          "default": 6
        }
        // other dynamic properties like time span
      }
    }
  }
}

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the scripting API path that builds action payloads from a Thing Description, then determine how omitted variables and TD default or const values should be handled. Done should include a decided behavior for the commandId example and tests covering omitted values; the issue names no files or tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
json
Domain
api
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.