{
  "openapi": "3.1.0",
  "info": {
    "title": "TesterStay API \u00b7 expected contract",
    "version": "1.0.0",
    "description": "Interview requirements, including expected validation and date types. Actual behavior may differ. Dates are calendar dates, checkout exclusive, 1\u201330 nights; no past-date restriction. Each room is one unit. Overlap of confirmed stays must return 409. Total = nights \u00d7 rate, in whole EUR. Cancellation persists and is idempotent. Sessions are isolated and expire seven days after their last database modification."
  },
  "servers": [
    {
      "url": "https://tester.dotaeva.cz/api"
    },
    {
      "url": "http://localhost:8090/api"
    }
  ],
  "security": [
    {
      "sessionToken": []
    }
  ],
  "paths": {
    "/health": {
      "get": {
        "summary": "Service health",
        "operationId": "gethealth",
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Health"
                }
              }
            }
          }
        },
        "security": []
      }
    },
    "/sessions": {
      "post": {
        "summary": "Create a separate session",
        "operationId": "postsessions",
        "responses": {
          "201": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Session"
                }
              }
            }
          },
          "400": {
            "description": "Malformed JSON",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Session or booking limit reached",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "security": []
      }
    },
    "/session": {
      "get": {
        "summary": "Verify session",
        "operationId": "getsession",
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SessionInfo"
                }
              }
            }
          },
          "401": {
            "description": "Missing or unknown session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/rooms": {
      "get": {
        "summary": "List room rates and capacities",
        "operationId": "getrooms",
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Rooms"
                }
              }
            }
          },
          "401": {
            "description": "Missing or unknown session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/quotes": {
      "post": {
        "summary": "Calculate the expected price",
        "operationId": "postquotes",
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Quote"
                }
              }
            }
          },
          "401": {
            "description": "Missing or unknown session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "400": {
            "description": "Malformed JSON",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Validation error or disallowed SQL",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/QuoteInput"
              }
            }
          }
        }
      }
    },
    "/bookings": {
      "get": {
        "summary": "List bookings",
        "operationId": "getbookings",
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Bookings"
                }
              }
            }
          },
          "401": {
            "description": "Missing or unknown session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Validation error or disallowed SQL",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "in": "query",
            "name": "status",
            "schema": {
              "type": "string",
              "enum": [
                "confirmed",
                "cancelled"
              ]
            },
            "description": "Omit for all reservations"
          }
        ]
      },
      "post": {
        "summary": "Create a confirmed booking",
        "operationId": "postbookings",
        "responses": {
          "201": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Booking"
                }
              }
            }
          },
          "401": {
            "description": "Missing or unknown session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "400": {
            "description": "Malformed JSON",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Room is already booked for overlapping dates",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Validation error or disallowed SQL",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Session or booking limit reached",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/BookingInput"
              }
            }
          }
        }
      }
    },
    "/bookings/{id}": {
      "get": {
        "summary": "Read booking",
        "operationId": "getbookingsid",
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Booking"
                }
              }
            }
          },
          "401": {
            "description": "Missing or unknown session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ]
      }
    },
    "/bookings/{id}/cancel": {
      "post": {
        "summary": "Persist cancellation; safe to repeat",
        "operationId": "postbookingsidcancel",
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Booking"
                }
              }
            }
          },
          "401": {
            "description": "Missing or unknown session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "400": {
            "description": "Malformed JSON",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ]
      }
    },
    "/database/schema": {
      "get": {
        "summary": "Inspect declared table types",
        "operationId": "getdatabaseschema",
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DatabaseSchema"
                }
              }
            }
          },
          "401": {
            "description": "Missing or unknown session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/database/query": {
      "post": {
        "summary": "Run a read-only SELECT query",
        "operationId": "postdatabasequery",
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/QueryResult"
                }
              }
            }
          },
          "401": {
            "description": "Missing or unknown session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "400": {
            "description": "Malformed JSON",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Validation error or disallowed SQL",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/QueryInput"
              }
            }
          }
        }
      }
    },
    "/session/reset": {
      "post": {
        "summary": "Restore only this session to seed data",
        "operationId": "postsessionreset",
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ResetResult"
                }
              }
            }
          },
          "401": {
            "description": "Missing or unknown session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "400": {
            "description": "Malformed JSON",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Validation error or disallowed SQL",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ResetInput"
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "sessionToken": {
        "type": "http",
        "scheme": "bearer"
      }
    },
    "schemas": {
      "Error": {
        "type": "object",
        "properties": {
          "error": {
            "type": "object",
            "properties": {
              "message": {
                "type": "string"
              },
              "requestId": {
                "type": "string"
              }
            },
            "required": [
              "message",
              "requestId"
            ]
          }
        },
        "required": [
          "error"
        ]
      },
      "Session": {
        "type": "object",
        "properties": {
          "token": {
            "type": "string"
          },
          "sessionId": {
            "type": "string"
          },
          "expiresIn": {
            "type": "integer"
          },
          "scenarioMonth": {
            "type": "string"
          }
        },
        "required": [
          "token",
          "sessionId",
          "expiresIn",
          "scenarioMonth"
        ]
      },
      "SessionInfo": {
        "type": "object",
        "properties": {
          "sessionId": {
            "type": "string"
          },
          "scenarioMonth": {
            "type": "string"
          }
        },
        "required": [
          "sessionId",
          "scenarioMonth"
        ]
      },
      "Health": {
        "type": "object",
        "properties": {
          "status": {
            "type": "string",
            "enum": [
              "ok"
            ]
          },
          "version": {
            "type": "string"
          }
        },
        "required": [
          "status",
          "version"
        ]
      },
      "Room": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "category": {
            "type": "string"
          },
          "capacity": {
            "type": "integer"
          },
          "nightlyRate": {
            "type": "integer"
          },
          "area": {
            "type": "integer"
          },
          "features": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "color": {
            "type": "string"
          }
        },
        "required": [
          "id",
          "name",
          "category",
          "capacity",
          "nightlyRate",
          "area",
          "features",
          "color"
        ]
      },
      "Rooms": {
        "type": "object",
        "properties": {
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Room"
            }
          },
          "currency": {
            "type": "string",
            "enum": [
              "EUR"
            ]
          }
        },
        "required": [
          "items",
          "currency"
        ]
      },
      "QuoteInput": {
        "type": "object",
        "properties": {
          "roomId": {
            "type": "string",
            "enum": [
              "r1",
              "r2",
              "r3"
            ]
          },
          "checkIn": {
            "type": "string",
            "format": "date",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
            "example": "2026-10-25"
          },
          "checkOut": {
            "type": "string",
            "format": "date",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
            "example": "2026-10-25"
          },
          "guests": {
            "type": "integer",
            "minimum": 1,
            "maximum": 6,
            "description": "Maximum is the selected room capacity."
          }
        },
        "required": [
          "roomId",
          "checkIn",
          "checkOut",
          "guests"
        ]
      },
      "BookingInput": {
        "type": "object",
        "properties": {
          "roomId": {
            "type": "string",
            "enum": [
              "r1",
              "r2",
              "r3"
            ]
          },
          "checkIn": {
            "type": "string",
            "format": "date",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
            "example": "2026-10-25"
          },
          "checkOut": {
            "type": "string",
            "format": "date",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
            "example": "2026-10-25"
          },
          "guests": {
            "type": "integer",
            "minimum": 1,
            "maximum": 6,
            "description": "Maximum is the selected room capacity."
          },
          "guestName": {
            "type": "string",
            "minLength": 2,
            "maxLength": 80
          },
          "source": {
            "type": "string",
            "enum": [
              "web",
              "ios",
              "postman"
            ],
            "default": "postman"
          }
        },
        "required": [
          "roomId",
          "checkIn",
          "checkOut",
          "guests",
          "guestName"
        ]
      },
      "Quote": {
        "type": "object",
        "properties": {
          "nights": {
            "type": "integer",
            "minimum": 1,
            "maximum": 30
          },
          "nightlyRate": {
            "type": "integer"
          },
          "total": {
            "type": "integer"
          },
          "currency": {
            "type": "string",
            "enum": [
              "EUR"
            ]
          }
        },
        "required": [
          "nights",
          "nightlyRate",
          "total",
          "currency"
        ]
      },
      "Booking": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "roomId": {
            "type": "string"
          },
          "guestName": {
            "type": "string"
          },
          "checkIn": {
            "type": "string",
            "format": "date",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
            "example": "2026-10-25"
          },
          "checkOut": {
            "type": "string",
            "format": "date",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
            "example": "2026-10-25"
          },
          "guests": {
            "type": "integer",
            "minimum": 1
          },
          "status": {
            "type": "string",
            "enum": [
              "confirmed",
              "cancelled"
            ]
          },
          "total": {
            "type": "integer",
            "minimum": 120
          },
          "currency": {
            "type": "string",
            "enum": [
              "EUR"
            ]
          },
          "source": {
            "type": "string",
            "enum": [
              "web",
              "ios",
              "postman",
              "legacy-import"
            ]
          }
        },
        "required": [
          "id",
          "roomId",
          "guestName",
          "checkIn",
          "checkOut",
          "guests",
          "status",
          "total",
          "currency",
          "source"
        ]
      },
      "Bookings": {
        "type": "object",
        "properties": {
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Booking"
            }
          }
        },
        "required": [
          "items"
        ]
      },
      "QueryInput": {
        "type": "object",
        "properties": {
          "sql": {
            "type": "string",
            "minLength": 1,
            "maxLength": 4000
          }
        },
        "required": [
          "sql"
        ]
      },
      "QueryResult": {
        "type": "object",
        "properties": {
          "columns": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "rows": {
            "type": "array",
            "maxItems": 200,
            "items": {
              "type": "array",
              "items": {}
            }
          },
          "truncated": {
            "type": "boolean"
          }
        },
        "required": [
          "columns",
          "rows",
          "truncated"
        ]
      },
      "DatabaseSchema": {
        "type": "object",
        "properties": {
          "engine": {
            "type": "string",
            "enum": [
              "SQLite"
            ]
          },
          "readOnly": {
            "type": "boolean"
          },
          "maxRows": {
            "type": "integer"
          },
          "tables": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "name": {
                  "type": "string"
                },
                "columns": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "cid": {
                        "type": "integer"
                      },
                      "name": {
                        "type": "string"
                      },
                      "type": {
                        "type": "string"
                      },
                      "notnull": {
                        "type": "integer"
                      },
                      "dflt_value": {
                        "type": [
                          "string",
                          "number",
                          "null"
                        ]
                      },
                      "pk": {
                        "type": "integer"
                      }
                    },
                    "required": [
                      "cid",
                      "name",
                      "type",
                      "notnull",
                      "dflt_value",
                      "pk"
                    ]
                  }
                }
              },
              "required": [
                "name",
                "columns"
              ]
            }
          }
        },
        "required": [
          "engine",
          "readOnly",
          "maxRows",
          "tables"
        ]
      },
      "ResetInput": {
        "type": "object",
        "properties": {
          "confirm": {
            "type": "string",
            "enum": [
              "RESET"
            ]
          }
        },
        "required": [
          "confirm"
        ]
      },
      "ResetResult": {
        "type": "object",
        "properties": {
          "status": {
            "type": "string",
            "enum": [
              "reset"
            ]
          }
        },
        "required": [
          "status"
        ]
      }
    }
  }
}
