{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/atlar/json-schema/atlar-entity-jsonpatch-request-schema.json",
  "title": "EntityJSONPatchRequest",
  "description": "JSON Patch Request",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/atlar-entities-api-openapi.yml#/components/schemas/EntityJSONPatchRequest",
  "type": "array",
  "items": {
    "oneOf": [
      {
        "$ref": "#/$defs/EntityJSONPatchReplaceLegalName"
      },
      {
        "$ref": "#/$defs/EntityJSONPatchReplaceAlias"
      },
      {
        "$ref": "#/$defs/EntityJSONPatchRemoveAlias"
      },
      {
        "$ref": "#/$defs/EntityJSONPatchReplaceNationalIdentifier"
      },
      {
        "$ref": "#/$defs/EntityJSONPatchRemoveNationalIdentifier"
      },
      {
        "$ref": "#/$defs/EntityJSONPatchReplaceAddress"
      },
      {
        "$ref": "#/$defs/EntityJSONPatchRemoveAddress"
      },
      {
        "$ref": "#/$defs/EntityJSONPatchReplaceParent"
      },
      {
        "$ref": "#/$defs/EntityJSONPatchRemoveParent"
      }
    ]
  },
  "$defs": {
    "Address": {
      "description": "Postal address.",
      "type": "object",
      "properties": {
        "country": {
          "$ref": "#/$defs/CountryCode",
          "x-go-type-skip-optional-pointer": true
        },
        "countrySubdivision": {
          "$ref": "#/$defs/CountrySubdivision",
          "x-go-type-skip-optional-pointer": true
        },
        "city": {
          "type": "string",
          "maxLength": 64
        },
        "postalCode": {
          "type": "string",
          "maxLength": 16
        },
        "streetName": {
          "type": "string",
          "maxLength": 64
        },
        "streetNumber": {
          "type": "string",
          "maxLength": 16
        }
      }
    },
    "CountryCode": {
      "type": "string",
      "description": "Two-letter ISO 3166-1 alpha2 country code.",
      "minLength": 2,
      "maxLength": 2,
      "pattern": "^[A-Z]{2,2}$"
    },
    "CountrySubdivision": {
      "type": "string",
      "description": "Country subdivision code (second part of the ISO 3166-2 code).\nE.g. state code `CA` for the state of California in the USA, `ON` for the province of Ontario in Canada, `NSW` for the state of New South Wales in Australia.\nISO 3166-2 codes can be found on the ISO website, for example, for the USA: https://www.iso.org/obp/ui/#iso:code:3166:US.\nIn the USA the state code is required for domestic payments, in Canada the province code is required for domestic payments.",
      "maxLength": 6,
      "pattern": "^[A-Z]{2,2}-[A-Z0-9]{1,3}$"
    },
    "EntityJSONPatchRemoveAddress": {
      "description": "Remove address.",
      "type": "object",
      "properties": {
        "op": {
          "type": "string",
          "enum": [
            "remove"
          ]
        },
        "path": {
          "type": "string",
          "enum": [
            "/address"
          ]
        }
      },
      "additionalProperties": false,
      "required": [
        "op",
        "path"
      ]
    },
    "EntityJSONPatchRemoveAlias": {
      "description": "Remove alias.",
      "type": "object",
      "properties": {
        "op": {
          "type": "string",
          "enum": [
            "remove"
          ]
        },
        "path": {
          "type": "string",
          "enum": [
            "/alias"
          ]
        }
      },
      "additionalProperties": false,
      "required": [
        "op",
        "path"
      ]
    },
    "EntityJSONPatchRemoveNationalIdentifier": {
      "description": "Remove national identifier.",
      "type": "object",
      "properties": {
        "op": {
          "type": "string",
          "enum": [
            "remove"
          ]
        },
        "path": {
          "type": "string",
          "enum": [
            "/nationalIdentifier"
          ]
        }
      },
      "additionalProperties": false,
      "required": [
        "op",
        "path"
      ]
    },
    "EntityJSONPatchRemoveParent": {
      "description": "Remove parent.",
      "type": "object",
      "properties": {
        "op": {
          "type": "string",
          "enum": [
            "remove"
          ]
        },
        "path": {
          "type": "string",
          "enum": [
            "/parentId"
          ]
        }
      },
      "additionalProperties": false,
      "required": [
        "op",
        "path"
      ]
    },
    "EntityJSONPatchReplaceAddress": {
      "description": "Set the address.",
      "type": "object",
      "properties": {
        "op": {
          "type": "string",
          "enum": [
            "replace"
          ]
        },
        "path": {
          "type": "string",
          "enum": [
            "/address"
          ]
        },
        "value": {
          "$ref": "#/$defs/Address"
        }
      },
      "additionalProperties": false,
      "required": [
        "op",
        "path",
        "value"
      ]
    },
    "EntityJSONPatchReplaceAlias": {
      "description": "Set alias.",
      "type": "object",
      "properties": {
        "op": {
          "type": "string",
          "enum": [
            "replace"
          ]
        },
        "path": {
          "type": "string",
          "enum": [
            "/alias"
          ]
        },
        "value": {
          "type": "string",
          "minLength": 1,
          "maxLength": 255
        }
      },
      "additionalProperties": false,
      "required": [
        "op",
        "path",
        "value"
      ]
    },
    "EntityJSONPatchReplaceLegalName": {
      "description": "Set legal name.",
      "type": "object",
      "properties": {
        "op": {
          "type": "string",
          "enum": [
            "replace"
          ]
        },
        "path": {
          "type": "string",
          "enum": [
            "/legalName"
          ]
        },
        "value": {
          "type": "string",
          "minLength": 1,
          "maxLength": 255
        }
      },
      "additionalProperties": false,
      "required": [
        "op",
        "path",
        "value"
      ]
    },
    "EntityJSONPatchReplaceNationalIdentifier": {
      "description": "Set the national identifier.",
      "type": "object",
      "properties": {
        "op": {
          "type": "string",
          "enum": [
            "replace"
          ]
        },
        "path": {
          "type": "string",
          "enum": [
            "/nationalIdentifier"
          ]
        },
        "value": {
          "$ref": "#/$defs/NationalIdentifier"
        }
      },
      "additionalProperties": false,
      "required": [
        "op",
        "path",
        "value"
      ]
    },
    "EntityJSONPatchReplaceParent": {
      "description": "Change the parent entity.",
      "type": "object",
      "properties": {
        "op": {
          "type": "string",
          "enum": [
            "replace"
          ]
        },
        "path": {
          "type": "string",
          "enum": [
            "/parentId"
          ]
        },
        "value": {
          "type": "string",
          "minLength": 32,
          "maxLength": 64
        }
      },
      "additionalProperties": false,
      "required": [
        "op",
        "path",
        "value"
      ]
    },
    "MarketCode": {
      "type": "string",
      "description": "Two-letter ISO 3166-1 alpha2 country code.",
      "minLength": 2,
      "maxLength": 2,
      "pattern": "^[A-Z]{2,2}$"
    },
    "NationalIdentifier": {
      "type": "object",
      "properties": {
        "type": {
          "type": "string",
          "description": "Type of the national identifier.",
          "enum": [
            "CIVIC",
            "COMPANY"
          ]
        },
        "market": {
          "$ref": "#/$defs/MarketCode"
        },
        "number": {
          "type": "string",
          "description": "The identifier itself."
        }
      },
      "required": [
        "type",
        "market",
        "number"
      ]
    }
  }
}