{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "type": "object",
  "description": "An atvise display configuration file",
  "properties": {
    "title": {
      "type": "string",
      "description": "A display's title"
    },
    "description": {
      "type": "string",
      "description": "A short description of the display"
    },
    "parameters": {
      "type": "array",
      "description": "Display parameters",
      "items": {
        "$comment": "NOTE: This is imported from './parameter-config.json'",
        "type": "object",
        "description": "A parameter",
        "required": ["name", "valuetype", "behavior"],
        "properties": {
          "name": {
            "type": "string",
            "description": "The parameter's name"
          },
          "desc": {
            "type": "string",
            "description": "A short description of what the parameter does"
          },
          "substitute": {
            "type": "string",
            "description": "A string to search in the code and replace with the parameter's value"
          },
          "valuetype": {
            "type": "string",
            "description": "The parameter's type",
            "enum": [
              "address",
              "display",
              "string",
              "trstring",
              "number",
              "bool",
              "color",
              "enum",
              "global"
            ]
          },
          "behavior": {
            "type": "string",
            "enum": ["mandatory", "optional", "hidden"]
          },
          "defaultvalue": {
            "type": "string"
          },
          "config": {
            "type": "string",
            "description": "Holds possible values in enum parameters",
            "examples": ["Yes;No"]
          },
          "group": {
            "type": "string"
          },
          "target": {
            "type": "object",
            "properties": {
              "namespaceIndex": {
                "type": "integer"
              },
              "name": {
                "type": "string"
              }
            },
            "required": ["namespaceIndex", "name"],
            "additionalProperties": false
          }
        },
        "defaultSnippets": [
          {
            "label": "New parameter",
            "description": "Creates an additional parameter",
            "body": {
              "name": "$1",
              "valuetype": "$2",
              "behavior": "$3"
            }
          }
        ]
      }
    },
    "dependencies": {
      "type": "array",
      "description": "External scripts to load",
      "deprecated": true,
      "items": {
        "type": "string"
      }
    },
    "scripts": {
      "type": "array",
      "contains": {
        "$ref": "#/definitions/inline-script"
      },
      "items": {
        "oneOf": [
          {
            "$ref": "#/definitions/external-script"
          },
          {
            "$ref": "#/definitions/inline-script"
          }
        ]
      },
      "defaultSnippets": [
        {
          "label": "Scripts",
          "description": "Adds a scripts configuration",
          "body": [
            {
              "type": "inline"
            },
            {
              "type": "${1:referenced}",
              "src": "/$2"
            }
          ]
        }
      ]
    }
  },
  "definitions": {
    "script-common": {
      "type": "object",
      "required": ["type"],
      "properties": {
        "type": {
          "type": "string"
        },
        "name": {
          "type": "string",
          "description": "An optional name to give the script"
        },
        "mimeType": {
          "type": "string",
          "default": "text/ecmascript"
        }
      }
    },
    "inline-script": {
      "description": "A display's inline script",
      "allOf": [
        {
          "$ref": "#/definitions/script-common"
        },
        {
          "type": "object",
          "required": ["type"],
          "properties": {
            "type": {
              "type": "string",
              "const": "inline"
            }
          }
        }
      ]
    },
    "external-script": {
      "title": "External script",
      "allOf": [
        {
          "$ref": "#/definitions/script-common"
        },
        {
          "type": "object",
          "required": ["type", "src"],
          "properties": {
            "type": {
              "type": "string",
              "enum": ["linked", "referenced"]
            },
            "src": {
              "type": "string"
            }
          }
        }
      ]
    }
  }
}
