{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://baanlyy.com/feeds/baanlyy-json-v1.schema.json",
  "title": "BAANLYY JSON listings feed v1",
  "type": "object",
  "additionalProperties": false,
  "required": ["version", "listings"],
  "properties": {
    "version": {
      "const": 1,
      "description": "Must be the number 1."
    },
    "listings": {
      "type": "array",
      "items": { "$ref": "#/definitions/listing" }
    }
  },
  "definitions": {
    "listing": {
      "type": "object",
      "additionalProperties": false,
      "required": ["ref", "deal", "type", "title", "price", "city"],
      "properties": {
        "ref": { "type": "string", "minLength": 1 },
        "deal": { "type": "string", "enum": ["rent", "sale"] },
        "type": {
          "type": "string",
          "enum": [
            "condo",
            "apartment",
            "villa",
            "townhouse",
            "penthouse",
            "serviced_apartment",
            "house",
            "commercial",
            "land"
          ]
        },
        "title": { "type": "string", "minLength": 1, "maxLength": 160 },
        "description": { "type": ["string", "null"] },
        "price": { "type": "number", "exclusiveMinimum": 0 },
        "currency": { "type": "string", "minLength": 3 },
        "city": { "type": "string", "minLength": 1 },
        "area": { "type": ["string", "null"] },
        "lat": { "type": ["number", "null"] },
        "lng": { "type": ["number", "null"] },
        "bedrooms": { "type": ["number", "null"] },
        "bathrooms": { "type": ["number", "null"] },
        "size_sqm": { "type": ["number", "null"] },
        "plot_size_sqm": { "type": ["number", "null"] },
        "floor": { "type": ["number", "null"] },
        "year_built": { "type": ["integer", "null"] },
        "building_floors": { "type": ["integer", "null"] },
        "tenure": {
          "type": ["string", "null"],
          "enum": ["freehold", "leasehold", "foreign_quota", "company", "unknown", null]
        },
        "furnishing": {
          "type": ["string", "null"],
          "enum": ["fully_furnished", "partly_furnished", "unfurnished", null]
        },
        "available_from": { "type": ["string", "null"], "pattern": "^\\d{4}-\\d{2}-\\d{2}$" },
        "amenities": { "type": "array", "items": { "type": "string" } },
        "photos": { "type": "array", "items": { "type": "string", "format": "uri" } },
        "url": { "type": ["string", "null"] },
        "status": {
          "type": "string",
          "enum": ["available", "sold", "let", "withdrawn"],
          "description": "Anything other than available counts as not available."
        }
      }
    }
  }
}
