{
    "$schema": "http://json-schema.org/draft-07/schema#",
    "$comment": "v0.1.0",
    "title": "Pipeline Schema",
    "description": "A dvc.yaml pipeline definition",
    "type": "object",
    "definitions": {
        "OutputFlags": {
            "type": "object",
            "description": "Output file with more flags",
            "properties": {
                "cache": {
                    "description": "Cache outputs by dvc",
                    "type": "boolean",
                    "default": true
                },
                "persist": {
                    "description": "Persist outputs among runs",
                    "type": "boolean",
                    "default": false
                }
            }
        },
        "PlotFlags": {
            "description": "Plots file with more flags",
            "allOf": [
                {
                    "$ref": "#/definitions/OutputFlags"
                }
            ],
            "$comment": "Unfortunately, 'additionalProperties' only works props in immediate schema.",
            "properties": {
                "cache": {},
                "persist": {},
                "x": {
                    "description": "Default field name to use as x-axis data",
                    "type": [
                        "string",
                        "integer"
                    ]
                },
                "y": {
                    "description": "Default field name to use as y-axis data",
                    "type": [
                        "string",
                        "integer"
                    ]
                },
                "x_label": {
                    "description": "Default label for the x-axis",
                    "type": "string"
                },
                "y_label": {
                    "description": "Default label for the y-axis",
                    "type": "string"
                },
                "template": {
                    "description": "Default plot template",
                    "type": "string"
                },
                "title": {
                    "description": "Default plot title",
                    "type": "string"
                },
                "header": {
                    "description": "The target CSV or TSV has a header",
                    "type": "boolean",
                    "default": false
                }
            },
            "additionalProperties": false
        },
        "Output": {
            "description": "An output of the stage",
            "anyOf": [
                {
                    "type": "string",
                    "description": "Output will be cached by dvc"
                },
                {
                    "type": "object",
                    "description": "Output file",
                    "patternProperties": {
                        "^.*$": {
                            "$ref": "#/definitions/OutputFlags",
                            "additionalProperties": false
                        }
                    },
                    "additionalProperties": false,
                    "maxProperties": 1
                }
            ]
        }
    },
    "properties": {
        "stages": {
            "description": "List of stages.",
            "type": "object",
            "patternProperties": {
                "^[A-Za-z0-9_-]+$": {
                    "description": "The stage",
                    "type": "object",
                    "properties": {
                        "cmd": {
                            "type": "string",
                            "description": "Command to run"
                        },
                        "wdir": {
                            "type": "string",
                            "description": "Working directory"
                        },
                        "deps": {
                            "type": "array",
                            "description": "Dependencies for the stage",
                            "items": {
                                "type": "string",
                                "description": "A dependency for the stage"
                            },
                            "minItems": 1,
                            "_uniqueItems": true
                        },
                        "params": {
                            "type": "array",
                            "description": "Params for the stage",
                            "items": {
                                "anyOf": [
                                    {
                                        "type": "string",
                                        "description": "Params from default params file"
                                    },
                                    {
                                        "type": "object",
                                        "description": "Params from custom params file",
                                        "patternProperties": {
                                            "^.*$": {
                                                "type": "array",
                                                "description": "Custom params file",
                                                "items": {
                                                    "type": "string",
                                                    "description": "Params from custom file"
                                                },
                                                "minItems": 1,
                                                "_uniqueItems": true
                                            }
                                        },
                                        "additionalProperties": false,
                                        "maxProperties": 1
                                    }
                                ]
                            },
                            "minItems": 1,
                            "_uniqueItems": true
                        },
                        "outs": {
                            "type": "array",
                            "description": "Outputs of the stage",
                            "items": {
                                "$ref": "#/definitions/Output"
                            },
                            "minItems": 1,
                            "_uniqueItems": true
                        },
                        "metrics": {
                            "type": "array",
                            "description": "Metrics outputs of the stage",
                            "items": {
                                "$ref": "#/definitions/Output"
                            },
                            "minItems": 1,
                            "_uniqueItems": true
                        },
                        "plots": {
                            "type": "array",
                            "description": "Plots outputs of the stage",
                            "items": {
                                "anyOf": [
                                    {
                                        "type": "string",
                                        "description": "Plots will be cached by dvc"
                                    },
                                    {
                                        "type": "object",
                                        "description": "Output file",
                                        "patternProperties": {
                                            "^.*$": {
                                                "$ref": "#/definitions/PlotFlags"
                                            }
                                        },
                                        "maxProperties": 1
                                    }
                                ]
                            },
                            "minItems": 1,
                            "_uniqueItems": true
                        },
                        "frozen": {
                            "type": "boolean",
                            "description": "Assume stage as unchanged",
                            "default": false
                        },
                        "locked": {
                            "type": "boolean",
                            "description": "Assume stage as unchanged (deprecated)",
                            "default": false
                        },
                        "always_changed": {
                            "type": "boolean",
                            "description": "Assume stage as always changed.",
                            "default": false
                        },
                        "meta": {
                            "description": "Additional information/metadata"
                        }
                    },
                    "additionalProperties": false,
                    "required": [
                        "cmd"
                    ]
                }
            },
            "additionalProperties": false
        }
    },
    "required": [
        "stages"
    ]
}