{
    "$schema": "http://json-schema.org/draft-04/schema#",
    "title": "Plurality Election",
    "description": "A single plurality 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"
                    },
                    "selection": {
                        "description": "The candidate selected on this ballot",
                        "type": "integer"
                    }
                },
                "required": [
                    "id",
                    "selection"
                ],
                "additionalProperties": false
            }
        },
        "tiebreak": {
            "description": "the candidate that should be chosen in the event of a tie",
            "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"
                },
                "tabulation": {
                    "type": "array",
                    "items": {
                        "type": "object",
                        "properties": {
                            "candidate": {
                                "type": "integer"
                            },
                            "votes": {
                                "type": "integer"
                            }
                        },
                        "required": [
                            "candidate",
                            "votes"
                        ],
                        "additionalProperties": false
                    }
                }
            },
            "required": [
                "winner"
            ],
            "additionalProperties": false
        }
    },
    "additionalProperties": false,
    "dependencies": {
        "isTest": [
            "results",
            "tiebreak",
            "counts"
        ]
    }
}