{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/sweetsaverfare-com/json-schema/sweetsaverfare-com-best-fare-response-schema.json",
  "title": "BestFareResponse",
  "x-generated": "2026-11-25",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/_original/sweetsaverfare-com-api-openapi.json#/components/schemas/BestFareResponse",
  "allOf": [
    {
      "type": "object",
      "required": [
        "observation_id",
        "observed_at",
        "stale_after",
        "freshness_state",
        "source_status",
        "data_source",
        "parser_version",
        "observation_trace_id",
        "fixture_sha",
        "disclaimer"
      ],
      "properties": {
        "observation_id": {
          "type": [
            "string",
            "null"
          ],
          "format": "uuid"
        },
        "observed_at": {
          "type": "string",
          "format": "date-time"
        },
        "stale_after": {
          "type": "string",
          "format": "date-time"
        },
        "freshness_state": {
          "type": "string",
          "enum": [
            "fresh",
            "stale",
            "expired"
          ]
        },
        "source_status": {
          "type": "string",
          "enum": [
            "ok",
            "missing",
            "provider_queue_active",
            "session_expired",
            "blocked",
            "unknown"
          ]
        },
        "data_source": {
          "type": "string",
          "enum": [
            "demo",
            "fake_worker",
            "fixture",
            "live_provider",
            "schedule_reference"
          ]
        },
        "parser_version": {
          "type": "string"
        },
        "observation_trace_id": {
          "type": [
            "string",
            "null"
          ]
        },
        "fixture_sha": {
          "type": [
            "string",
            "null"
          ]
        },
        "observation_outcome": {
          "type": "string",
          "enum": [
            "verified",
            "partial",
            "unavailable",
            "failed"
          ]
        },
        "disclaimer": {
          "type": "string",
          "const": "Ferry fares can change. Confirm final availability and price directly with BC Ferries before making travel decisions."
        }
      }
    },
    {
      "type": "object",
      "required": [
        "route_id",
        "profile_id",
        "from",
        "to",
        "data_unavailable_dates",
        "data_unavailable_from",
        "reservation_horizon",
        "route_advisory",
        "best_fares"
      ],
      "properties": {
        "route_id": {
          "type": "string",
          "enum": [
            "TSA_SWB",
            "SWB_TSA",
            "TSA_DUK",
            "DUK_TSA",
            "TSA_NAN",
            "HSB_NAN",
            "NAN_HSB",
            "SWB_FUL",
            "FUL_SWB",
            "HSB_LNG",
            "LNG_HSB",
            "ERL_SLT",
            "SLT_ERL",
            "CMX_PWR",
            "PWR_CMX"
          ]
        },
        "profile_id": {
          "type": "string",
          "enum": [
            "ADULT_NO_VEHICLE",
            "ADULT_STANDARD_VEHICLE",
            "ADULT_OVERHEIGHT_VEHICLE"
          ]
        },
        "from": {
          "type": "string",
          "format": "date"
        },
        "to": {
          "type": "string",
          "format": "date"
        },
        "booking_closed_dates": {
          "type": "array",
          "items": {
            "type": "string",
            "format": "date"
          }
        },
        "data_unavailable_dates": {
          "type": "array",
          "items": {
            "type": "string",
            "format": "date"
          }
        },
        "data_unavailable_from": {
          "type": [
            "string",
            "null"
          ],
          "format": "date"
        },
        "reservation_horizon": {
          "anyOf": [
            {
              "$ref": "#/$defs/ReservationHorizon"
            },
            {
              "type": "null"
            }
          ]
        },
        "route_advisory": {
          "anyOf": [
            {
              "$ref": "#/$defs/RouteAdvisory"
            },
            {
              "type": "null"
            }
          ]
        },
        "best_fares": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/BestFareResult"
          }
        }
      }
    }
  ],
  "$defs": {
    "BestFareResult": {
      "type": "object",
      "required": [
        "travel_date",
        "departure_time",
        "reservation_state",
        "saver_fare_sailing_count",
        "total_sailing_count",
        "fare",
        "lowest_fare",
        "observed_at",
        "stale_after",
        "freshness_state",
        "source_status",
        "data_source",
        "observation_outcome",
        "outcome_reason"
      ],
      "properties": {
        "travel_date": {
          "type": "string",
          "format": "date"
        },
        "departure_time": {
          "type": "string"
        },
        "reservation_state": {
          "type": "string",
          "enum": [
            "BOOKABLE",
            "BOOKABLE_BUT_NO_SAVER",
            "NOT_RELEASED",
            "SOLD_OUT_OR_UNAVAILABLE",
            "NON_RESERVABLE",
            "UNKNOWN"
          ]
        },
        "saver_fare_sailing_count": {
          "type": "integer",
          "minimum": 0
        },
        "total_sailing_count": {
          "type": "integer",
          "minimum": 0
        },
        "fare": {
          "anyOf": [
            {
              "$ref": "#/$defs/FareOption"
            },
            {
              "type": "null"
            }
          ]
        },
        "lowest_fare": {
          "anyOf": [
            {
              "$ref": "#/$defs/FareOption"
            },
            {
              "type": "null"
            }
          ]
        },
        "observed_at": {
          "type": "string",
          "format": "date-time"
        },
        "stale_after": {
          "type": "string",
          "format": "date-time"
        },
        "freshness_state": {
          "type": "string",
          "enum": [
            "fresh",
            "stale",
            "expired"
          ]
        },
        "source_status": {
          "type": "string",
          "enum": [
            "ok",
            "missing",
            "provider_queue_active",
            "session_expired",
            "blocked",
            "unknown"
          ]
        },
        "data_source": {
          "type": "string",
          "enum": [
            "demo",
            "fake_worker",
            "fixture",
            "live_provider",
            "schedule_reference"
          ]
        },
        "observation_outcome": {
          "type": "string",
          "enum": [
            "verified",
            "partial",
            "unavailable",
            "failed"
          ]
        },
        "outcome_reason": {
          "type": [
            "string",
            "null"
          ]
        }
      }
    },
    "FareOption": {
      "allOf": [
        {
          "type": "object",
          "required": [
            "observation_id",
            "observed_at",
            "stale_after",
            "freshness_state",
            "source_status",
            "data_source",
            "parser_version",
            "observation_trace_id",
            "fixture_sha",
            "disclaimer"
          ],
          "properties": {
            "observation_id": {
              "type": [
                "string",
                "null"
              ],
              "format": "uuid"
            },
            "observed_at": {
              "type": "string",
              "format": "date-time"
            },
            "stale_after": {
              "type": "string",
              "format": "date-time"
            },
            "freshness_state": {
              "type": "string",
              "enum": [
                "fresh",
                "stale",
                "expired"
              ]
            },
            "source_status": {
              "type": "string",
              "enum": [
                "ok",
                "missing",
                "provider_queue_active",
                "session_expired",
                "blocked",
                "unknown"
              ]
            },
            "data_source": {
              "type": "string",
              "enum": [
                "demo",
                "fake_worker",
                "fixture",
                "live_provider",
                "schedule_reference"
              ]
            },
            "parser_version": {
              "type": "string"
            },
            "observation_trace_id": {
              "type": [
                "string",
                "null"
              ]
            },
            "fixture_sha": {
              "type": [
                "string",
                "null"
              ]
            },
            "observation_outcome": {
              "type": "string",
              "enum": [
                "verified",
                "partial",
                "unavailable",
                "failed"
              ]
            },
            "disclaimer": {
              "type": "string",
              "const": "Ferry fares can change. Confirm final availability and price directly with BC Ferries before making travel decisions."
            }
          }
        },
        {
          "type": "object",
          "required": [
            "fare_family",
            "price_cents",
            "currency",
            "available"
          ],
          "properties": {
            "fare_family": {
              "type": "string",
              "enum": [
                "SAVER",
                "PREPAID",
                "RESERVATION_ONLY",
                "STANDARD"
              ]
            },
            "price_cents": {
              "type": [
                "integer",
                "null"
              ],
              "minimum": 0
            },
            "currency": {
              "type": "string",
              "const": "CAD"
            },
            "available": {
              "type": "boolean"
            },
            "seats_remaining": {
              "type": [
                "integer",
                "null"
              ],
              "minimum": 0
            },
            "price_breakdown": {
              "type": "array",
              "items": {
                "type": "object",
                "required": [
                  "label",
                  "price_cents"
                ],
                "properties": {
                  "label": {
                    "type": "string"
                  },
                  "price_cents": {
                    "type": [
                      "integer",
                      "null"
                    ],
                    "minimum": 0
                  }
                }
              }
            }
          }
        }
      ]
    },
    "ReservationHorizon": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "not_open_from",
        "observed_at",
        "stale_after",
        "freshness_state",
        "source_status"
      ],
      "properties": {
        "not_open_from": {
          "type": "string",
          "format": "date"
        },
        "observed_at": {
          "type": "string",
          "format": "date-time"
        },
        "stale_after": {
          "type": "string",
          "format": "date-time"
        },
        "freshness_state": {
          "type": "string",
          "enum": [
            "fresh",
            "stale",
            "expired"
          ]
        },
        "source_status": {
          "type": "string",
          "enum": [
            "ok",
            "missing",
            "provider_queue_active",
            "session_expired",
            "blocked",
            "unknown"
          ]
        }
      }
    },
    "RouteAdvisory": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "message",
        "source_url",
        "reviewed_at"
      ],
      "properties": {
        "message": {
          "type": "string"
        },
        "source_url": {
          "type": "string",
          "format": "uri"
        },
        "reviewed_at": {
          "type": "string",
          "format": "date"
        }
      }
    }
  }
}