{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/zuegle-com/json-schema/zuegle-com-rent-benchmark-schema.json",
  "title": "RentBenchmark",
  "description": "BFS rent benchmark for a municipality, from the Mietpreiserhebung (Strukturerhebung) survey.",
  "x-generated": "2026-11-29",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/zuegle-com-openapi.yaml#/components/schemas/RentBenchmark",
  "type": "object",
  "required": [
    "municipality",
    "overall",
    "forRooms",
    "basisMeaning",
    "source"
  ],
  "properties": {
    "municipality": {
      "type": "object",
      "description": "The municipality this benchmark describes.",
      "required": [
        "bfsId",
        "name",
        "canton"
      ],
      "properties": {
        "bfsId": {
          "type": "integer",
          "description": "BFS/OFS municipality number."
        },
        "name": {
          "type": "string",
          "description": "Municipality name."
        },
        "canton": {
          "type": "string",
          "description": "Two-letter canton abbreviation."
        }
      }
    },
    "overall": {
      "type": [
        "object",
        "null"
      ],
      "description": "The overall (average) rent for this municipality or canton, depending on `basis`. Null when no figure is available.",
      "properties": {
        "monthly": {
          "type": "number",
          "description": "Monthly rent in CHF."
        },
        "basis": {
          "type": "string",
          "enum": [
            "city",
            "canton"
          ],
          "description": "'city' means BFS publishes this municipality in its own right; 'canton' means this is the cantonal average, NOT a figure about this municipality specifically."
        },
        "label": {
          "type": "string",
          "description": "Display label — municipality name or canton abbreviation."
        },
        "year": {
          "oneOf": [
            {
              "type": "integer",
              "description": "Publication year (e.g., 2024) for city-level figures."
            },
            {
              "type": "string",
              "description": "Year range (e.g., '2022-2024') for some city-level figures."
            }
          ]
        },
        "marginChf": {
          "type": "number",
          "description": "Margin of error in CHF (the range is ±marginChf)."
        }
      }
    },
    "forRooms": {
      "type": [
        "object",
        "null"
      ],
      "description": "Rent benchmark for the specified room count, interpolated if necessary. Swiss flats are advertised in half-rooms but BFS publishes by whole rooms, so a 3.5-room figure is interpolated between two buckets. Null when the requested room count is not available or was not requested.",
      "properties": {
        "rooms": {
          "type": "number",
          "description": "The requested room count (echoed back)."
        },
        "monthly": {
          "type": "number",
          "description": "Monthly rent in CHF for this room count."
        },
        "basis": {
          "type": "string",
          "enum": [
            "city",
            "canton"
          ],
          "description": "Same meaning as `overall.basis`."
        },
        "label": {
          "type": "string",
          "description": "Display label — municipality name or canton abbreviation."
        },
        "bucketLabel": {
          "type": "string",
          "description": "The BFS room bucket this comes from (e.g., '3', '4'), useful when interpolated."
        },
        "interpolated": {
          "type": "boolean",
          "description": "True when this value is interpolated between two BFS buckets (e.g., a 3.5-room query between published 3 and 4 room figures). It is a stated approximation."
        }
      }
    },
    "basisMeaning": {
      "type": "string",
      "description": "Explanation of what `basis` means — stated in the payload so no reader can miss that 'canton' is NOT a figure about this municipality specifically."
    },
    "source": {
      "type": [
        "object",
        "null"
      ],
      "description": "Provenance of the figure, passed through from data/rent-stats.json. An OBJECT, not a string — a client generated against a string here would break on the real payload.",
      "properties": {
        "name": {
          "type": "string"
        },
        "url": {
          "type": "string",
          "description": "The cantonal dataset on opendata.swiss."
        },
        "citySourceUrl": {
          "type": "string",
          "description": "The 10-largest-cities dataset."
        },
        "retrievedAt": {
          "type": "string",
          "description": "When the committed snapshot was taken."
        }
      }
    },
    "note": {
      "type": "string",
      "description": "Explanation of why no figure is available. Present only when `overall` is null, never when data is returned."
    }
  }
}