{
  "openapi": "3.1.0",
  "info": {
    "title": "MTS Public API",
    "version": "1.0.0",
    "description": "Read-only public data for the MTS live show, episode archive, guests, schedule, and situations briefing."
  },
  "servers": [
    {
      "url": "https://api.mts.now",
      "description": "Production"
    }
  ],
  "paths": {
    "/config": {
      "get": {
        "operationId": "getLiveStatus",
        "summary": "Get current MTS live status and site configuration",
        "responses": {
          "200": {
            "description": "Current live status",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SiteConfig"
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Problem"
          }
        }
      }
    },
    "/episodes": {
      "get": {
        "operationId": "listEpisodes",
        "summary": "List public episodes in archive order",
        "responses": {
          "200": {
            "description": "Episode archive",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["episodes"],
                  "properties": {
                    "episodes": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Episode"
                      }
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Problem"
          }
        }
      }
    },
    "/episodes/latest": {
      "get": {
        "operationId": "getLatestEpisode",
        "summary": "Get the most recently aired episode",
        "responses": {
          "200": {
            "description": "Latest episode, or null when the archive is empty",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["episode"],
                  "properties": {
                    "episode": {
                      "oneOf": [
                        {
                          "$ref": "#/components/schemas/Episode"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Problem"
          }
        }
      }
    },
    "/episodes/{number}": {
      "get": {
        "operationId": "getEpisode",
        "summary": "Get one episode by episode number",
        "parameters": [
          {
            "name": "number",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Episode details",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["episode"],
                  "properties": {
                    "episode": {
                      "$ref": "#/components/schemas/Episode"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/responses/Problem"
          }
        }
      }
    },
    "/guests": {
      "get": {
        "operationId": "listGuests",
        "summary": "List public MTS guests",
        "responses": {
          "200": {
            "description": "Guest directory",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["guests"],
                  "properties": {
                    "guests": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Guest"
                      }
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Problem"
          }
        }
      }
    },
    "/guests/{handle}": {
      "get": {
        "operationId": "getGuest",
        "summary": "Get a public guest profile by X handle",
        "parameters": [
          {
            "name": "handle",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Guest profile",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["guest"],
                  "properties": {
                    "guest": {
                      "$ref": "#/components/schemas/Guest"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/responses/Problem"
          }
        }
      }
    },
    "/schedule": {
      "get": {
        "operationId": "getSchedule",
        "summary": "Get the current MTS broadcast schedule",
        "responses": {
          "200": {
            "description": "Current schedule",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["date", "events"],
                  "properties": {
                    "date": {
                      "type": "string",
                      "format": "date"
                    },
                    "events": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/ScheduleEvent"
                      }
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Problem"
          }
        }
      }
    },
    "/situations": {
      "get": {
        "operationId": "getSituations",
        "summary": "Get the current public situations briefing",
        "responses": {
          "200": {
            "description": "Current situations data",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Problem"
          }
        }
      }
    }
  },
  "components": {
    "responses": {
      "Problem": {
        "description": "Machine-readable error",
        "content": {
          "application/problem+json": {
            "schema": {
              "$ref": "#/components/schemas/Problem"
            }
          }
        }
      }
    },
    "schemas": {
      "Problem": {
        "type": "object",
        "required": ["type", "title", "status", "detail", "code"],
        "properties": {
          "type": {
            "type": "string",
            "format": "uri-reference"
          },
          "title": {
            "type": "string"
          },
          "status": {
            "type": "integer",
            "minimum": 400,
            "maximum": 599
          },
          "detail": {
            "type": "string"
          },
          "code": {
            "type": "string"
          },
          "resolution": {
            "type": "string"
          }
        }
      },
      "SiteConfig": {
        "type": "object",
        "required": ["isLive", "broadcastId", "hosts", "ticker", "version"],
        "properties": {
          "isLive": {
            "type": "boolean"
          },
          "broadcastId": {
            "type": "string"
          },
          "episode": {
            "type": ["integer", "null"]
          },
          "nextShowAt": {
            "type": "string",
            "format": "date-time"
          },
          "hosts": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": true
            }
          },
          "ticker": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": true
            }
          },
          "version": {
            "type": "integer"
          }
        },
        "additionalProperties": true
      },
      "Episode": {
        "type": "object",
        "required": ["n", "title", "airedAt", "guests", "chapters"],
        "properties": {
          "n": {
            "type": "integer"
          },
          "title": {
            "type": "string"
          },
          "airedAt": {
            "type": "string",
            "format": "date-time"
          },
          "description": {
            "type": ["string", "null"]
          },
          "xUrl": {
            "type": ["string", "null"],
            "format": "uri"
          },
          "youtubeUrl": {
            "type": ["string", "null"],
            "format": "uri"
          },
          "guests": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": true
            }
          },
          "chapters": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": true
            }
          }
        },
        "additionalProperties": true
      },
      "Guest": {
        "type": "object",
        "required": ["xUserId", "handle", "name"],
        "properties": {
          "xUserId": {
            "type": "string"
          },
          "handle": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "bio": {
            "type": ["string", "null"]
          },
          "avatarUrl": {
            "type": ["string", "null"],
            "format": "uri"
          },
          "verified": {
            "type": "boolean"
          }
        },
        "additionalProperties": true
      },
      "ScheduleEvent": {
        "type": "object",
        "required": ["id", "summary", "startAt", "endAt", "kind", "guests"],
        "properties": {
          "id": {
            "type": "string"
          },
          "summary": {
            "type": "string"
          },
          "startAt": {
            "type": "string",
            "format": "date-time"
          },
          "endAt": {
            "type": "string",
            "format": "date-time"
          },
          "kind": {
            "type": "string"
          },
          "guests": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": true
            }
          }
        }
      }
    }
  }
}
