{
  "$id": "https://vendia.net/examples/approaches/data-modeling",
  "$schema": "https://json-schema.org/draft-07/schema#",
  "definitions": {
    "Address": {
      "properties": {
        "city": {
          "description": "The city",
          "type": "string"
        },
        "state": {
          "description": "The state",
          "pattern": "((A[LKZR])|(C[AOT])|(D[EC])|(FL)|(GA)|(HI)|(I[DLNA])|(K[SY])|(LA)|(M[EDAINSOT])|(N[EVHJMYCD])|(O[HKR])|(PA)|(RI)|(S[CD])|(T[NX])|(UT)|(V[TA])|(W[AVIY]))",
          "type": "string"
        },
        "street": {
          "description": "Street address",
          "type": "string"
        },
        "zipcode": {
          "description": "The zipcode",
          "pattern": "\\d{5}",
          "type": "string"
        }
      },
      "required": [
        "street",
        "city",
        "state"
      ],
      "type": "object"
    },
    "EmployeeId": {
      "pattern": "\\d{5}",
      "type": "string"
    },
    "Name": {
      "properties": {
        "firstName": {
          "description": "Person's first name",
          "type": "string"
        },
        "lastName": {
          "description": "Person's first name",
          "type": "string"
        }
      },
      "required": [
        "firstName",
        "lastName"
      ],
      "type": "object"
    },
    "OfficeId": {
      "pattern": "\\d{3}",
      "type": "string"
    }
  },
  "description": "A model to capture ACME Company's organizational structure and office locations",
  "properties": {
    "Employee": {
      "description": "An ACME Co. Employee",
      "items": {
        "properties": {
          "employeeAddress": {
            "$ref": "#/definitions/Address",
            "description": "Address of the employee"
          },
          "employeeId": {
            "$ref": "#/definitions/EmployeeId",
            "description": "Unique identifier of the employee"
          },
          "employeeIds": {
            "description": "Unique identifier of the employees this person manages",
            "items": {
              "$ref": "#/definitions/EmployeeId"
            },
            "type": "array"
          },
          "employeeName": {
            "$ref": "#/definitions/Name",
            "description": "Name of the employee"
          },
          "managerId": {
            "$ref": "#/definitions/EmployeeId",
            "description": "Unique identifier of the employee's manager"
          },
          "officeId": {
            "$ref": "#/definitions/OfficeId",
            "description": "Office this employee is expected to work from, if applicable"
          },
          "targetHours": {
            "description": "Target hours/week for the employee",
            "type": "integer"
          }
        },
        "required": [
          "employeeId",
          "employeeName",
          "employeeAddress",
          "managerId",
          "officeId"
        ],
        "type": "object"
      },
      "type": "array"
    },
    "Office": {
      "description": "An ACME Co. Office",
      "items": {
        "properties": {
          "costType": {
            "description": "Cost type for the office",
            "enum": [
              "LEASE",
              "MORTGAGE",
              "OWN",
              "OTHER"
            ],
            "type": "string"
          },
          "currentOccupancy": {
            "description": "Current number of employees reporting to this office",
            "type": "integer"
          },
          "dateOpened": {
            "description": "Date the office opened",
            "format": "date",
            "type": "string"
          },
          "isFull": {
            "description": "Whether the office is at its max capacity",
            "type": "boolean"
          },
          "maxOccupancy": {
            "description": "Maximum number of employees allowed",
            "type": "integer"
          },
          "monthlyCost": {
            "description": "Cost type for the office per month, if applicable",
            "type": "number"
          },
          "officeAddress": {
            "$ref": "#/definitions/Address",
            "description": "Address of the office"
          },
          "officeId": {
            "$ref": "#/definitions/OfficeId",
            "description": "Unique identifier of the office"
          }
        },
        "required": [
          "officeId",
          "officeAddress",
          "maxOccupancy",
          "costType",
          "isFull"
        ],
        "type": "object"
      },
      "type": "array"
    }
  },
  "title": "ACME Co. Universal Application",
  "type": "object",
  "x-vendia-acls": {
    "EmployeeAcl": {
      "type": "Employee"
    },
    "OfficeAcl": {
      "type": "Office"
    }
  },
  "x-vendia-indexes": {
    "CurrentOccupancyIndex": [
      {
        "property": "currentOccupancy",
        "type": "Office"
      }
    ],
    "MaxOccupancyIndex": [
      {
        "property": "maxOccupancy",
        "type": "Office"
      }
    ]
  }
}