{
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "$id": "https://schemas.finqu.com/ucp/schemas/2026-11-24/customizations.json",
    "name": "com.finqu.schemas.shopping.customizations",
    "version": "2026-11-24",
    "title": "Finqu Product Customizations Extension",
    "description": "Finqu-specific extension for product customizations. Customizations allow buyers to personalize products beyond standard variant options (e.g., engraving text, gift wrapping, color choices for sub-components). Customization definitions are returned in variant.metadata.customizations from catalog operations. When submitting line_items to cart or checkout, include customizations[] array with selections.",
    "requires": {
        "protocol": {
            "min": "2026-08-25",
            "max": "2026-08-25"
        }
    },
    "$defs": {
        "customization_group": {
            "type": "object",
            "title": "Customization Group",
            "description": "A group of customization options for a product variant. Groups can be required (must have at least one selection) or optional.",
            "required": [
                "id",
                "title",
                "required",
                "input_type",
                "options"
            ],
            "properties": {
                "id": {
                    "type": "string",
                    "description": "Unique group identifier."
                },
                "title": {
                    "type": "string",
                    "description": "Display title for the group (e.g., 'Engraving', 'Gift Wrapping')."
                },
                "required": {
                    "type": "boolean",
                    "description": "Whether at least one option must be selected. If true, the cart/checkout will be rejected without a selection from this group."
                },
                "input_type": {
                    "type": "string",
                    "description": "Input type hint. Common values: 'select' (pick from options), 'text' (free text input), 'checkbox' (toggle).",
                    "examples": [
                        "select",
                        "text",
                        "checkbox"
                    ]
                },
                "options": {
                    "type": "array",
                    "items": {
                        "$ref": "#/$defs/customization_option"
                    },
                    "description": "Available options within this group."
                }
            }
        },
        "customization_option": {
            "type": "object",
            "title": "Customization Option",
            "description": "A single selectable/inputtable option within a customization group.",
            "required": [
                "id",
                "title"
            ],
            "properties": {
                "id": {
                    "type": "string",
                    "description": "Unique option identifier. Use this as the 'id' field in line_items[].customizations[]."
                },
                "title": {
                    "type": "string",
                    "description": "Display title for the option."
                },
                "price": {
                    "type": "integer",
                    "description": "Additional price in minor currency units (e.g., cents). 0 or omitted means no surcharge."
                },
                "min_length": {
                    "type": "integer",
                    "description": "Minimum character length for text and textarea inputs. Present only when greater than 0. Choice options (select, radio, checkbox) have no character limit; a stored length of 0 is omitted and must not block selecting that option."
                },
                "max_length": {
                    "type": "integer",
                    "description": "Maximum character length for text and textarea inputs. Present only when greater than 0. A stored value of 0 means no limit and is omitted. Choice labels such as a size are not checked against this field."
                },
                "child_group": {
                    "$ref": "#/$defs/customization_group",
                    "description": "Nested sub-group activated when this option is selected. Enables hierarchical customization trees."
                }
            }
        },
        "customization_selection": {
            "type": "object",
            "title": "Customization Selection",
            "description": "A buyer's selection for a customization option, submitted as part of a line item.",
            "required": [
                "id",
                "value"
            ],
            "properties": {
                "id": {
                    "type": "string",
                    "description": "The option ID from the customization group (metadata.customizations[].options[].id)."
                },
                "value": {
                    "type": "string",
                    "description": "For select, radio, and checkbox: the option id or the option title (for example \"M\"). Character limits do not apply to choices. For text and textarea: the buyer's text, which must respect min_length and max_length when those are greater than 0."
                }
            },
            "additionalProperties": false
        },
        "line_item_customizations": {
            "type": "array",
            "title": "Line Item Customizations",
            "description": "Array of customization selections for a line item. Include one entry per selected customization option. For required groups, at least one option from that group must be included.",
            "items": {
                "$ref": "#/$defs/customization_selection"
            }
        },
        "customized_line_items": {
            "type": "object",
            "properties": {
                "line_items": {
                    "type": "array",
                    "items": {
                        "type": "object",
                        "properties": {
                            "customizations": {
                                "$ref": "#/$defs/line_item_customizations"
                            }
                        }
                    }
                }
            }
        },
        "dev.ucp.shopping.cart": {
            "allOf": [
                { "$ref": "https://ucp.dev/2026-08-25/schemas/shopping/cart.json" },
                { "$ref": "#/$defs/customized_line_items" }
            ]
        },
        "dev.ucp.shopping.checkout": {
            "allOf": [
                { "$ref": "https://ucp.dev/2026-08-25/schemas/shopping/checkout.json" },
                { "$ref": "#/$defs/customized_line_items" }
            ]
        }
    }
}
