{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/predixsport-com/json-schema/predixsport-com-fantacalcio-recommendation-schema.json",
  "title": "FantacalcioRecommendation",
  "x-generated": "2026-11-21",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/predixsport-com-openapi.json#/components/schemas/FantacalcioRecommendation",
  "properties": {
    "snapshot_id": {
      "type": "integer",
      "title": "Snapshot Id"
    },
    "season": {
      "type": "string",
      "title": "Season"
    },
    "team": {
      "type": "integer",
      "title": "Team"
    },
    "giornata": {
      "type": "integer",
      "title": "Giornata"
    },
    "created_at": {
      "type": "string",
      "format": "date-time",
      "title": "Created At"
    },
    "applied_at": {
      "anyOf": [
        {
          "type": "string",
          "format": "date-time"
        },
        {
          "type": "null"
        }
      ],
      "title": "Applied At"
    },
    "stale": {
      "type": "boolean",
      "title": "Stale",
      "description": "True when the squad or the board moved after this advice was computed. Run the optimiser again rather than acting on it.",
      "default": false
    },
    "policy_version": {
      "type": "string",
      "title": "Policy Version"
    },
    "vote_probability": {
      "type": "boolean",
      "title": "Vote Probability",
      "description": "True when this advice priced every player on his chance of getting a vote, starting or off the bench (policy_version fantacalcio-lineup-v5 and later): each player then carries p_vote and x_vote and his selection_score is their product. False on every older snapshot, where selection_score is projected_fantavoto times p_start. Every printed probability (p_start) and settlement on the real votes stay the same. The minimum a starter needs reads the chance of starting up to fantacalcio-lineup-v5 and the chance of a vote from fantacalcio-lineup-v6 (11 Nov 2026).",
      "default": false
    },
    "module": {
      "type": "string",
      "title": "Module"
    },
    "starters": {
      "items": {
        "type": "string"
      },
      "type": "array",
      "maxItems": 11,
      "minItems": 11,
      "title": "Starters"
    },
    "bench_order": {
      "items": {
        "type": "string"
      },
      "type": "array",
      "title": "Bench Order"
    },
    "selection_total": {
      "type": "number",
      "title": "Selection Total",
      "description": "The optimiser's own objective. Since policy_version fantacalcio-lineup-v3 it is the expected score of this eleven AND its bench under your league's substitution rule: a starter who does not play is replaced from the bench the way the league's substitution_mode says (same role only, or a module change when no same-role reserve has a vote), while your league's substitution limit lasts, plus the defence modifier weighted by the chance it is paid. Older snapshots (v2 and earlier) carry the plain sum of selection scores, which ignored substitutions."
    },
    "expected_substitutions": {
      "type": "number",
      "minimum": 0.0,
      "title": "Expected Substitutions",
      "description": "How many substitutions the league's rule is expected to make for this lineup. 0 on snapshots older than fantacalcio-lineup-v3.",
      "default": 0.0
    },
    "hole_probability": {
      "type": "number",
      "maximum": 1.0,
      "minimum": 0.0,
      "title": "Hole Probability",
      "description": "Probability of NOT fielding eleven voted players: at least one slot stays without a vote after every substitution the league's substitution_mode allows, because no eligible reserve is left on the bench or the substitution limit is spent. Since fantacalcio-lineup-v4 it follows the league's mode (a module change can fill a slot the same-role rule could not). 0 on snapshots older than fantacalcio-lineup-v3.",
      "default": 0.0
    },
    "substitution_mode": {
      "type": "string",
      "enum": [
        "traditional",
        "hybrid",
        "dynamic"
      ],
      "title": "Substitution Mode",
      "description": "The substitution rule this advice was priced under, echoed from the league rules at the time. Snapshots older than fantacalcio-lineup-v4 report 'traditional', the same-role walk they were computed with.",
      "default": "traditional"
    },
    "projected_points": {
      "type": "number",
      "title": "Projected Points",
      "description": "What this eleven is worth if everybody in it plays: the starters' projected fantavoti plus the expected defence modifier. This is the number to show a reader."
    },
    "expected_defence": {
      "type": "number",
      "title": "Expected Defence",
      "description": "The defence modifier in points. Always shown separately."
    },
    "players": {
      "additionalProperties": {
        "$ref": "#/$defs/FantacalcioPlayerAdvice"
      },
      "type": "object",
      "title": "Players"
    },
    "ballottaggi": {
      "items": {
        "$ref": "#/$defs/FantacalcioBallottaggio"
      },
      "type": "array",
      "title": "Ballottaggi"
    },
    "what_if": {
      "items": {
        "$ref": "#/$defs/FantacalcioWhatIf"
      },
      "type": "array",
      "title": "What If"
    },
    "modules": {
      "items": {
        "$ref": "#/$defs/FantacalcioModuleOption"
      },
      "type": "array",
      "title": "Modules"
    },
    "player_count": {
      "type": "integer",
      "minimum": 0.0,
      "title": "Player Count"
    },
    "omitted_player_count": {
      "type": "integer",
      "minimum": 0.0,
      "title": "Omitted Player Count",
      "default": 0
    }
  },
  "additionalProperties": false,
  "type": "object",
  "required": [
    "snapshot_id",
    "season",
    "team",
    "giornata",
    "created_at",
    "policy_version",
    "module",
    "starters",
    "bench_order",
    "selection_total",
    "projected_points",
    "expected_defence",
    "players",
    "player_count"
  ],
  "$defs": {
    "FantacalcioBallottaggio": {
      "properties": {
        "role": {
          "type": "string",
          "enum": [
            "P",
            "D",
            "C",
            "A"
          ],
          "title": "Role"
        },
        "last_in": {
          "type": "string",
          "title": "Last In"
        },
        "first_out": {
          "type": "string",
          "title": "First Out"
        },
        "gap": {
          "type": "number",
          "title": "Gap"
        }
      },
      "additionalProperties": false,
      "type": "object",
      "required": [
        "role",
        "last_in",
        "first_out",
        "gap"
      ],
      "title": "FantacalcioBallottaggio",
      "description": "The closest call in one role: last man in against first man out."
    },
    "FantacalcioModuleOption": {
      "properties": {
        "module": {
          "type": "string",
          "title": "Module"
        },
        "expected_points": {
          "type": "number",
          "title": "Expected Points"
        },
        "expected_defence": {
          "type": "number",
          "title": "Expected Defence"
        }
      },
      "additionalProperties": false,
      "type": "object",
      "required": [
        "module",
        "expected_points",
        "expected_defence"
      ],
      "title": "FantacalcioModuleOption"
    },
    "FantacalcioPlayerAdvice": {
      "properties": {
        "player_code": {
          "type": "string",
          "title": "Player Code"
        },
        "name": {
          "type": "string",
          "title": "Name"
        },
        "role": {
          "type": "string",
          "enum": [
            "P",
            "D",
            "C",
            "A"
          ],
          "title": "Role"
        },
        "club": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Club"
        },
        "club_name": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Club Name"
        },
        "opponent": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Opponent"
        },
        "opponent_name": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Opponent Name"
        },
        "is_home": {
          "anyOf": [
            {
              "type": "boolean"
            },
            {
              "type": "null"
            }
          ],
          "title": "Is Home"
        },
        "kickoff_utc": {
          "anyOf": [
            {
              "type": "string",
              "format": "date-time"
            },
            {
              "type": "null"
            }
          ],
          "title": "Kickoff Utc"
        },
        "p_start": {
          "type": "number",
          "maximum": 1.0,
          "minimum": 0.0,
          "title": "P Start",
          "description": "Pooled probability that he is in the XI. This is the probability to print beside a player, under every policy_version."
        },
        "projected_fantavoto": {
          "type": "number",
          "title": "Projected Fantavoto",
          "description": "His expected fantavoto IF he plays."
        },
        "selection_score": {
          "type": "number",
          "title": "Selection Score",
          "description": "The number the optimiser ranked him on. When the recommendation's vote_probability is false (every snapshot before fantacalcio-lineup-v5) it is projected_fantavoto times p_start. When it is true it is x_vote times p_vote: his chance of getting a vote, starting or off the bench, times the fantavoto that goes with it. Bench order follows it inside each role. The eleven itself is chosen on the lineup's expected score with substitutions (selection_total), so a better player with a real chance of starting can start over a surer one when the bench covers him. Never the score to quote a reader."
        },
        "p_vote": {
          "anyOf": [
            {
              "type": "number",
              "maximum": 1.0,
              "minimum": 0.0
            },
            {
              "type": "null"
            }
          ],
          "title": "P Vote",
          "description": "Only when the recommendation's vote_probability is true: the chance he gets a vote (rated), starting or coming on from the bench, that the optimiser priced him on. It is p_start plus (1 - p_start) times p_vote_sub, and equals p_start for a player forced in or out, reported unavailable, or with no p_vote_sub. Null on every other snapshot. p_start stays the probability to print."
        },
        "x_vote": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "title": "X Vote",
          "description": "Only when the recommendation's vote_probability is true: the fantavoto the optimiser priced him at alongside p_vote. It equals projected_fantavoto for keepers and defenders and sits slightly below it for a midfielder or forward, the more so the larger the share of his vote expected off the bench, because a vote earned off the bench is worth a little less. selection_score is x_vote times p_vote. Null on every other snapshot."
        },
        "p_vote_sub": {
          "anyOf": [
            {
              "type": "number",
              "maximum": 1.0,
              "minimum": 0.0
            },
            {
              "type": "null"
            }
          ],
          "title": "P Vote Sub",
          "description": "The matchweek's probability that he gets a vote if he does NOT start, from coming on off the bench. 0 for a player reported unavailable. It feeds p_vote only when the recommendation's vote_probability is true. Null when the matchweek's projections carried no such figure, which is every snapshot saved before October 2026."
        },
        "expected_vote": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "title": "Expected Vote"
        },
        "expected_goals": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "title": "Expected Goals"
        },
        "expected_assists": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "title": "Expected Assists"
        },
        "expected_conceded": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "title": "Expected Conceded",
          "description": "Goalkeepers only."
        },
        "clean_sheet_expected": {
          "type": "number",
          "title": "Clean Sheet Expected",
          "description": "Expected porta imbattuta if he is fielded: the league's clean sheet bonus times the probability his team concedes nothing. 0 for every outfield player and for every league that does not pay the bonus. It is printed beside projected_fantavoto, never inside it: a team bonus is not part of a player's own fantavoto.",
          "default": 0.0
        },
        "opponent_effect": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "title": "Opponent Effect",
          "description": "How much this fixture is worth to him against a league-median opponent. Positive is a friendlier fixture."
        },
        "unavailable": {
          "type": "boolean",
          "title": "Unavailable",
          "default": false
        },
        "availability_status": {
          "anyOf": [
            {
              "type": "string",
              "enum": [
                "reported_unavailable",
                "no_probable_lineup_published"
              ]
            },
            {
              "type": "null"
            }
          ],
          "title": "Availability Status",
          "description": "The only two availability states published. There is no count of lineup sources anywhere in this response."
        },
        "value_source": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Value Source",
          "description": "model, prior_season or role_prior."
        },
        "on_board": {
          "type": "boolean",
          "title": "On Board",
          "description": "False for an owned player this matchweek carries no projection for. He can only be advised onto the bench.",
          "default": true
        },
        "forced": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Forced",
          "description": "Set when you asked for him in or out."
        },
        "out_reason": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Out Reason",
          "description": "Why a player is on the bench: titolarita (lower chance of starting), qualita (lower projection), titolarita_e_qualita, escluso (left out on request), ruolo non schierato, or copertura: his selection score beats a starter of his position, who starts because a reserve like him comes on if that starter gets no vote (see covers). Snapshots before 10 October 2026 may say modificatore for the same case."
        },
        "covers": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Covers",
          "description": "With out_reason copertura: the player code of the starter of his position he is on the bench to cover."
        }
      },
      "additionalProperties": false,
      "type": "object",
      "required": [
        "player_code",
        "name",
        "role",
        "p_start",
        "projected_fantavoto",
        "selection_score"
      ],
      "title": "FantacalcioPlayerAdvice",
      "description": "One player inside a recommendation."
    },
    "FantacalcioWhatIf": {
      "properties": {
        "player_code": {
          "type": "string",
          "title": "Player Code"
        },
        "replaces": {
          "items": {
            "type": "string"
          },
          "type": "array",
          "title": "Replaces"
        },
        "gain": {
          "type": "number",
          "title": "Gain"
        }
      },
      "additionalProperties": false,
      "type": "object",
      "required": [
        "player_code",
        "replaces",
        "gain"
      ],
      "title": "FantacalcioWhatIf",
      "description": "What changes if a doubtful bench player were confirmed to start."
    }
  }
}