{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "title": "Teerkost offers",
  "description": "Offer records published from the Teerkost scraper output.",
  "type": "array",
  "items": {
    "type": "object",
    "required": [
      "id",
      "productId",
      "product",
      "productInfo",
      "category",
      "image",
      "deal",
      "price",
      "percentage",
      "dateStart",
      "dateEnd",
      "link",
      "shop"
    ],
    "properties": {
      "id": { "type": "integer" },
      "productId": { "type": "string" },
      "product": { "type": "string" },
      "productInfo": { "type": "string" },
      "category": { "type": "string" },
      "image": { "type": "string" },
      "deal": { "type": "string" },
      "price": { "type": "number", "minimum": 0 },
      "percentage": {
        "description": "Discount percentage; legacy Lidl records may encode this integer as a string.",
        "anyOf": [
          { "type": "number" },
          { "type": "string", "pattern": "^-?\\d+$" }
        ]
      },
      "dateStart": { "$ref": "#/$defs/dateOrEmpty" },
      "dateEnd": { "$ref": "#/$defs/dateOrEmpty" },
      "link": { "type": "string" },
      "shop": { "type": "string" }
    },
    "additionalProperties": false
  },
  "$defs": {
    "dateOrEmpty": {
      "anyOf": [
        { "type": "string", "format": "date" },
        { "const": "" }
      ]
    }
  }
}
