Browse the docs

types

Adds named data types with a JSON Schema that params and outputs can refer to.

Details #

A data type is a name for a shape of data, such as a contact with a name and an email. You describe the shape once with a JSON Schema, and the type is registered with the extension.

Declare it in switchboard.json under adds.types. Every entry has an id (lowercase, digits and . _ -, up to 64 characters, starting with a letter), a title (1 to 80 characters), a schema and an optional description. Ids must be unique within the list.

{
  "adds": {
    "types": [
      { "id": "ticket", "title": "Ticket", "schema": { "type": "object", "properties": { "key": { "type": "string" }, "title": { "type": "string" } }, "required": ["key"] } }
    ]
  }
}

Gotchas #

  • Today the engine checks the entry and lists the type with the extension. No other part of the app uses it yet, so params and outputs don't refer to it by name. To change how a value is checked, describe it in the action's own params.

  • Keep every required name a real property, and give every array an items schema.

  • Unknown keys in an entry are refused.

Full example #

The Full example above is a working extension with two types, a contact and a priority, and a test that checks good and bad values against them. You can download it from the Full example section and edit it into your own.

See also #