{
    "$schema": "http://json-schema.org/draft-04/schema#",
    "type": "object",
    "properties": {
        "$schema": {
            "type": "string",
            "description": "URL to a schema file"
        },
        "apiVersion": {
            "type": "integer",
            "description": "API Version"
        },
        "modules": {
            "type": "array",
            "description": "List of modules like controls, functions and additional resources like Cascading Style Sheets or JavaScript files.",
            "items": {
                "anyOf": [
                    {
                        "type": "object",
                        "properties": {
                            "type": {
                                "type": "string",
                                "enum": ["Package"],
                                "description": "Describes a reference to a package."
                            },
                            "nugetId": {
                                "type": "string",
                                "description": "This is the NugetId of the referenced package. The resources of the referenced package are used before the rest of the modules."
                            }
                        },
                        "required": ["type", "nugetId"],
                        "additionalProperties": false
                    },
                    {
                        "type": "object",
                        "properties": {
                            "type": {
                                "type": "string",
                                "enum": ["Control"],
                                "description": "Describes a tchmi control."
                            },
                            "basePath": {
                                "type": "string",
                                "description": "The base path to find all control files."
                            },
                            "descriptionFile": {
                                "type": "string",
                                "description": "Name of the description file for the control: Description.json in most cases."
                            },
                            "toolboxCategory": {
                                "type": "string",
                                "description": ""
                            },
                            "__notused__toolboxCategory": {
                                "type": "string",
                                "description": ""
                            }
                        },
                        "required": ["type", "descriptionFile"],
                        "additionalProperties": false
                    },
                    {
                        "type": "object",
                        "properties": {
                            "type": {
                                "type": "string",
                                "enum": ["Function"],
                                "description": "Describes a tchmi function."
                            },
                            "basePath": {
                                "type": "string",
                                "description": "The base path to find the function <functionName>.js and <functionName>.function.json files."
                            },
                            "descriptionFile": {
                                "type": "string",
                                "description": "Name of the description file for the function. This is <functionName>.function.json in most cases."
                            }
                        },
                        "required": ["type", "descriptionFile"],
                        "additionalProperties": false
                    },
                    {
                        "type": "object",
                        "properties": {
                            "type": {
                                "type": "string",
                                "enum": ["Resource"],
                                "description": "Defines we are refering to a resource. This can be a CSS Stylesheet or a JS file."
                            },
                            "path": {
                                "type": "string",
                                "description": "Url of the css or js resource."
                            },
                            "theme": {
                                "type": "string",
                                "description": "Restricts the CSS Resource to be used only for one specific theme name. Will be used for all themes if unset. (not valid for JS files)",
                                "minLength": 1
                            },
                            "component": {
                                "type": "string",
                                "description": "Groups the resource for theme override in project. (not valid for JS files)",
                                "minLength": 1
                            }
                        },
                        "required": ["type", "path"],
                        "additionalProperties": false
                    }
                ]
            }
        },
        "provideMetadata": {
            "type": "object",
            "description": "Metadata",
            "properties": {
                "toolbox": {
                    "type": "object",
                    "description": "Dictionary of category groups.",
                    "additionalProperties": {
                        "type": "object",
                        "description": "Dictionary of category names. Key has to be a number.",
                        "patternProperties": {
                            "^[0-9]*$": {
                                "anyOf": [
                                    {
                                        "type": "string",
                                        "description": "Category name."
                                    },
                                    {
                                        "type": "object",
                                        "description": "Category name by language code.",
                                        "properties": {
                                            "default": {
                                                "type": "string"
                                            }
                                        },
                                        "patternProperties": {
                                            "^[a-z]{2}-[A-Z]{2}$": {
                                                "type": "string"
                                            },
                                            "^[a-z]{2}$": {
                                                "type": "string"
                                            }
                                        },
                                        "requiredProperties": ["default"],
                                        "additionalProperties": false
                                    }
                                ]
                            }
                        },
                        "additionalProperties": false
                    }
                }
            },
            "additionalProperties": false
        },
        "uiProvider": {
            "description": "This packages provides some system ui implementation.",
            "type": "array",
            "items": {
                "oneOf": [
                    {
                        "type": "object",
                        "properties": {
                            "type": {
                                "type": "string",
                                "enum": ["keyboard"],
                                "description": "This definition provides a system keyboard implementation."
                            },
                            "name": {
                                "type": "string",
                                "description": "Defines the id of this keyboard implementation. Use a namespace string to avoid name collisions."
                            },
                            "projectBasedKeyboardFiles": {
                                "type": "boolean",
                                "description": "Defines if the keyboard needs a list of keyboards in the project directory (will be stored in tchmiconfig.json)",
                                "default": false
                            },
                            "projectBasedKeyboardFileExt": {
                                "type": "string",
                                "description": "Defines the extension of keyboard files in the project.",
                                "default": ".keyboard.json"
                            }
                        },
                        "additionalProperties": false,
                        "required": ["name", "type", "projectBasedKeyboardFiles"]
                    },
                    {
                        "type": "object",
                        "properties": {
                            "type": {
                                "type": "string",
                                "enum": ["popup"],
                                "description": "This definition provides a system popup implementation."
                            },
                            "name": {
                                "type": "string",
                                "description": "Defines the id of this popup implementation. Use a namespace string to avoid name collisions.",
                                "default": "TcHmi.Controls.Beckhoff.TcHmiPopup"
                            },
                            "popup": {
                                "type": "string",
                                "description": "Defines the type of the popup. TODO: Needed?"
                            }
                        },
                        "additionalProperties": false,
                        "required": ["name", "type"]
                    }
                ]
            }
        }
    },
    "additionalProperties": false
}
