{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "title": "hub.entity.3",
  "description": "Defines a version 3 entity message payload. Version 3 marks an entity whose profile is JSON: entity.files holds the profile as entity-data and the JSON Schema of that profile as entity-schema, and entity.modules holds exactly one item that names the entity type and the content version of that schema.",
  "type": "object",
  "properties": {
    "message": {
      "type": "object",
      "properties": {
        "version": {
          "type": "integer",
          "const": 3,
          "description": "Payload version. Always 3 for this schema."
        },
        "id": {
          "type": "string",
          "format": "uuid"
        },
        "relatedId": {
          "type": "string",
          "format": "uuid"
        },
        "applicationId": {
          "type": "string"
        },
        "dateTime": {
          "type": "string",
          "format": "date-time"
        }
      },
      "required": [
        "version",
        "id",
        "applicationId",
        "dateTime"
      ]
    },
    "entity": {
      "type": "object",
      "properties": {
        "reference": {
          "type": "string"
        },
        "names": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "locale": {
                "type": "string",
                "description": "Language code as the sending application's content defines it, for example en or de."
              },
              "name": {
                "type": "string"
              }
            },
            "required": [
              "locale",
              "name"
            ]
          },
          "uniqueItems": true
        },
        "status": {
          "type": "string"
        },
        "modules": {
          "type": "array",
          "description": "Exactly one item. id is the entity type and version is the content version that defines the entity type's schema.",
          "minItems": 1,
          "maxItems": 1,
          "items": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string"
              },
              "version": {
                "type": "string"
              }
            },
            "required": [
              "id",
              "version"
            ]
          }
        },
        "files": {
          "type": "array",
          "description": "Exactly one entity-data file, which holds the entity profile as JSON, and exactly one entity-schema file, which holds the JSON Schema that the profile conforms to.",
          "uniqueItems": true,
          "items": {
            "type": "object",
            "properties": {
              "type": {
                "type": "string"
              },
              "uri": {
                "type": "string"
              }
            },
            "required": [
              "type",
              "uri"
            ]
          },
          "allOf": [
            {
              "contains": {
                "properties": {
                  "type": {
                    "const": "entity-data"
                  }
                }
              },
              "maxContains": 1
            },
            {
              "contains": {
                "properties": {
                  "type": {
                    "const": "entity-schema"
                  }
                }
              },
              "maxContains": 1
            }
          ]
        }
      },
      "required": [
        "reference",
        "names",
        "modules",
        "files"
      ]
    }
  },
  "required": [
    "message",
    "entity"
  ]
}
