{
  "id": "#byggnad-ref-1.0.json",
  "$schema": "http://json-schema.org/draft-04/schema#",
  "title": "Byggnad Referens 1.0 Test 6",
  "oneOf": [
    {
      "$ref": "#/definitions/byggnad"
    },
    {
      "$ref": "#/definitions/byggnadstillbehor"
    },
    {
      "$ref": "#/definitions/andamalsenhet"
    }
  ],
  "definitions": {
    "byggnad": {
      "type": "object",
      "properties": {
        "feature": {
          "$ref": "#/definitions/attributFeatureByggnad"
        },
        "byggnad": {
          "$ref": "#/definitions/attributByggnad"
        }
      },
      "required": [
        "feature",
        "byggnad"
      ],
      "additionalProperties": false
    },
    "attributFeatureByggnad": {
      "type": "object",
      "properties": {
        "typ": {
          "type": "string",
          "enum": [
            "byggnad"
          ]
        },
        "etikett": {
          "type": "string"
        }
      },
      "required": [
        "typ",
        "etikett"
      ],
      "additionalProperties": false
    },
    "attributByggnad": {
      "type": "object",
      "properties": {
        "objektidentitet": {
          "$ref": "#/definitions/uuid"
        },
        "fritidshus": {
          "type": "boolean"
        },
        "datumNybyggnad": {
          "$ref": "#/definitions/datum"
        },
        "datumNybyggnadTaxering": {
          "$ref": "#/definitions/datum"
        },
        "datumTillbyggnad": {
          "type": "array",
          "minItems": 1,
          "items": {
            "$ref": "#/definitions/datum"
          }
        },
        "datumAndring": {
          "type": "array",
          "minItems": 1,
          "items": {
            "$ref": "#/definitions/datum"
          }
        },
        "maxAbsolutHojdTak": {
          "type": "number"
        },
        "kallare": {
          "type": "boolean"
        },
        "vind": {
          "type": "boolean"
        },
        "maxAntalPlanOverMark": {
          "type": "integer"
        },
        "totalByggnadsarea": {
          "type": "number"
        },
        "totalBruttoarea": {
          "type": "number"
        },
        "totalOppenarea": {
          "type": "number"
        },
        "totalUppvarmdArea": {
          "type": "number"
        }
      },
      "required": [
        "objektidentitet"
      ],
      "additionalProperties": false
    },
    "byggnadstillbehor": {
      "type": "object",
      "properties": {
        "feature": {
          "$ref": "#/definitions/attributFeatureByggnadstillbehor"
        },
        "byggnad": {
          "$ref": "#/definitions/attributByggnad"
        },
        "byggnadstillbehor": {
          "$ref": "#/definitions/attributByggnadstillbehor"
        }
      },
      "required": [
        "feature",
        "byggnad",
        "byggnadstillbehor"
      ],
      "additionalProperties": false
    },
    "attributFeatureByggnadstillbehor": {
      "type": "object",
      "properties": {
        "typ": {
          "type": "string",
          "enum": [
            "byggnadstillbehör"
          ]
        },
        "etikett": {
          "type": "string"
        }
      },
      "required": [
        "typ",
        "etikett"
      ],
      "additionalProperties": false
    },
    "attributByggnadstillbehor": {
      "type": "object",
      "properties": {
        "andamalsenhet": {
          "$ref": "#/definitions/uuid"
        },
        "tillbehorstyp": {
          "$ref": "#/definitions/tillbehorstyp"
        },
        "matvardArea": {
          "type": "boolean"
        }
      },
      "required": [
        "tillbehorstyp"
      ],
      "additionalProperties": false
    },
    "andamalsenhet": {
      "type": "object",
      "properties": {
        "feature": {
          "$ref": "#/definitions/attributFeatureAndamalsenhet"
        },
        "byggnad": {
          "$ref": "#/definitions/attributByggnad"
        },
        "andamalsenhet": {
          "$ref": "#/definitions/attributAndamalsenhet"
        }
      },
      "required": [
        "feature",
        "byggnad",
        "andamalsenhet"
      ],
      "additionalProperties": false
    },
    "attributFeatureAndamalsenhet": {
      "type": "object",
      "properties": {
        "typ": {
          "type": "string",
          "enum": [
            "ändamålsenhet"
          ]
        },
        "etikett": {
          "type": "string"
        }
      },
      "required": [
        "typ",
        "etikett"
      ],
      "additionalProperties": false
    },
    "attributAndamalsenhet": {
      "type": "object",
      "properties": {
        "byggnadstillbehor": {
          "$ref": "#/definitions/uuid"
        },
        "andamalNiva1": {
          "type": "string"
        },
        "andamalNiva2": {
          "type": "string"
        },
        "andamalNiva3": {
          "type": "string"
        },
        "statusperiod": {
          "type": "array",
          "minItems": 1,
          "items": {
            "$ref": "#/definitions/byggnadsstatusperiod"
          }
        },
        "bygglovsbefriad": {
          "type": "boolean"
        }
      },
      "required": [
        "andamalNiva1"
      ],
      "additionalProperties": false
    },
    "byggnadsstatusperiod": {
      "type": "object",
      "properties": {
        "status": {
          "$ref": "#/definitions/byggnadsstatus"
        },
        "datumFran": {
          "$ref": "#/definitions/datum"
        },
        "datumTill": {
          "$ref": "#/definitions/datum"
        }
      },
      "required": [
        "status",
        "datumFran"
      ],
      "additionalProperties": false
    },
    "uuid": {
      "type": "string",
      "format": "uuid",
      "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"
    },
    "datum": {
      "type": "string",
      "format": "date",
      "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
    },
    "tillbehorstyp": {
      "type": "string",
      "enum": [
        "altan",
        "balkong",
        "lastkaj",
        "loftgång",
        "mast/antenn",
        "ramp",
        "räcke",
        "skorsten",
        "skärmtak",
        "solenergianläggning",
        "takfönster",
        "takkupa",
        "teknisk försörjning",
        "trappa"
      ]
    },
    "byggnadsstatus": {
      "type": "string",
      "enum": [
        "preliminär",
        "planerad",
        "under uppförande",
        "gällande",
        "riven"
      ]
    }
  }
}