{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/emporix/json-schema/emporix-product-template-update-schema.json",
  "title": "productTemplateUpdate",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/emporix-product-templates-api-openapi.yml#/components/schemas/productTemplateUpdate",
  "allOf": [
    {
      "$ref": "#/$defs/productTemplateBase"
    },
    {
      "type": "object",
      "properties": {
        "metadata": {
          "type": "object",
          "properties": {
            "version": {
              "type": "number",
              "description": "Version of the object. The value is required while product template update."
            }
          },
          "required": [
            "version"
          ]
        }
      }
    }
  ],
  "required": [
    "name",
    "attributes",
    "metadata"
  ],
  "$defs": {
    "productTemplateAttribute": {
      "title": "productTemplateAttribute",
      "type": "object",
      "properties": {
        "key": {
          "type": "string",
          "description": "An identifier of the attribute. The key is used as a field name in a product instance created based on the product template. The key can contain only alphanumeric characters. "
        },
        "name": {
          "type": "object",
          "additionalProperties": {
            "type": "string"
          },
          "description": "Localized resource name in a form of a map of translations."
        },
        "type": {
          "type": "string",
          "description": "Attribute type. Correct values: `TEXT`, `NUMBER`, `BOOLEAN`, `DATETIME`. Regardless of the chosen type, the defaultValue and values fields are validated. The DATETIME values must be compliant with the ISO 8601 standard, for example: 2022-03-31T09:52:15.423Z."
        },
        "metadata": {
          "type": "object",
          "description": "Metadata contains additional information about the attribute.",
          "properties": {
            "mandatory": {
              "type": "boolean",
              "description": "Indicates whether the attribute should be treated as a mandatory."
            },
            "variantAttribute": {
              "type": "boolean",
              "description": "Indicates whether the attribute is a variant-specific attribute. Variant attributes are taken into account during variants creation.\nIf the value is set to true, then the 'values' array cannot be null."
            },
            "defaultValue": {
              "description": "The attribute stores a default value for the attribute.",
              "oneOf": [
                {
                  "type": "string"
                },
                {
                  "type": "boolean"
                },
                {
                  "type": "number"
                }
              ]
            }
          }
        },
        "values": {
          "allOf": [
            {
              "$ref": "#/$defs/values"
            },
            {
              "type": "object",
              "description": "If the values are populated then the attribute behaves as an enum property. In other words, the attribute in a product instance can contain only values mentioned in this array. For each\nattribute the value should consist of object with key and localized names."
            }
          ]
        }
      },
      "required": [
        "key",
        "name",
        "type",
        "metadata"
      ]
    },
    "productTemplateBase": {
      "type": "object",
      "properties": {
        "name": {
          "type": "object",
          "description": "Localized product template name in a form of a map of translations.",
          "additionalProperties": {
            "type": "string"
          }
        },
        "attributes": {
          "type": "array",
          "description": "List of attributes related to the product template.",
          "items": {
            "$ref": "#/$defs/productTemplateAttribute"
          }
        }
      },
      "required": [
        "name",
        "attributes"
      ]
    },
    "value": {
      "type": "object",
      "properties": {
        "key": {
          "oneOf": [
            {
              "type": "string"
            },
            {
              "type": "number"
            },
            {
              "type": "boolean"
            }
          ]
        }
      }
    },
    "values": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/value"
      }
    }
  }
}