{
    "$schema": "http://json-schema.org/draft-04/schema#",
    "name": "Package",
    "type": "object",
    "additionalProperties": false,
    "required": [ "name", "version", "description" ],
    "properties": {
        "name": {
            "type": "string",
            "description": "Package name."
        },
        "version": {
            "type": "string",
            "description": "Package version."
        },
        "description": {
            "type": "string",
            "description": "Short package description."
        },
        "keywords": {
            "type": "array",
            "items": {
                "type": "string",
                "description": "A tag/keyword that this package relates to."
            }
        },
        "homepage": {
            "type": "string",
            "description": "Homepage URL for the project.",
            "format": "uri"
        },
        "repository": {
            "type": "string",
            "description": "Repository URL for the project.",
            "format": "uri"
        },
        "documentation": {
            "type": "string",
            "description": "Documentation URL for the project.",
            "format": "uri"
        },
        "license": {
            "type": "string",
            "description": "License name."
        },
        "authors": {
            "$ref": "#/definitions/authors"
        },
        "readme": {
            "type": "string",
            "description": "The path to the README file"
        },
        "classifiers":  {
            "type": "array",
            "description": "A list of trove classifers."
        },
        "dependencies": {
            "type": "object",
            "description": "This is a hash of package name (keys) and version constraints (values) that are required to run this package.",
            "required": ["python"],
            "properties": {
                "python": {
                    "type": "string",
                    "description": "The Python versions the package is compatible with."
                }
            },
            "patternProperties": {
                "^[a-zA-Z-_.0-9]+$": {
                    "oneOf": [
                        {
                            "$ref": "#/definitions/dependency"
                        },
                        {
                            "$ref": "#/definitions/long-dependency"
                        },
                        {
                            "$ref": "#/definitions/git-dependency"
                        },
                        {
                            "$ref": "#/definitions/file-dependency"
                        },
                        {
                            "$ref": "#/definitions/path-dependency"
                        }
                    ]
                }
            },
            "additionalProperties": false
        },
        "dev-dependencies": {
            "type": "object",
            "description": "This is a hash of package name (keys) and version constraints (values) that this package requires for developing it (testing tools and such).",
            "patternProperties": {
                "^[a-zA-Z-_.0-9]+$": {
                    "oneOf": [
                        {
                            "$ref": "#/definitions/dependency"
                        },
                        {
                            "$ref": "#/definitions/long-dependency"
                        },
                        {
                            "$ref": "#/definitions/git-dependency"
                        },
                        {
                            "$ref": "#/definitions/file-dependency"
                        }
                    ]
                }
            },
            "additionalProperties": false
        },
        "extras": {
            "type": "object",
            "patternProperties": {
                "^[a-zA-Z-_.0-9]+$": {
                    "type": "array",
                    "items": {
                        "type": "string"
                    }
                }
            }
        },
        "build": {
            "type": "string",
            "description": "The file used to build extensions."
        },
        "source": {
            "type": "array",
            "description": "A set of additional repositories where packages can be found.",
            "additionalProperties": {
                "$ref": "#/definitions/repository"
            },
            "items": {
                "$ref": "#/definitions/repository"
            }
        },
        "scripts": {
            "type": "object",
            "description": "A hash of scripts to be installed.",
            "items": {
                "type": "string"
            }
        },
        "plugins": {
            "type": "object",
            "description": "A hash of hashes representing plugins",
            "patternProperties": {
                "^[a-zA-Z-_.0-9]+$": {
                    "type": "object",
                    "patternProperties": {
                        "^[a-zA-Z-_.0-9]+$": {
                            "type": "string"
                        }
                    }
                }
            }
        }
    },
    "definitions": {
        "authors": {
            "type": "array",
            "description": "List of authors that contributed to the package. This is typically the main maintainers, not the full list.",
            "items": {
                "type": "string"
            }
        },
        "dependency": {
            "type": "string",
            "description": "The constraint of the dependency."
        },
        "long-dependency": {
            "type": "object",
            "required": ["version"],
            "additionalProperties": false,
            "properties": {
                "version": {
                    "type": "string",
                    "description": "The constraint of the dependency."
                },
                "python": {
                    "type": "string",
                    "description": "The python versions for which the dependency should be installed."
                },
                "platform": {
                    "type": "string",
                    "description": "The platform(s) for which the dependency should be installed."
                },
                "allows-prereleases": {
                    "type": "boolean",
                    "description": "Whether the dependency allows prereleases or not."
                },
                "optional": {
                    "type": "boolean",
                    "description": "Whether the dependency is optional or not."
                },
                "extras": {
                    "type": "array",
                    "description": "The required extras for this dependency.",
                    "items": {
                        "type": "string"
                    }
                }
            }
        },
        "git-dependency": {
            "type": "object",
            "required": ["git"],
            "additionalProperties": false,
            "properties": {
                "git": {
                    "type": "string",
                    "description": "The url of the git repository.",
                    "format": "uri"
                },
                "branch": {
                    "type": "string",
                    "description": "The branch to checkout."
                },
                "tag": {
                    "type": "string",
                    "description": "The tag to checkout."
                },
                "rev": {
                    "type": "string",
                    "description": "The revision to checkout."
                },
                "python": {
                    "type": "string",
                    "description": "The python versions for which the dependency should be installed."
                },
                "platform": {
                    "type": "string",
                    "description": "The platform(s) for which the dependency should be installed."
                },
                "allows-prereleases": {
                    "type": "boolean",
                    "description": "Whether the dependency allows prereleases or not."
                },
                "optional": {
                    "type": "boolean",
                    "description": "Whether the dependency is optional or not."
                },
                "extras": {
                    "type": "array",
                    "description": "The required extras for this dependency.",
                    "items": {
                        "type": "string"
                    }
                }
            }
        },
        "file-dependency": {
            "type": "object",
            "required": ["file"],
            "additionalProperties": false,
            "properties": {
                "file": {
                    "type": "string",
                    "description": "The path to the file."
                },
                "python": {
                    "type": "string",
                    "description": "The python versions for which the dependency should be installed."
                },
                "platform": {
                    "type": "string",
                    "description": "The platform(s) for which the dependency should be installed."
                },
                "optional": {
                    "type": "boolean",
                    "description": "Whether the dependency is optional or not."
                },
                "extras": {
                    "type": "array",
                    "description": "The required extras for this dependency.",
                    "items": {
                        "type": "string"
                    }
                }
            }
        },
        "path-dependency": {
            "type": "object",
            "required": ["path"],
            "additionalProperties": false,
            "properties": {
                "path": {
                    "type": "string",
                    "description": "The path to the dependency."
                },
                "python": {
                    "type": "string",
                    "description": "The python versions for which the dependency should be installed."
                },
                "platform": {
                    "type": "string",
                    "description": "The platform(s) for which the dependency should be installed."
                },
                "optional": {
                    "type": "boolean",
                    "description": "Whether the dependency is optional or not."
                },
                "extras": {
                    "type": "array",
                    "description": "The required extras for this dependency.",
                    "items": {
                        "type": "string"
                    }
                },
                "develop": {
                    "type": "boolean",
                    "description": "Whether to install the dependency in development mode."
                }
            }
        },
        "repository": {
            "type": "object",
            "properties": {
                "name": {
                    "type": "string",
                    "description": "The name of the repository"
                },
                "url": {
                    "type": "string",
                    "description": "The url of the repository",
                    "format": "uri"
                }
            }
        }
    }
}
