Skip to main content

Extensions

https://json-schema.org/understanding-json-schema/reference/index.html

Base Schema

{
"type": "object",
"properties": $EXTENSION_SCHEMA
}

Extension Schema (Example)

{
"myExtension": {
"type": "object",
"properties": {
"myProperty": {
"type": "string"
}
}
}
}
  • Top-level object property is used to identify custom data (e.g., myExtension). This property must be of type object and contain a properties field.

  • It must also contain a file property to determine if the extension expects a file on the asset.

  • Custom fields are defined in the properties section of the object. The key of the property (e.g., myProperty) is used to identify the property.

  • Custom supported field types include string, number, boolean, and array.

  • Can use custom type definitions using $ref

{
"$defs": {
"color": {
"type": "object",
"properties": {
"r": { "type": "number" },
"g": { "type": "number" },
"b": { "type": "number" },
"a": { "type": "number" }
}
}
},
"properties": {
"color": { "$ref": "#/$defs/color" }
}
}
  • Array fields use additional fields items, minItems, maxItems

  • Enum strings can be created by adding an enum property.

  • The default field can be used to set a default value for any property.

  • The name property can be set to specify the label name for the field. (NOTE: may be replaced by title to align with JSONSchema)

  • ui:widget can be set to single-dropdown, textarea

  • ui:hidden can be set to hide the propery from the ui.

  • ui:sequenceFilterable can be used to expose a property to the filter options for dynamic programming.

  • ui:fieldDescription can be used to add a description above the field.

  • ui:thumbnail can be used to add an image src above the field.

  • ui:labelPrefix can be used to prefix the dropdown label

The allOf property can be used to add conditional fields to the UI, using ui:hidden:

  "allOf": [
{
"if": {
"properties": {
"programmingType": {
"const": "Takeover"
}
}
},
"then": {
"properties": {
"seasons": {
"ui:hidden": true
},
"regions": {
"ui:hidden": true
}
}
}
}
]

Examples of extensions:

Color

asset.data.color.value // { r: 0, g: 255, b: 0, a: 1 }
// current approach
if (asset.extensionId) {
if ('liveStream' in asset.data) {
// treat as a live stream
}
} else {
// treat as a file
}

// how do we support svrunner built-in custom types? (e.g., color, web?)

if (asset.extensionId) {
if ('liveStream' in asset.data) {
// treat as a live stream
}
} else if ('Color' in asset.data) {
// new branch, treat as a color
} else {
// treat as a file
}

custom extension:

{
"$ref": "#/$defs/svrunner:color"
}

our code base:

{
"$defs": {
"color": {
"type": "object",
"properties": {
"r": { "type": "number" },
"g": { "type": "number" },
"b": { "type": "number" },
"a": { "type": "number" }
}
}
"svrunner:color": {
"svrunner:internal": true,
"name": "Color",
"properties": {
"value": { "$ref": "#/$defs/color" }
}
}
}
}

Live Stream

{
"liveStream": {
"name": "Live Stream",
"type": "object",
"properties": {
"rtspLink": {
"type": "string",
"name": "RTSP Link"
},
"qrLink": {
"type": "string",
"name": "QR Link"
},
"title": {
"type": "string",
"name": "Title"
},
"description": {
"type": "string",
"ui:widget": "textarea",
"name": "Description"
},
"showDate": {
"type": "boolean",
"name": "Show Date"
},
"template": {
"type": "string",
"enum": ["A", "B", "C", "D"],
"name": "Template"
},
"username": {
"type": "string",
"name": "RTSP Auth User"
},
"password": {
"type": "string",
"name": "RTSP Auth Password"
}
}
}
}

Generative

{
"generative": {
"name": "Generative",
"type": "object",
"properties": {
"descriptionTitle": {
"name": "Description Title",
"type": "string"
},
"descriptionCopy": {
"name": "Description Copy",
"type": "string",
"ui:widget": "textarea"
}
}
}
}

The Hall

{
"theHall": {
"file": true,
"name": "The Hall",
"type": "object",
"properties": {
"active": {
"name": "Active",
"type": "boolean",
"default": true
},
"programmingType": {
"name": "Programming Type",
"type": "string",
"enum": ["Regular", "Takeover"],
"default": "Regular"
},
"seasons": {
"name": "Seasons",
"ui:widget": "single-dropdown",
"type": "array",
"items": {
"type": "string",
"enum": ["Spring", "Summer", "Fall", "Winter"]
},
"minItems": 0,
"maxItems": 4,
"default": ["Spring", "Summer", "Fall", "Winter"]
},
"regions": {
"name": "Region",
"type": "string",
"ui:sequenceFilterable": true,
"enum": [
"Northeast",
"Mid-Atlantic",
"Great Lakes",
"Southeast",
"Florida",
"The South",
"The Great Plains",
"The Rockies"
]
},
"abstractionPattern": {
"name": "Abstraction Patterns",
"type": "array",
"ui:widget": "single-dropdown",
"ui:sequenceFilterable": true,
"items": {
"type": "string",
"enum": [
"Oil Paint",
"Point Cloud",
"Mosaic",
"Graphic Simplification"
]
},
"minItems": 0,
"maxItems": 4,
"default": [
"Oil Paint",
"Point Cloud",
"Mosaic",
"Graphic Simplification"
]
},
"afterHours": {
"name": "After Hours",
"type": "boolean",
"default": false
}
},
"allOf": [
{
"if": {
"properties": {
"programmingType": {
"const": "Takeover"
}
}
},
"then": {
"properties": {
"seasons": {
"ui:hidden": true
},
"regions": {
"ui:hidden": true
},
"abstractionPattern": {
"ui:hidden": true
},
"afterHours": {
"ui:hidden": true
}
}
}
}
]
}
}