{
  "openapi": "3.1.0",
  "info": {
    "title": "LA divadlo – otevřená data",
    "version": "1.0.0",
    "description": "Veřejný program zájezdového LA divadla: termíny představení v JSON a iCalendar. Jen pro čtení, bez autentizace.",
    "contact": {
      "name": "LA divadlo",
      "url": "https://ladivadlo.cz/kontakt/"
    }
  },
  "servers": [
    {
      "url": "https://ladivadlo.cz"
    }
  ],
  "externalDocs": {
    "description": "Dokumentace",
    "url": "https://ladivadlo.cz/otevrena-data/"
  },
  "paths": {
    "/program.json": {
      "get": {
        "operationId": "getProgram",
        "summary": "Nadcházející představení",
        "description": "Seznam budoucích termínů seřazený podle data. Aktualizuje se každou noc a při každé změně programu.",
        "responses": {
          "200": {
            "description": "Program",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Program"
                }
              }
            }
          }
        }
      }
    },
    "/program.ics": {
      "get": {
        "operationId": "getProgramCalendar",
        "summary": "Celý program jako kalendář (iCalendar, RFC 5545)",
        "responses": {
          "200": {
            "description": "Kalendář",
            "content": {
              "text/calendar": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        }
      }
    },
    "/program/{slug}.ics": {
      "get": {
        "operationId": "getEventCalendar",
        "summary": "Jeden termín jako kalendářová událost",
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Hodnota z pole `ics` v /program.json"
          }
        ],
        "responses": {
          "200": {
            "description": "Událost",
            "content": {
              "text/calendar": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "404": {
            "description": "Termín neexistuje"
          }
        }
      }
    },
    "/api/health": {
      "get": {
        "operationId": "getHealth",
        "summary": "Stav služby",
        "responses": {
          "200": {
            "description": "Služba běží",
            "content": {
              "application/health+json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string",
                      "enum": [
                        "pass"
                      ]
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Program": {
        "type": "object",
        "required": [
          "generated",
          "events"
        ],
        "properties": {
          "generated": {
            "type": "string",
            "format": "date-time"
          },
          "events": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Event"
            }
          }
        }
      },
      "Event": {
        "type": "object",
        "required": [
          "id",
          "url",
          "start",
          "end",
          "status",
          "show",
          "venue"
        ],
        "properties": {
          "id": {
            "type": "integer"
          },
          "url": {
            "type": "string",
            "format": "uri"
          },
          "ics": {
            "type": "string",
            "format": "uri"
          },
          "start": {
            "type": "string",
            "format": "date-time"
          },
          "end": {
            "type": "string",
            "format": "date-time"
          },
          "status": {
            "type": "string",
            "enum": [
              "prodej",
              "vyprodano",
              "zruseno",
              "presunuto"
            ],
            "description": "prodej = v prodeji, vyprodano = vyprodáno, zruseno = zrušeno, presunuto = přesunuto"
          },
          "premiere": {
            "type": "boolean"
          },
          "derniere": {
            "type": "boolean"
          },
          "note": {
            "type": [
              "string",
              "null"
            ]
          },
          "ticketsUrl": {
            "type": [
              "string",
              "null"
            ],
            "format": "uri",
            "description": "Prodej vstupenek u pořadatele"
          },
          "show": {
            "type": "object",
            "properties": {
              "slug": {
                "type": "string"
              },
              "title": {
                "type": "string"
              },
              "url": {
                "type": "string",
                "format": "uri"
              },
              "durationMin": {
                "type": [
                  "integer",
                  "null"
                ]
              },
              "ageFrom": {
                "type": [
                  "integer",
                  "null"
                ]
              }
            }
          },
          "venue": {
            "type": "object",
            "properties": {
              "name": {
                "type": "string"
              },
              "address": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "city": {
                "type": "string"
              },
              "region": {
                "type": "string"
              },
              "regionName": {
                "type": "string"
              },
              "lat": {
                "type": [
                  "number",
                  "null"
                ]
              },
              "lng": {
                "type": [
                  "number",
                  "null"
                ]
              }
            }
          }
        }
      }
    }
  }
}