{
    "$schema": "http://json-schema.org/draft-07/schema#",
    "type": "object",
    "properties": {
      "calendars": {
        "type": "array",
        "minItems": 1,
        "items": 
          {
            "type": "object",
            "properties": {
              "url": {
                "type": "string",
                "minLength": 1
              },
              "roomRules": {
                "type": "array",
                "minItems": 1,
                "items": 
                  {
                    "type": "object",
                    "properties": {
                      "locationRegEx": {
                        "type": "string",
                        "minLength": 1
                      },
                      "roomId": {
                        "type": "string",
                        "minLength": 1
                      }
                    },
                    "required": ["locationRegEx", "roomId"]
                  }
              }
            },
            "required": ["url", "roomRules"]
          }
      },   
      "devices": {
        "type": "array",
        "minItems": 1,
        "items": 
          {
            "type": "object",
            "properties": {
              "deviceId": {
                "type": "string",
                "minLength": 1
              },
              "roomIds": {
                "type": "array",
                "minItems": 0,
                "items": 
                  {
                    "type": "string",
                    "minLength": 1
                  }
                
              },
              "routerId": {
                "type": ["string", "null"]
              }
              
            },
            "required": ["deviceId", "roomIds", "routerId"],
          }
      }, 
      "rooms": {
        "type": "array",
        "minItems": 1,
        "items": 
          {
            "type": "object",
            "properties": {
              "roomId": {
                "type": "string",
                "minLength": 1
              },
              "name": {
                "type": "string",
                "minLength": 1
              },
              "door": {
                "type": "string",
                "minLength": 1  
              }
            },
            "required": ["roomId", "name", "door"]
          }
      },
      "routers": {
        "type": "array",
        "minItems": 1,
        "items": 
          {
            "type": "object",
            "properties": {
             
              "routerId": {
                "$ref": "#/properties/devices/items/properties/routerId"   
              },
              "routes": {
                "type": "array",
                "minItems": 1,
                "items": 
                  {
                    "type": "object",
                    "properties": {
                      "roomId": {
                        "type": "string"
                      },
                      "distance": {
                        "type": "string"
                      },
                      "direction": {
                        "type": "string",
                        "enum": ["n", "e", "s", "w", "ne", "se", "sw", "nw"]
                      }
                    },
                    "required": ["roomId", "distance", "direction"]
                  }
              }
            },
            "required": ["routerId", "routes"]
          }
      }
    },
    "required": ["calendars", "devices", "rooms"]
  }