{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://json.schemastore.org/libman.json",
  "allOf": [
    {
      "anyOf": [
        {
          "$ref": "#/definitions/specifiedProvider"
        },
        {
          "$ref": "#/definitions/defaultProvider"
        }
      ]
    },
    {
      "anyOf": [
        {
          "$ref": "#/definitions/specifiedDestination"
        },
        {
          "$ref": "#/definitions/defaultDestination"
        }
      ]
    },
    {
      "if": {
        "$ref": "#/definitions/fileMapping"
      },
      "then": {
        "$ref": "#/definitions/manifestVersion3"
      }
    }
  ],
  "definitions": {
    "libraryEntry": {
      "required": ["library"],
      "properties": {
        "files": {
          "description": "The file names of the individual files to copy to the project.",
          "type": "array",
          "default": null,
          "items": {
            "type": "string",
            "minLength": 1
          }
        },
        "library": {
          "description": "The unique identifier of the library.",
          "type": "string",
          "minLength": 1
        },
        "destination": {
          "description": "The relative folder path from this config file to the location where the files should be copied to.",
          "type": "string",
          "pattern": "^[^\\\\]+$"
        },
        "provider": {
          "description": "The unique identifier of the provider",
          "type": "string",
          "minLength": 1
        },
        "fileMappings": {
          "description": "A list of file mappings.",
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "root": {
                "description": "The mapping root within the library contents. If omitted, defaults to the library root.",
                "type": "string",
                "minLength": 1
              },
              "destination": {
                "description": "The destination for files included in this mapping. If omitted, defaults to a destination set for the library.",
                "type": "string",
                "minLength": 1
              },
              "files": {
                "description": "The file names of the individual files to copy to the project, relative to the specified root. If omitted, defaults to all files.",
                "type": "array",
                "default": null,
                "items": {
                  "type": "string",
                  "minLength": 1
                }
              }
            }
          }
        }
      }
    },
    "specifiedProvider": {
      "properties": {
        "libraries": {
          "items": {
            "required": ["provider"]
          }
        }
      },
      "not": {
        "required": ["defaultProvider"]
      }
    },
    "defaultProvider": {
      "properties": {
        "defaultProvider": {
          "description": "The unique identifier of the provider to use as default.",
          "type": "string",
          "minLength": 1
        }
      }
    },
    "specifiedDestination": {
      "properties": {
        "libraries": {
          "items": {
            "required": ["destination"]
          }
        }
      },
      "not": {
        "required": ["defaultDestination"]
      }
    },
    "defaultDestination": {
      "properties": {
        "defaultDestination": {
          "description": "The default destination to place library files.",
          "type": "string",
          "minLength": 1
        }
      }
    },
    "fileMapping": {
      "properties": {
        "libraries": {
          "contains": {
            "required": ["fileMappings"]
          }
        }
      }
    },
    "manifestVersion3": {
      "properties": {
        "version": {
          "const": "3.0"
        }
      },
      "required": ["version"]
    }
  },
  "properties": {
    "libraries": {
      "description": "A list of library references.",
      "type": "array",
      "items": {
        "$ref": "#/definitions/libraryEntry"
      }
    },
    "version": {
      "description": "The syntax version of this config file.",
      "enum": ["1.0", "3.0"],
      "default": "3.0"
    }
  },
  "required": ["libraries", "version"],
  "title": "JSON schema for client-side library config files",
  "type": "object"
}
