{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://schema.yext.com/config/km/field",
  "$version": "1.1",
  "type": "object",
  "title": "Field",
  "description": "Resource that represents a custom field.",
  "properties": {
    "$id": {
      "type": "string"
    },
    "$schema": {
      "const": "https://schema.yext.com/config/km/field/v1"
    },
    "description": {
      "type": "string",
      "description": "Description of the custom field ."
    },
    "descriptionTranslation": {
      "type": "array",
      "description": "Translations of the description for different locale codes.",
      "items": {
        "$ref": "#/definitions/translation"
      }
    },
    "displayName": {
      "type": "string",
      "description": "Display name of the field."
    },
    "displayNameTranslation": {
      "type": "array",
      "description": "Translations of the displayName for different locale codes.",
      "items": {
        "$ref": "#/definitions/translation"
      }
    },
    "group": {
      "type": "string",
      "description": "The ID of the custom field group for which this field belongs, NONE if this field isn\u0027t in a custom field group. Custom fields that are in the same group are displayed in a section together in the entity page and have the same permissions",
      "enum": [
        "NONE",
        "GROUP1",
        "GROUP2",
        "GROUP3",
        "GROUP4",
        "GROUP5",
        "GROUP6",
        "GROUP7",
        "GROUP8",
        "GROUP9",
        "GROUP10",
        "GROUP11",
        "GROUP12",
        "GROUP13",
        "GROUP14",
        "GROUP15",
        "GROUP16",
        "GROUP17",
        "GROUP18",
        "GROUP19",
        "GROUP20",
        "GROUP21",
        "GROUP22",
        "GROUP23",
        "GROUP24",
        "GROUP25",
        "GROUP26",
        "GROUP27",
        "GROUP28",
        "GROUP29",
        "GROUP30"
      ]
    },
    "localization": {
      "type": "string",
      "enum": [
        "PRIMARY_ONLY",
        "OVERRIDABLE",
        "LOCALE_SPECIFIC"
      ],
      "description": "Custom Field multi-language profile behavior. PRIMARY_ONLY: The Custom Field can only have a value set on its primary language profile. OVERRIDABLE: The Custom Field can have a value set on any alternate language profiles, which will override the primary language profile value when the alternate language profile is requested. When requested, if a value is not set for an alternate language profile, the primary language profile value will be returned. LANGUAGE_SPECIFIC: The Custom Field can have a value set on any alternate language profiles. When requested, if a value is not set for an alternate language profile, no value will be returned."
    },
    "type": {
      "$ref": "#/definitions/type",
      "description": "Property that defines data type for this field\u0027s content."
    },
    "typeId": {
      "type": "string",
      "format": "km/field-type",
      "description": "The ID of this field\u0027s type."
    },
    "writeScopes": {
      "type": "array",
      "description": "List of supported write scopes to edit this field.",
      "unordered": true,
      "items": {
        "type": "string",
        "description": "Write scopes to edit this field.",
        "enum": [
          "YEXT",
          "APP",
          "USER",
          "CONNECTOR"
        ]
      }
    }
  },
  "additionalProperties": false,
  "required": [
    "displayName",
    "typeId",
    "localization",
    "group"
  ],
  "definitions": {
    "type": {
      "type": "object",
      "properties": {
        "booleanType": {
          "$ref": "#/definitions/booleanType"
        },
        "dateTimeType": {
          "$ref": "#/definitions/dateTimeType"
        },
        "dateType": {
          "$ref": "#/definitions/dateType"
        },
        "decimalType": {
          "$ref": "#/definitions/decimalType"
        },
        "fileType": {
          "$ref": "#/definitions/fileType"
        },
        "imageType": {
          "$ref": "#/definitions/imageType"
        },
        "richTextV2Type": {
          "$ref": "#/definitions/richTextV2Type"
        },
        "listType": {
          "$ref": "#/definitions/listType"
        },
        "markdownType": {
          "$ref": "#/definitions/markdownType"
        },
        "optionType": {
          "$ref": "#/definitions/optionType"
        },
        "richTextType": {
          "$ref": "#/definitions/richTextType"
        },
        "stringType": {
          "$ref": "#/definitions/stringType"
        },
        "structType": {
          "$ref": "#/definitions/structType"
        },
        "videoType": {
          "$ref": "#/definitions/videoType"
        }
      },
      "additionalProperties": false,
      "minProperties": 1,
      "maxProperties": 1
    },
    "booleanType": {
      "type": "object",
      "description": "A Boolean (Yes/No) type.",
      "additionalProperties": false
    },
    "dateTimeType": {
      "type": "object",
      "description": "A DateTime type.",
      "properties": {
        "minValue": {
          "type": "string"
        },
        "maxValue": {
          "type": "string"
        }
      }
    },
    "dateType": {
      "type": "object",
      "description": "A Date type.",
      "properties": {
        "minValue": {
          "$ref": "#/definitions/day"
        },
        "maxValue": {
          "$ref": "#/definitions/day"
        }
      },
      "additionalProperties": false
    },
    "day": {
      "type": "object",
      "description": "A type describing a certain date.",
      "properties": {
        "year": {
          "type": "integer",
          "description": "Year of the date.",
          "minimum": 0
        },
        "month": {
          "type": "integer",
          "description": "Month of the date.",
          "minimum": 1,
          "maximum": 12
        },
        "day": {
          "type": "integer",
          "description": "Day of the date.",
          "minimum": 1,
          "maximum": 31
        }
      },
      "required": [
        "year",
        "month",
        "day"
      ],
      "additionalProperties": false
    },
    "decimalType": {
      "type": "object",
      "description": "A Decimal type.",
      "properties": {
        "minValue": {
          "type": "string"
        },
        "maxValue": {
          "type": "string"
        }
      },
      "additionalProperties": false
    },
    "fileType": {
      "type": "object",
      "description": "A File type.",
      "properties": {
        "maxFileSize": {
          "type": "integer",
          "description": "Size of the file in bytes.",
          "minimum": 0,
          "maximum": 1073741824
        },
        "mimeTypeFilter": {
          "type": "object",
          "description": "A MIME type filter.",
          "properties": {
            "supportedMimeType": {
              "type": "array",
              "description": "The list of MIME types supported by the file type.",
              "items": {
                "type": "object",
                "properties": {
                  "type": {
                    "type": "string",
                    "description": "Primary type of the file.",
                    "enum": [
                      "UNKNOWN",
                      "APPLICATION",
                      "AUDIO",
                      "FONT",
                      "EXAMPLE",
                      "IMAGE",
                      "MESSAGE",
                      "MODEL",
                      "MULTIPART",
                      "TEXT",
                      "VIDEO"
                    ]
                  },
                  "subtype": {
                    "type": "string",
                    "description": "Subtype of the file."
                  }
                },
                "additionalProperties": false
              }
            }
          }
        },
        "usePrivateUrls": {
          "type": "boolean",
          "description": "If true, any Images or Files uploaded to this field will be hosted via a secure URL that is not publicly accessible. This is only recommended for content that will be integrating with authorized experiences."
        }
      },
      "additionalProperties": false
    },
    "imageType": {
      "type": "object",
      "description": "An Image type.",
      "properties": {
        "isSimpleImage": {
          "type": "boolean",
          "description": "A flag determining if the image is simple or complex. A simple image contains a source url and an alternate text of an image. A complex image contains a simple image, caption, details and a click-through URL."
        },
        "minSize": {
          "type": "object",
          "description": "Minimum size of the image.",
          "properties": {
            "width": {
              "type": "integer",
              "description": "Width of the image in pixels.",
              "minimum": 0,
              "maximum": 10000
            },
            "height": {
              "type": "integer",
              "description": "Height of the image in pixels.",
              "minimum": 0,
              "maximum": 10000
            }
          },
          "required": [
            "width",
            "height"
          ],
          "additionalProperties": false
        },
        "allowedAspectRatio": {
          "type": "array",
          "description": "The set of aspect ratios supported by the image type.",
          "items": {
            "type": "object",
            "properties": {
              "horizontalFactor": {
                "type": "integer",
                "description": "The horizontal value for the aspect ratio."
              },
              "verticalFactor": {
                "type": "integer",
                "description": "The vertical value for the aspect ratio."
              }
            },
            "enum": [
              {
                "horizontalFactor": 1,
                "verticalFactor": 1
              },
              {
                "horizontalFactor": 4,
                "verticalFactor": 3
              },
              {
                "horizontalFactor": 3,
                "verticalFactor": 2
              },
              {
                "horizontalFactor": 5,
                "verticalFactor": 3
              },
              {
                "horizontalFactor": 16,
                "verticalFactor": 9
              },
              {
                "horizontalFactor": 3,
                "verticalFactor": 1
              },
              {
                "horizontalFactor": 2,
                "verticalFactor": 3
              },
              {
                "horizontalFactor": 5,
                "verticalFactor": 7
              },
              {
                "horizontalFactor": 4,
                "verticalFactor": 5
              },
              {
                "horizontalFactor": 16,
                "verticalFactor": 10
              }
            ],
            "additionalProperties": false
          },
          "maxItems": 1
        },
        "unconstrainedAspectRatioAllowed": {
          "type": "boolean",
          "description": "Flag to determine if a custom aspect ratio is supported by this image."
        },
        "noAllowedAspectRatios": {
          "type": "boolean",
          "description": "Flag to determine if any aspect ratio is allowed."
        }
      },
      "additionalProperties": false,
      "$comment": "Validates that an image type has 1 and only 1 aspect ratio",
      "allOf": [
        {
          "not": {
            "properties": {
              "unconstrainedAspectRatioAllowed": {
                "const": true
              },
              "allowedAspectRatio": {
                "minItems": 1
              }
            },
            "required": [
              "allowedAspectRatio"
            ]
          }
        },
        {
          "not": {
            "properties": {
              "unconstrainedAspectRatioAllowed": {
                "const": false
              },
              "allowedAspectRatio": {
                "maxItems": 0
              }
            }
          }
        }
      ]
    },
    "listType": {
      "type": "object",
      "description": "A List type.",
      "properties": {
        "typeId": {
          "type": "string",
          "description": "The type ID of the list items.",
          "format": "km/field-type"
        },
        "minLength": {
          "type": "integer",
          "description": "Minimum size of the list.",
          "minimum": 0
        },
        "maxLength": {
          "type": "integer",
          "description": "Maximum size of the list.",
          "minimum": 0
        },
        "type": {
          "description": "The type of the list items.",
          "oneOf": [
            {
              "$ref": "#/definitions/type"
            },
            {
              "type": "object",
              "properties": {
                "entityReferenceType": {
                  "type": "object",
                  "description": "An Entity reference type.",
                  "properties": {
                    "supportedEntityTypeIds": {
                      "type": "array",
                      "description": "List of supported entity type IDs.",
                      "items": {
                        "type": "string",
                        "format": "km/entity-type"
                      }
                    },
                    "type": {
                      "type": "string",
                      "description": "The type of entity reference relationship.",
                      "enum": [
                        "ONE_WAY",
                        "TWO_WAY"
                      ]
                    },
                    "relatedFieldId": {
                      "type": "string",
                      "format": "km/field",
                      "description": "The related field id in TWO_WAY entity reference relationship."
                    }
                  },
                  "additionalProperties": false
                }
              },
              "additionalProperties": false
            }
          ]
        }
      },
      "required": [
        "typeId"
      ],
      "additionalProperties": false
    },
    "optionType": {
      "type": "object",
      "description": "An Option type that contains a list of values (options) that a user can select from.",
      "properties": {
        "option": {
          "type": "array",
          "description": "A list of available options for this type.",
          "items": {
            "type": "object",
            "properties": {
              "displayName": {
                "type": "string",
                "description": "The display name of an option."
              },
              "textValue": {
                "type": "string",
                "description": "The value of an option."
              },
              "displayNameTranslation": {
                "type": "array",
                "description": "Translations of the displayName for different locale codes.",
                "items": {
                  "$ref": "#/definitions/translation"
                }
              }
            },
            "required": [
              "displayName",
              "textValue"
            ],
            "additionalProperties": false,
            "minProperties": 1
          }
        },
        "noOptions": {
          "type": "boolean",
          "description": "Flag that determines if this type has no options."
        }
      },
      "additionalProperties": false
    },
    "richTextType": {
      "type": "object",
      "description": "A Rich Text type, which contains a text that can be decorated with common formatting options such as bold and italics.",
      "properties": {
        "minLength": {
          "type": "integer",
          "description": "The minimum length of the text.",
          "minimum": 0
        },
        "maxLength": {
          "type": "integer",
          "description": "The maximum length of the text.",
          "minimum": 0
        },
        "supportedFormat": {
          "type": "array",
          "description": "List of supported rich text formats.",
          "unordered": true,
          "items": {
            "type": "string",
            "description": "Supported rich text format.",
            "enum": [
              "BOLD",
              "ITALICS",
              "UNDERLINE",
              "BULLETED_LIST",
              "NUMBERED_LIST",
              "HYPERLINK",
              "IMAGE",
              "CODE_SPAN",
              "HEADINGS",
              "HORIZONTAL_LINE",
              "STRIKETHROUGH",
              "BLOCK_QUOTE",
              "SUPERSCRIPT",
              "SUBSCRIPT",
              "CODE_BLOCK"
            ]
          }
        },
        "noSupportedFormats": {
          "type": "boolean",
          "description": "A flag determining if this type supports no rich text formats."
        }
      },
      "additionalProperties": false
    },
    "richTextV2Type": {
      "type": "object",
      "description": "A Rich Text type, which contains a text that can be decorated with common formatting options such as bold and italics. Updated version of Rich Text Type Built on Meta\u0027s Lexical library.",
      "properties": {
        "minLength": {
          "type": "integer",
          "description": "The minimum length of the text.",
          "minimum": 0
        },
        "maxLength": {
          "type": "integer",
          "description": "The maximum length of the text.",
          "minimum": 0
        },
        "supportedFormatFilter": {
          "type": "object",
          "description": "The supported formats of the type",
          "properties": {
            "supportedFormats": {
              "type": "array",
              "description": "List of supported rich text v2 formats.",
              "items": {
                "type": "string",
                "description": "Supported rich text v2 format.",
                "enum": [
                  "BOLD",
                  "ITALICS",
                  "UNDERLINE",
                  "BULLETED_LIST",
                  "NUMBERED_LIST",
                  "HYPERLINK",
                  "IMAGE",
                  "CODE_SPAN",
                  "HEADINGS",
                  "HORIZONTAL_LINE",
                  "STRIKETHROUGH",
                  "BLOCK_QUOTE",
                  "SUPERSCRIPT",
                  "SUBSCRIPT",
                  "CODE_BLOCK",
                  "TABLE",
                  "HIGHLIGHT",
                  "TEXT_COLOR",
                  "ALIGN"
                ]
              }
            }
          },
          "additionalProperties": false
        },
        "usePrivateUrls": {
          "type": "boolean",
          "description": "If true, any Images or Files uploaded to this field will be hosted via a secure URL that is not publicly accessible. This is only recommended for content that will be integrating with authorized experiences."
        }
      },
      "additionalProperties": false
    },
    "markdownType": {
      "type": "object",
      "description": "A Markdown type, which contains a text that can be formatted using the Markdown markup language.",
      "properties": {
        "minLength": {
          "type": "integer",
          "description": "The minimum length of the text.",
          "minimum": 0
        },
        "maxLength": {
          "type": "integer",
          "description": "The maximum length of the text.",
          "minimum": 0
        }
      },
      "additionalProperties": false
    },
    "stringType": {
      "type": "object",
      "description": "A String type.",
      "properties": {
        "stereotype": {
          "type": "string",
          "description": "The stereotype of the value for this field type, which can be a single-line text (SIMPLE), multiline text (MULTILINE), url (URL) or a slug type (SLUG).",
          "enum": [
            "SIMPLE",
            "MULTILINE",
            "URL",
            "SLUG"
          ]
        },
        "minLength": {
          "type": "integer",
          "description": "The minimum length of the text.",
          "minimum": 0
        },
        "maxLength": {
          "type": "integer",
          "description": "The maximum length of the text.",
          "minimum": 0
        }
      },
      "required": [
        "stereotype"
      ],
      "additionalProperties": false
    },
    "structType": {
      "type": "object",
      "description": "A Struct type which contains a group of subfields that each have a unique subfield ID.",
      "properties": {
        "property": {
          "type": "array",
          "description": "List of subfields of the struct type.",
          "items": {
            "type": "object",
            "description": "A subfield of the struct type.",
            "properties": {
              "name": {
                "type": "string",
                "description": "The name of the subfield."
              },
              "displayName": {
                "type": "string",
                "description": "The display name of the subfield."
              },
              "displayNameTranslation": {
                "type": "array",
                "description": "Translations of the displayName for different locale codes.",
                "items": {
                  "$ref": "#/definitions/translation"
                }
              },
              "isRequired": {
                "type": "boolean",
                "description": "Flag that determines if this subfield is required."
              },
              "typeId": {
                "type": "string",
                "description": "The type ID of the subfield.",
                "format": "km/field-type"
              },
              "type": {
                "$ref": "#/definitions/type"
              }
            },
            "required": [
              "name",
              "isRequired",
              "typeId"
            ],
            "additionalProperties": false
          },
          "minItems": 1
        }
      },
      "required": [
        "property"
      ],
      "additionalProperties": false
    },
    "videoType": {
      "type": "object",
      "description": "A Video type.",
      "properties": {
        "isSimpleVideo": {
          "type": "boolean",
          "description": "A flag determining if the video is simple or complex. A simple video contains a source url a video. A complex image contains a simple video and a description."
        },
        "descriptionType": {
          "type": "object",
          "description": "Type of description of the video.",
          "properties": {
            "stereotype": {
              "type": "string",
              "description": "The stereotype of the description of the video.",
              "enum": [
                "MULTILINE"
              ]
            },
            "minLength": {
              "type": "integer",
              "description": "Minimum length of the description.",
              "minimum": 0
            },
            "maxLength": {
              "type": "integer",
              "description": "Maximum length of the description.",
              "minimum": 0
            }
          },
          "required": [
            "stereotype"
          ]
        }
      },
      "additionalProperties": false,
      "allOf": [
        {
          "if": {
            "properties": {
              "isSimpleVideo": {
                "const": true
              }
            },
            "required": [
              "isSimpleVideo"
            ]
          },
          "then": {
            "not": {
              "required": [
                "descriptionType"
              ]
            }
          }
        },
        {
          "if": {
            "properties": {
              "isSimpleVideo": {
                "const": false
              }
            },
            "required": [
              "isSimpleVideo"
            ]
          },
          "then": {
            "required": [
              "descriptionType"
            ]
          }
        }
      ]
    },
    "translation": {
      "type": "object",
      "properties": {
        "localeCode": {
          "type": "string",
          "description": "The locale code of the translation."
        },
        "value": {
          "type": "string",
          "description": "The value of the translation."
        }
      },
      "required": [
        "localeCode",
        "value"
      ]
    }
  }
}