{
    "$schema": "http://json-schema.org/draft-07/schema#",
    "title": "Heroku app.json Schema",
    "description": "app.json is a manifest format for describing web apps. It declares environment variables, add-ons, and other information required to run an app on Heroku. Used for dynamic configurations or converted projects",
    "type": "object",
    "properties": {
        "name": {
            "type": "string",
            "pattern": "^[a-zA-Z-_\\.]+",
            "maxLength": 300
        },
        "description": {
            "type": "string"
        },
        "keywords": {
            "type": "array",
            "items": {
                "type": "string"
            }
        },
        "website": {
            "$ref": "#/definitions/uriString"
        },
        "repository": {
            "$ref": "#/definitions/uriString"
        },
        "logo": {
            "$ref": "#/definitions/uriString"
        },
        "success_url": {
            "type": "string"
        },
        "scripts": {
            "$ref": "#/definitions/scripts"
        },
        "env": {
            "$ref": "#/definitions/env"
        },
        "formation": {
            "$ref": "#/definitions/formation"
        },
        "addons": {
            "$ref": "#/definitions/addons"
        },
        "buildpacks": {
            "$ref": "#/definitions/buildpacks"
        },
        "environments": {
            "$ref": "#/definitions/environments"
        },
        "stack": {
            "$ref": "#/definitions/stack"
        },
        "image": {
            "type": "string"
        }
    },
    "additionalProperties": false,
    "definitions": {
        "uriString": {
            "type": "string",
            "format": "uri"
        },
        "scripts": {
            "type": "object",
            "properties": {
                "postdeploy": {
                    "type": "string"
                },
                "pr-predestroy": {
                    "type": "string"
                }
            },
            "additionalProperties": false
        },
        "env": {
            "type": "object",
            "patternProperties": {
                "^[A-Z][A-Z0-9_]*$": {
                    "type": "object",
                    "properties": {
                        "description": {
                            "type": "string"
                        },
                        "value": {
                            "type": "string"
                        },
                        "required": {
                            "type": "boolean"
                        },
                        "generator": {
                            "type": "string",
                            "enum": ["secret"]
                        }
                    },
                    "additionalProperties": false
                }
            }
        },
        "dynoSize": {
            "type": "string",
            "enum": [
                "free",
                "eco",
                "hobby",
                "basic",
                "standard-1x",
                "standard-2x",
                "performance-m",
                "performance-l",
                "private-s",
                "private-m",
                "private-l",
                "shield-s",
                "shield-m",
                "shield-l"
            ]
        },
        "formation": {
            "type": "object",
            "patternProperties": {
                "^[a-zA-Z0-9_-]+$": {
                    "type": "object",
                    "properties": {
                        "quantity": {
                            "type": "integer",
                            "minimum": 0
                        },
                        "size": {
                            "$ref": "#/definitions/dynoSize"
                        }
                    },
                    "required": ["quantity"],
                    "additionalProperties": false
                }
            }
        },
        "addons": {
            "type": "array",
            "items": {
                "oneOf": [
                    {
                        "type": "string"
                    },
                    {
                        "type": "object",
                        "properties": {
                            "plan": {
                                "type": "string"
                            },
                            "as": {
                                "type": "string"
                            },
                            "options": {
                                "type": "object"
                            }
                        },
                        "required": ["plan"],
                        "additionalProperties": false
                    }
                ]
            }
        },
        "buildpacks": {
            "type": "array",
            "items": {
                "type": "object",
                "properties": {
                    "url": {
                        "type": "string"
                    }
                },
                "required": ["url"],
                "additionalProperties": false
            }
        },
        "environmentConfig": {
            "type": "object",
            "properties": {
                "env": {
                    "type": "object"
                },
                "formation": {
                    "type": "object"
                },
                "addons": {
                    "type": "array"
                },
                "buildpacks": {
                    "type": "array"
                }
            }
        },
        "environments": {
            "type": "object",
            "properties": {
                "test": {
                    "allOf": [
                        {
                            "$ref": "#/definitions/environmentConfig"
                        },
                        {
                            "type": "object",
                            "properties": {
                                "scripts": {
                                    "type": "object",
                                    "properties": {
                                        "test": {
                                            "type": "string"
                                        }
                                    },
                                    "additionalProperties": false
                                }
                            }
                        }
                    ]
                },
                "review": {
                    "$ref": "#/definitions/environmentConfig"
                },
                "production": {
                    "$ref": "#/definitions/environmentConfig"
                }
            },
            "additionalProperties": false
        },
        "stack": {
            "type": "string",
            "enum": ["heroku-18", "heroku-20", "heroku-22", "heroku-24"]
        }
    }
}
