{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "definitions": {
    "fileExtension": {
      "pattern": "^\\.[^/\\\\]+$"
    },
    "fileName": {
      "pattern": "^[^/\\\\|:><\"?\\*]+$"
    },
    "ext-ext": {
      "type": "object",
      "additionalProperties": false,
      "patternProperties": {
        "^(\\.[^/\\\\]+|\\*)$": {
          "type": "array",
          "uniqueItems": true,
          "items": {
            "$ref": "#/definitions/fileExtension"
          }
        }
      }
    },
    "file-file": {
      "type": "object",
      "additionalProperties": false,
      "patternProperties": {
        "^[^/\\\\|:><\"?\\*]+$": {
          "type": "array",
          "uniqueItems": true,
          "items": {
            "$ref": "#/definitions/fileName"
          }
        }
      }
    },
    "file-ext": {
      "type": "object",
      "additionalProperties": false,
      "patternProperties": {
        "^([^/\\\\|:><\"?\\*]+|\\*)$": {
          "type": "array",
          "uniqueItems": true,
          "items": {
            "$ref": "#/definitions/fileExtension"
          }
        }
      }
    },
    "providers": {
      "type": "object",
      "properties": {
        "addedExtension": {
          "description": "If this exist, files with an additional extension should nest under file without additional extension. Example: file.html.css nest under file.html",
          "type": "object",
          "maxProperties": 0
        },
        "pathSegment": {
          "description": "If this exists, files with \"extra\" extension part in the file name should nest under files without it, but having same name and last extension. Example: file.min.js nest under file.js.",
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "add": {
              "description": "Add nesting rules in the order to be applied by corresponding provider, where each rule entry has a form 'child: collection of potential parents'.",
              "properties": {
                ".*": {
                  "type": "array",
                  "uniqueItems": true,
                  "items": {
                    "$ref": "#/definitions/fileExtension"
                  }
                }
              }
            },
            "remove": {
              "description": "Remove specified nesting rules if they are merged from higher level nesting settings.",
              "oneOf": [
                {
                  "type": "object",
                  "additionalProperties": {
                    "type": "array",
                    "uniqueItems": true,
                    "items": {
                      "$ref": "#/definitions/fileExtension"
                    }
                  }
                },
                {
                  "enum": ["*"]
                }
              ]
            }
          }
        },
        "extensionToExtension": {
          "description": "Nest files with specific extensions under other specific extensions",
          "additionalProperties": false,
          "properties": {
            "add": {
              "description": "Add nesting rules in the order to be applied by corresponding provider, where each rule entry has a form 'child: collection of potential parents'.",
              "allOf": [
                {
                  "$ref": "#/definitions/ext-ext"
                }
              ]
            },
            "remove": {
              "description": "Remove specified nesting rules if they are merged from higher level nesting settings.",
              "oneOf": [
                {
                  "$ref": "#/definitions/ext-ext"
                },
                {
                  "enum": ["*"]
                }
              ]
            }
          }
        },
        "fileToFile": {
          "description": "Nest specific file names under other specific file names",
          "additionalProperties": false,
          "properties": {
            "add": {
              "description": "Add nesting rules in the order to be applied by corresponding provider, where each rule entry has a form 'child: collection of potential parents'.",
              "allOf": [
                {
                  "$ref": "#/definitions/file-file"
                }
              ]
            },
            "remove": {
              "description": "Remove specified nesting rules if they are merged from higher level nesting settings.",
              "oneOf": [
                {
                  "$ref": "#/definitions/file-file"
                },
                {
                  "enum": ["*"]
                }
              ]
            }
          }
        },
        "fileSuffixToExtension": {
          "description": "Nest files with specified suffixes under files with specified extensions.",
          "additionalProperties": false,
          "properties": {
            "add": {
              "description": "Add nesting rules in the order to be applied by corresponding provider, where each rule entry has a form 'child: collection of potential parents'.",
              "allOf": [
                {
                  "$ref": "#/definitions/file-ext"
                }
              ]
            },
            "remove": {
              "description": "Remove specified nesting rules if they are merged from higher level nesting settings.",
              "oneOf": [
                {
                  "$ref": "#/definitions/file-ext"
                },
                {
                  "enum": ["*"]
                }
              ]
            }
          }
        },
        "allExtensions": {
          "description": "A greedy version of 'extensionToExtension' and has * as the only child key",
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "add": {
              "description": "Add nesting rules in the order to be applied by corresponding provider, where each rule entry has a form 'child: collection of potential parents'.",
              "properties": {
                ".*": {
                  "type": "array",
                  "uniqueItems": true,
                  "items": {
                    "$ref": "#/definitions/fileExtension"
                  }
                }
              }
            },
            "remove": {
              "description": "Remove specified nesting rules if they are merged from higher level nesting settings.",
              "oneOf": [
                {
                  "type": "object",
                  "properties": {
                    ".*": {
                      "type": "array",
                      "items": {
                        "$ref": "#/definitions/fileExtension"
                      }
                    }
                  }
                },
                {
                  "type": "string",
                  "enum": ["*"]
                }
              ]
            }
          }
        }
      }
    }
  },
  "id": "https://json.schemastore.org/vs-nesting.json",
  "properties": {
    "root": {
      "description": "Determines if this is the root nesting config file and no further inheritance is required.",
      "type": "boolean",
      "default": false
    },
    "dependentFileProviders": {
      "description": "Contains a collection of nesting rule providers specified in the order to be applied.",
      "type": "object",
      "properties": {
        "add": {
          "description": "Add nesting rules in the order to be applied by corresponding provider, where each rule entry has a form 'child: collection of potential parents'.",
          "allOf": [
            {
              "$ref": "#/definitions/providers"
            }
          ]
        },
        "remove": {
          "description": "Remove specified nesting rules if they are merged from higher level nesting settings.",
          "oneOf": [
            {
              "$ref": "#/definitions/providers"
            },
            {
              "enum": ["*"]
            }
          ]
        }
      }
    }
  },
  "title": "JSON schema for Visual Studio's file nesting feature",
  "type": "object"
}
