{
    "$schema": "http://json-schema.org/draft-07/schema#",
    "$id": "https://mcda.drugis.org/dataSource.json#",
    "title": "MCDA problem schema",
    "description": "MCDA dataSource schema for uploaded JSON",
    "type": "object",
    "required": [
        "id",
        "unitOfMeasurement",
        "scale"
    ],
    "additionalProperties": false,
    "properties": {
        "id": {
            "description": "identifier of the data source",
            "type": "string"
        },
        "unitOfMeasurement": {
            "type": "object",
            "required": [
                "type",
                "label"
            ],
            "additionalProperties": false,
            "properties": {
                "type": {
                    "type": "string",
                    "enum": [
                        "custom",
                        "percentage",
                        "decimal"
                    ]
                },
                "label": {
                    "type": "string"
                }
            }
        },
        "source": {
            "description": "Where the data comes from",
            "type": "string"
        },
        "sourceLink": {
            "description": "Link to the source",
            "type": "string"
        },
        "strengthOfEvidence": {
            "description": "Strengths of the data",
            "type": "string"
        },
        "uncertainties": {
            "description": "Uncertainties about the data",
            "type": "string"
        },
        "scale": {
            "description": "The minimum and maximum values the data can have",
            "type": "array",
            "minItems": 2,
            "maxItems": 2,
            "items": {
                "oneOf": [
                    {
                        "type": "number"
                    },
                    {
                        "type": "null"
                    }
                ]
            }
        },
        "pvf": {
            "oneOf": [
                {
                    "description": "The partial value function",
                    "type": "object",
                    "required": [
                        "direction",
                        "type",
                        "range"
                    ],
                    "additionalProperties": false,
                    "properties": {
                        "direction": {
                            "type": "string",
                            "enum": [
                                "increasing",
                                "decreasing"
                            ]
                        },
                        "type": {
                            "type": "string",
                            "enum": [
                                "linear",
                                "piecewise-linear"
                            ]
                        },
                        "range": {
                            "type": "array",
                            "minItems": 2,
                            "maxItems": 2,
                            "items": {
                                "type": "number"
                            }
                        },
                        "values": {
                            "type": "array",
                            "minItems": 3,
                            "maxItems": 3,
                            "items": {
                                "type": "number"
                            }
                        },
                        "cutoffs": {
                            "type": "array",
                            "minItems": 3,
                            "maxItems": 3,
                            "items": {
                                "type": "number"
                            }
                        }
                    }
                },
                {
                    "type": "null"
                }
            ]
        }
    }
}