Configuration Schema

This json schema is a general-purpose mechanism for describing SMC-compliant json configuration.

Field: type

Required | String

All schemas require a type field.

The value is not constrained to a particular enum, but the enumerated values below are explicitly supported. If the type is not explicitly supported then the value will be displayed as prettified json.
{
    "type": "object" | "dict" | "list" | "collection" | "string" | "int" | "float" | "boolean" | "ip" | "port" | "iso8601" | "timestamp" | "password"
}

Complex Types

Complex types represent values which are either json objects or json arrays.

Type Description

object

A json object with known fields. See the Schema: object section for details

dict

A json object with arbitrary keys. See the Schema: dict section for details

list

A json array with a determinate order. See the Schema: list and collection section for details

collection

A json array with an indeterminate order. See the Schema: list and collection section for details

Simple Types

Simple types represent values which are json primitives - strings, numbers, booleans.

string

A generic string

"abc123"

int

An integer

1

float

A float

1.0

boolean

A boolean

true, "true", "TRUE", "True", 1, false, "false", "False", "FALSE", 0

yes or no

ip

An internet ip

127.0.0.1

port

A tcp port - i.e. an integer between 0-65535

8080

iso8601

An iso8601/RFC3339 compliant date-time representation

2020-11-09T17:12:42Z

As a human-readable date and time

timestamp

A unix tiemstamp. This will display in a human-readable format

1604942049

As a human-readable date and time

password

A password string

1604942049

Asterisks

Field: label

Optional | String

Provides a display label for the schema.

Field: description

Optional | String

Supplies a description of the schema.

Field: required

Optional | Boolean

If true, a value is required.

Field: hidden

Optional | Boolean

If true, this value will not be displayed. If the value is a complex object then the entire json subtree will be hidden.

Field: editable

Optional | Boolean

Whether the value is editable.

object types are inherently uneditable in themselves, as their keys and associated values are pre-defined by the schema.

Field: default

Optional | JSON

Sets a default value if the value is 'empty' (i.e. missing).

9/11/20 Zero-length strings and null are inconsistently treated as 'empty' values.

Field: sort

Optional | Integer | Default = 0

Provides a sorting hint for display. Primarily used for schemas within a parent object schema, to establish which fields should present first.

Higher values appear first. Negative values are allowed and, by virtue, of the default being 0 are moved to the bottom.

Fields with the same sort value are ordered by the case-insensitive field’s key.

Field: unit

Optional | String

Appends the given string as a suffix to the value.

e.g.

Schema Value Display
{
  "type": "int",
  "unit": "kWh"
}

123

123kWh

Only applicable to simple types

Schema: object

A json object with a defined set of allowed fields and their schemas.

Field: fields

Required | Object

An object with keys matching the fields of the object, and schemas for each field’s values.

e.g.

Schema Value
{
    "type": "object",
    "fields": {
        "name": {
            "type": "string"
        },
        "port": {
            "type": "port"
        }
    }
{
{
    "name": "micro-service-A",
    "port": 8081,
}

Schema: dict

A json object with arbitrary keys and all values conforming to the same schema.

This is most useful for defining key-pairs where the value is itself a simple type.

Field: items

Required | Schema

Specifies the schema for the values.

e.g.

Schema Value
{
  "type": "dict",
  "items": {
    "type": "string"
  }
}
{
    "0a712": "Device A",
    "87ac3": "Device B",
    "a8e71": "Device C",
    ...
}

Schema: list and collection

list is an ordered array of values. collection is an unordered array of values.

Field: items

Required | Schema

Specifies the schema for the values.

e.g.

Schema Value
{
  "type": "dict",
  "items": {
    "type": "string"
  }
}
{
    "0a712": "Device A",
    "87ac3": "Device B",
    "a8e71": "Device C",
    ...
}

Field: item_label

Optional | String

This only applies when the items are a complex type. It uses lodash.get() dot-notation to reference the location of the label in the value object.