{
  "$schema": "http://json-schema.org/schema",
  "id": "AngularDevkitWorkspaceSchema",
  "title": "Angular Devkit Workspace Schema for validating workspace JSON.",
  "type": "object",
  "properties": {
    "$schema": {
      "type": "string",
      "description": "Link to schema."
    },
    "version": {
      "type": "number",
      "description": "Workspace Schema version."
    },
    "newProjectRoot": {
      "type": "string",
      "description": "New project root.",
      "default": "./"
    },
    "defaultProject": {
      "type": "string",
      "description": "The default project."
    },
    "cli": {
      "$ref": "#/definitions/tool",
      "default": {}
    },
    "schematics": {
      "$ref": "#/definitions/tool",
      "default": {}
    },
    "architect": {
      "$ref": "#/definitions/tool",
      "default": {}
    },
    "targets": {
      "$ref": "#/definitions/tool",
      "default": {}
    },    
    "projects": {
      "type": "object",
      "description": "A map of project names to project options.",
      "additionalProperties": {
        "$ref": "#/definitions/project"
      },
      "default": {}
    }
  },
  "additionalProperties": false,
  "required": [
    "version"
  ],
  "definitions": {
    "project": {
      "type": "object",
      "description": "Project options.",
      "properties": {
        "projectType": {
          "type": "string",
          "description": "Project type.",
          "enum": [
            "application",
            "library"
          ]
        },
        "root": {
          "type": "string",
          "description": "Root of the project sourcefiles."
        },
        "sourceRoot": {
          "type": "string",
          "description": "The root of the source files, assets and index.html file structure."
        },
        "prefix": {
          "type": "string",
          "description": "The prefix to apply to generated selectors."
        },
        "cli": {
          "$ref": "#/definitions/tool",
          "default": {}
        },
        "schematics": {
          "$ref": "#/definitions/tool",
          "default": {}
        },
        "architect": {
          "$ref": "#/definitions/tool",
          "default": {}
        },
        "targets": {
          "$ref": "#/definitions/tool",
          "default": {}
        },
        "i18n": {
          "$ref": "#/definitions/i18n",
          "default": {}
        }
      },
      "additionalProperties": false,
      "required": [
        "root",
        "projectType"
      ],
      "if": {
        "properties": {
          "projectType": {
            "const": "library"
          }
        }
      },
      "then": {
        "not": {
          "required": [
            "i18n"
          ]
        }
      }
    },
    "tool": {
      "type": "object",
      "description": "Tool options.",
      "properties": {
        "$schema": {
          "type": "string",
          "description": "Link to schema."
        }
      },
      "additionalProperties": true
    },
    "i18n": {
      "type": "object",
      "properties": {
        "sourceLocale": {
          "oneOf": [
            {
              "type": "string",
              "description": "Specifies the source locale of the application.",
              "default": "en-US",
              "pattern": "^[a-zA-Z]{2,3}(-[a-zA-Z]{4})?(-([a-zA-Z]{2}|[0-9]{3}))?(-[a-zA-Z]{5,8})?(-x(-[a-zA-Z0-9]{1,8})+)?$"
            },
            {
              "type": "object",
              "description": "Localization options to use for the source locale",
              "properties": {
                "code": {
                  "type": "string",
                  "description": "Specifies the locale code of the source locale",
                  "pattern": "^[a-zA-Z]{2,3}(-[a-zA-Z]{4})?(-([a-zA-Z]{2}|[0-9]{3}))?(-[a-zA-Z]{5,8})?(-x(-[a-zA-Z0-9]{1,8})+)?$"
                },
                "baseHref": {
                  "type": "string",
                  "description": "HTML base HREF to use for the locale (defaults to the locale code)"
                }
              },
              "additionalProperties": false
            }
          ]
        },
        "locales": {
          "type": "object",
          "additionalProperties": false,
          "patternProperties": {
            "^[a-zA-Z]{2,3}(-[a-zA-Z]{4})?(-([a-zA-Z]{2}|[0-9]{3}))?(-[a-zA-Z]{5,8})?(-x(-[a-zA-Z0-9]{1,8})+)?$": {
              "oneOf": [
                {
                  "type": "string",
                  "description": "Localization file to use for i18n"
                },
                {
                  "type": "object",
                  "description": "Localization options to use for the locale",
                  "properties": {
                    "translation": {
                      "type": "string",
                      "description": "Localization file to use for i18n"
                    },
                    "baseHref": {
                      "type": "string",
                      "description": "HTML base HREF to use for the locale (defaults to the locale code)"
                    }
                  },
                  "additionalProperties": false
                }
              ]
            }
          }
        }
      },
      "additionalProperties": false
    }
  }
}
