{
    "$schema": "http://json-schema.org/draft-04/schema#",
    "title": "RCV Election",
    "description": "A single Ranked Choice Voting (RCV) race",
    "type": "object",
    "properties": {
        "isTest": {
            "description": "Value that is always true if it exists, could later be used to specify some useful info about the test",
            "type": "boolean",
            "enum": [
                true
            ]
        },
        "counts": {
            "description": "In a test, this array specifies how many of each of the ballots in votes will appear. Can be used for a compressed form of tests",
            "type": "array",
            "items": {
                "type": "integer"
            }
        },
        "votes": {
            "description": "all of the votes in the election",
            "type": "array",
            "items": {
                "type": "object",
                "properties": {
                    "id": {
                        "description": "A unique identifier for each ballot",
                        "type": "integer"
                    },
                    "ranks": {
                        "description": "The rankings on this ballot, ordered from first to last within the list",
                        "type": "array",
                        "items": {
                            "description": "A rank selection. Is an array because it allows overvotes",
                            "type": "array",
                            "items": {
                                "type": "integer"
                            }
                        }
                    }
                },
                "required": [
                    "id",
                    "ranks"
                ],
                "additionalProperties": false
            }
        },
        "tiebreak": {
            "description": "the candidate that should be chosen in each successive tiebreak to give the results as reported in the results value",
            "type": "array",
            "items": {
                "type": "integer"
            }
        },
        "results": {
            "description": "a record of what happened as the election was tabulated",
            "type": "object",
            "properties": {
                "winner": {
                    "description": "which candidate won the election",
                    "type": "integer"
                },
                "record": {
                    "description": "a round by round summary of the results of the election",
                    "type": "array",
                    "items": {
                        "type": "object",
                        "properties": {
                            "tally": {
                                "description": "the number of first choice selections for some/all of the candidates",
                                "type": "array",
                                "items": {
                                    "type": "object",
                                    "properties": {
                                        "candidate": {
                                            "type": "integer"
                                        },
                                        "firstChoices": {
                                            "type": "integer"
                                        }
                                    },
                                    "required": [
                                        "candidate",
                                        "firstChoices"
                                    ],
                                    "additionalProperties": false
                                }
                            },
                            "eliminated": {
                                "type": "array",
                                "items": {
                                    "type": "integer"
                                }
                            }
                        }
                    }
                }
            },
            "required": [
                "winner"
            ],
            "additionalProperties": false
        }
    },
    "additionalProperties": false,
    "dependencies": {
        "isTest": [
            "results",
            "tiebreak",
            "counts"
        ]
    }
}