{
  "openapi": "3.1.1",
  "info": {
    "title": "SaunaWatch | v1",
    "version": "1.0.0"
  },
  "servers": [
    {
      "url": "http://zaparenyzlaby.dytrych.xyz/"
    }
  ],
  "paths": {
    "/api/v1/saunas": {
      "get": {
        "tags": [
          "Saunas"
        ],
        "summary": "Seznam všech saun",
        "description": "Vrátí přehled všech sledovaných saun s aktuální obsazeností a kapacitou.",
        "operationId": "GetAllSaunas",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SaunaApiListResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/saunas/{saunaId}": {
      "get": {
        "tags": [
          "Saunas"
        ],
        "summary": "Detail jedné sauny",
        "description": "Vrátí aktuální uloženou obsazenost vybrané sauny a otevírací dobu. Pokud je měření zastaralé, může zařadit obnovu na pozadí.",
        "operationId": "GetSauna",
        "parameters": [
          {
            "name": "saunaId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SaunaApiDetailResponse"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/widget/{saunaId}": {
      "get": {
        "tags": [
          "Saunas"
        ],
        "summary": "W12 formát pro API Widget",
        "description": "Vrátí pole řádků přizpůsobené pro aplikaci API Widget na Androidu.",
        "operationId": "GetWidgetData",
        "parameters": [
          {
            "name": "saunaId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "fields",
            "in": "query",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/WidgetApiRow"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/saunas/{saunaId}/history": {
      "get": {
        "tags": [
          "Saunas"
        ],
        "summary": "Historie obsazenosti za vybraný den",
        "description": "Vrátí průběh vybraného dne po půlhodinových slotech a denní průměry.",
        "operationId": "GetSaunaHistory",
        "parameters": [
          {
            "name": "saunaId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "date",
            "in": "query",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SaunaDayStats"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/saunas/{saunaId}/stats": {
      "get": {
        "tags": [
          "Saunas"
        ],
        "summary": "Dlouhodobé statistiky sauny",
        "description": "Vrátí dlouhodobé statistiky podle dne v týdnu a času, měsíční průměry a historii průměrů.",
        "operationId": "GetSaunaStats",
        "parameters": [
          {
            "name": "saunaId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "days",
            "in": "query",
            "schema": {
              "pattern": "^-?(?:0|[1-9]\\d*)$",
              "type": [
                "integer",
                "string"
              ],
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SaunaStatsResponse"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/saunas/{saunaId}/recommendation": {
      "get": {
        "tags": [
          "Saunas"
        ],
        "summary": "Doporučení nejlepšího času k návštěvě",
        "description": "Doporučí nejklidnější časové okno a denní špičku na základě historických dat o obsazenosti.",
        "operationId": "GetSaunaRecommendation",
        "parameters": [
          {
            "name": "saunaId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "date",
            "in": "query",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SaunaRecommendationResponse"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "ProblemDetails": {
        "type": "object",
        "properties": {
          "type": {
            "type": [
              "null",
              "string"
            ]
          },
          "title": {
            "type": [
              "null",
              "string"
            ]
          },
          "status": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "null",
              "integer",
              "string"
            ],
            "format": "int32"
          },
          "detail": {
            "type": [
              "null",
              "string"
            ]
          },
          "instance": {
            "type": [
              "null",
              "string"
            ]
          }
        }
      },
      "SaunaApiAttempt": {
        "required": [
          "startedAtUtc",
          "status",
          "source"
        ],
        "type": "object",
        "properties": {
          "startedAtUtc": {
            "type": "string",
            "format": "date-time"
          },
          "status": {
            "type": "string"
          },
          "source": {
            "type": "string"
          }
        }
      },
      "SaunaApiDetailResponse": {
        "required": [
          "apiVersion",
          "generatedAtUtc",
          "sauna"
        ],
        "type": "object",
        "properties": {
          "apiVersion": {
            "type": "string"
          },
          "generatedAtUtc": {
            "type": "string",
            "format": "date-time"
          },
          "sauna": {
            "$ref": "#/components/schemas/SaunaApiSnapshot"
          }
        }
      },
      "SaunaApiListResponse": {
        "required": [
          "apiVersion",
          "generatedAtUtc",
          "saunas"
        ],
        "type": "object",
        "properties": {
          "apiVersion": {
            "type": "string"
          },
          "generatedAtUtc": {
            "type": "string",
            "format": "date-time"
          },
          "saunas": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SaunaApiSnapshot"
            }
          }
        }
      },
      "SaunaApiSnapshot": {
        "required": [
          "id",
          "name",
          "sourceUrl",
          "timeZone",
          "capacity",
          "occupancy",
          "occupancyPercent",
          "observedAtUtc",
          "ageSeconds",
          "source",
          "isStale",
          "lastAttempt",
          "nextScheduledAtUtc",
          "refreshPending"
        ],
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "sourceUrl": {
            "type": "string"
          },
          "timeZone": {
            "type": "string"
          },
          "capacity": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "null",
              "integer",
              "string"
            ],
            "format": "int32"
          },
          "occupancy": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "null",
              "integer",
              "string"
            ],
            "format": "int32"
          },
          "occupancyPercent": {
            "pattern": "^-?(?:0|[1-9]\\d*)(?:\\.\\d+)?(?:[eE][+-]?\\d+)?$",
            "type": [
              "null",
              "number",
              "string"
            ],
            "format": "double"
          },
          "observedAtUtc": {
            "type": [
              "null",
              "string"
            ],
            "format": "date-time"
          },
          "ageSeconds": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "null",
              "integer",
              "string"
            ],
            "format": "int64"
          },
          "source": {
            "type": [
              "null",
              "string"
            ]
          },
          "isStale": {
            "type": "boolean"
          },
          "lastAttempt": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "$ref": "#/components/schemas/SaunaApiAttempt"
              }
            ]
          },
          "nextScheduledAtUtc": {
            "type": "string",
            "format": "date-time"
          },
          "refreshPending": {
            "type": "boolean"
          }
        }
      },
      "SaunaDailyAverage": {
        "required": [
          "date",
          "averageOccupancy",
          "averagePercent",
          "measurementCount",
          "slotCount"
        ],
        "type": "object",
        "properties": {
          "date": {
            "type": "string",
            "format": "date"
          },
          "averageOccupancy": {
            "pattern": "^-?(?:0|[1-9]\\d*)(?:\\.\\d+)?(?:[eE][+-]?\\d+)?$",
            "type": [
              "number",
              "string"
            ],
            "format": "double"
          },
          "averagePercent": {
            "pattern": "^-?(?:0|[1-9]\\d*)(?:\\.\\d+)?(?:[eE][+-]?\\d+)?$",
            "type": [
              "null",
              "number",
              "string"
            ],
            "format": "double"
          },
          "measurementCount": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "integer",
              "string"
            ],
            "format": "int32"
          },
          "slotCount": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "integer",
              "string"
            ],
            "format": "int32"
          }
        }
      },
      "SaunaDayStats": {
        "required": [
          "apiVersion",
          "generatedAtUtc",
          "saunaId",
          "saunaName",
          "timeZone",
          "date",
          "capacity",
          "lastOccupancy",
          "lastObservedAtUtc",
          "averageOccupancy",
          "averagePercent",
          "peakOccupancy",
          "measurementCount",
          "expectedSlots",
          "slots"
        ],
        "type": "object",
        "properties": {
          "apiVersion": {
            "type": "string"
          },
          "generatedAtUtc": {
            "type": "string",
            "format": "date-time"
          },
          "saunaId": {
            "type": "string"
          },
          "saunaName": {
            "type": "string"
          },
          "timeZone": {
            "type": "string"
          },
          "date": {
            "type": "string",
            "format": "date"
          },
          "capacity": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "null",
              "integer",
              "string"
            ],
            "format": "int32"
          },
          "lastOccupancy": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "null",
              "integer",
              "string"
            ],
            "format": "int32"
          },
          "lastObservedAtUtc": {
            "type": [
              "null",
              "string"
            ],
            "format": "date-time"
          },
          "averageOccupancy": {
            "pattern": "^-?(?:0|[1-9]\\d*)(?:\\.\\d+)?(?:[eE][+-]?\\d+)?$",
            "type": [
              "null",
              "number",
              "string"
            ],
            "format": "double"
          },
          "averagePercent": {
            "pattern": "^-?(?:0|[1-9]\\d*)(?:\\.\\d+)?(?:[eE][+-]?\\d+)?$",
            "type": [
              "null",
              "number",
              "string"
            ],
            "format": "double"
          },
          "peakOccupancy": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "null",
              "integer",
              "string"
            ],
            "format": "int32"
          },
          "measurementCount": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "integer",
              "string"
            ],
            "format": "int32"
          },
          "expectedSlots": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "integer",
              "string"
            ],
            "format": "int32"
          },
          "slots": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SaunaSlotAverage"
            }
          }
        }
      },
      "SaunaMonthlyAverage": {
        "required": [
          "month",
          "averageOccupancy",
          "averagePercent",
          "days",
          "measurementCount"
        ],
        "type": "object",
        "properties": {
          "month": {
            "type": "string"
          },
          "averageOccupancy": {
            "pattern": "^-?(?:0|[1-9]\\d*)(?:\\.\\d+)?(?:[eE][+-]?\\d+)?$",
            "type": [
              "number",
              "string"
            ],
            "format": "double"
          },
          "averagePercent": {
            "pattern": "^-?(?:0|[1-9]\\d*)(?:\\.\\d+)?(?:[eE][+-]?\\d+)?$",
            "type": [
              "null",
              "number",
              "string"
            ],
            "format": "double"
          },
          "days": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "integer",
              "string"
            ],
            "format": "int32"
          },
          "measurementCount": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "integer",
              "string"
            ],
            "format": "int32"
          }
        }
      },
      "SaunaOpeningHours": {
        "required": [
          "weekday",
          "weekdayName",
          "startHour",
          "endHour",
          "endMinute",
          "capacity"
        ],
        "type": "object",
        "properties": {
          "weekday": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "integer",
              "string"
            ],
            "format": "int32"
          },
          "weekdayName": {
            "type": "string"
          },
          "startHour": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "integer",
              "string"
            ],
            "format": "int32"
          },
          "endHour": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "integer",
              "string"
            ],
            "format": "int32"
          },
          "endMinute": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "integer",
              "string"
            ],
            "format": "int32"
          },
          "capacity": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "null",
              "integer",
              "string"
            ],
            "format": "int32"
          }
        }
      },
      "SaunaRecommendationResponse": {
        "required": [
          "apiVersion",
          "generatedAtUtc",
          "saunaId",
          "saunaName",
          "timeZone",
          "targetDate",
          "weekdayName",
          "capacity",
          "bestWindow",
          "peakWindow",
          "summary",
          "daySlots"
        ],
        "type": "object",
        "properties": {
          "apiVersion": {
            "type": "string"
          },
          "generatedAtUtc": {
            "type": "string",
            "format": "date-time"
          },
          "saunaId": {
            "type": "string"
          },
          "saunaName": {
            "type": "string"
          },
          "timeZone": {
            "type": "string"
          },
          "targetDate": {
            "type": "string",
            "format": "date"
          },
          "weekdayName": {
            "type": "string"
          },
          "capacity": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "null",
              "integer",
              "string"
            ],
            "format": "int32"
          },
          "bestWindow": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "$ref": "#/components/schemas/SaunaTimeRecommendationWindow"
              }
            ]
          },
          "peakWindow": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "$ref": "#/components/schemas/SaunaTimeRecommendationWindow"
              }
            ]
          },
          "summary": {
            "type": "string"
          },
          "daySlots": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SaunaWeekdaySlotAverage"
            }
          }
        }
      },
      "SaunaSlotAverage": {
        "required": [
          "slot",
          "localTime",
          "averageOccupancy",
          "averagePercent",
          "measurements"
        ],
        "type": "object",
        "properties": {
          "slot": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "integer",
              "string"
            ],
            "format": "int32"
          },
          "localTime": {
            "type": "string"
          },
          "averageOccupancy": {
            "pattern": "^-?(?:0|[1-9]\\d*)(?:\\.\\d+)?(?:[eE][+-]?\\d+)?$",
            "type": [
              "number",
              "string"
            ],
            "format": "double"
          },
          "averagePercent": {
            "pattern": "^-?(?:0|[1-9]\\d*)(?:\\.\\d+)?(?:[eE][+-]?\\d+)?$",
            "type": [
              "null",
              "number",
              "string"
            ],
            "format": "double"
          },
          "measurements": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "integer",
              "string"
            ],
            "format": "int32"
          }
        }
      },
      "SaunaStatsResponse": {
        "required": [
          "apiVersion",
          "generatedAtUtc",
          "saunaId",
          "saunaName",
          "sourceUrl",
          "timeZone",
          "capacity",
          "firstObservedAtUtc",
          "lastObservedAtUtc",
          "measurementCount",
          "openingHours",
          "dailyAverages",
          "weekdaySlots",
          "monthlyAverages"
        ],
        "type": "object",
        "properties": {
          "apiVersion": {
            "type": "string"
          },
          "generatedAtUtc": {
            "type": "string",
            "format": "date-time"
          },
          "saunaId": {
            "type": "string"
          },
          "saunaName": {
            "type": "string"
          },
          "sourceUrl": {
            "type": "string"
          },
          "timeZone": {
            "type": "string"
          },
          "capacity": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "null",
              "integer",
              "string"
            ],
            "format": "int32"
          },
          "firstObservedAtUtc": {
            "type": [
              "null",
              "string"
            ],
            "format": "date-time"
          },
          "lastObservedAtUtc": {
            "type": [
              "null",
              "string"
            ],
            "format": "date-time"
          },
          "measurementCount": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "integer",
              "string"
            ],
            "format": "int32"
          },
          "openingHours": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SaunaOpeningHours"
            }
          },
          "dailyAverages": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SaunaDailyAverage"
            }
          },
          "weekdaySlots": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SaunaWeekdaySlotAverage"
            }
          },
          "monthlyAverages": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SaunaMonthlyAverage"
            }
          }
        }
      },
      "SaunaTimeRecommendationWindow": {
        "required": [
          "startTime",
          "endTime",
          "averageOccupancy",
          "averagePercent"
        ],
        "type": "object",
        "properties": {
          "startTime": {
            "type": "string"
          },
          "endTime": {
            "type": "string"
          },
          "averageOccupancy": {
            "pattern": "^-?(?:0|[1-9]\\d*)(?:\\.\\d+)?(?:[eE][+-]?\\d+)?$",
            "type": [
              "number",
              "string"
            ],
            "format": "double"
          },
          "averagePercent": {
            "pattern": "^-?(?:0|[1-9]\\d*)(?:\\.\\d+)?(?:[eE][+-]?\\d+)?$",
            "type": [
              "null",
              "number",
              "string"
            ],
            "format": "double"
          }
        }
      },
      "SaunaWeekdaySlotAverage": {
        "required": [
          "weekday",
          "weekdayName",
          "slot",
          "localTime",
          "averageOccupancy",
          "averagePercent",
          "days"
        ],
        "type": "object",
        "properties": {
          "weekday": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "integer",
              "string"
            ],
            "format": "int32"
          },
          "weekdayName": {
            "type": "string"
          },
          "slot": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "integer",
              "string"
            ],
            "format": "int32"
          },
          "localTime": {
            "type": "string"
          },
          "averageOccupancy": {
            "pattern": "^-?(?:0|[1-9]\\d*)(?:\\.\\d+)?(?:[eE][+-]?\\d+)?$",
            "type": [
              "number",
              "string"
            ],
            "format": "double"
          },
          "averagePercent": {
            "pattern": "^-?(?:0|[1-9]\\d*)(?:\\.\\d+)?(?:[eE][+-]?\\d+)?$",
            "type": [
              "null",
              "number",
              "string"
            ],
            "format": "double"
          },
          "days": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "integer",
              "string"
            ],
            "format": "int32"
          }
        }
      },
      "WidgetApiRow": {
        "required": [
          "key"
        ],
        "type": "object",
        "properties": {
          "key": {
            "type": "string"
          },
          "value": {
            "type": [
              "null",
              "string"
            ]
          },
          "color": {
            "type": [
              "null",
              "string"
            ]
          }
        }
      }
    }
  },
  "tags": [
    {
      "name": "Saunas"
    }
  ]
}