{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/foundryims-com/json-schema/foundryims-com-storefront-product-detail-dto-schema.json",
  "title": "StorefrontProductDetailDto",
  "x-generated": "2026-11-08",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/foundryims-com-openapi.json#/components/schemas/StorefrontProductDetailDto",
  "type": "object",
  "properties": {
    "id": {
      "type": "string"
    },
    "slug": {
      "type": [
        "string",
        "null"
      ]
    },
    "name": {
      "type": "string"
    },
    "description": {
      "type": [
        "string",
        "null"
      ]
    },
    "metaTitle": {
      "type": "string",
      "description": "Resolved SEO <title>; falls back to the product name when unset."
    },
    "metaDescription": {
      "type": "string",
      "description": "Resolved SEO meta description; falls back to a description excerpt when unset."
    },
    "brand": {
      "nullable": true,
      "allOf": [
        {
          "$ref": "#/$defs/IdNameDto"
        }
      ]
    },
    "category": {
      "nullable": true,
      "allOf": [
        {
          "$ref": "#/$defs/IdNameDto"
        }
      ]
    },
    "categories": {
      "description": "Every category the product is in, primary (`category`) first.",
      "type": "array",
      "items": {
        "$ref": "#/$defs/IdNameDto"
      }
    },
    "thumbnail": {
      "type": [
        "string",
        "null"
      ]
    },
    "priceFrom": {
      "type": "number"
    },
    "compareAtPriceFrom": {
      "type": [
        "number",
        "null"
      ],
      "description": "Set only when a variant is on sale (compare-at above price)."
    },
    "currency": {
      "type": "string"
    },
    "featured": {
      "type": "boolean"
    },
    "displayOrder": {
      "type": "number"
    },
    "inStock": {
      "type": "boolean"
    },
    "availableQuantity": {
      "type": "number",
      "description": "Aggregate on-hand across tracked variants (on-hand minus reserved). Untracked/made-to-order variants report 0 here but still set inStock=true — use inStock for availability, this for \"N left\"."
    },
    "variantCount": {
      "type": "number"
    },
    "customFields": {
      "description": "Product-level custom fields flagged visible on storefront.",
      "type": "array",
      "items": {
        "$ref": "#/$defs/StorefrontCustomFieldDto"
      }
    },
    "variants": {
      "description": "Full variant rows — present only when the list is requested with `?include=variants`. Same shape as the product-detail response.",
      "type": "array",
      "items": {
        "$ref": "#/$defs/StorefrontVariantDto"
      }
    },
    "createdAt": {
      "type": "string",
      "format": "date-time"
    },
    "updatedAt": {
      "type": "string",
      "format": "date-time"
    },
    "options": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/ProductOptionDto"
      }
    },
    "images": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/ImageRefDto"
      }
    },
    "addOns": {
      "description": "Optional extra products offered on this page. Each choice is sold as its own line for `variantId` at `price`.",
      "type": "array",
      "items": {
        "$ref": "#/$defs/StorefrontAddOnGroupDto"
      }
    },
    "customerInputs": {
      "description": "Fields the buyer fills in (e.g. engine serial number). Send values in line metadata.",
      "type": "array",
      "items": {
        "$ref": "#/$defs/StorefrontCustomerInputDto"
      }
    }
  },
  "required": [
    "id",
    "slug",
    "name",
    "description",
    "metaTitle",
    "metaDescription",
    "brand",
    "category",
    "categories",
    "thumbnail",
    "priceFrom",
    "compareAtPriceFrom",
    "currency",
    "featured",
    "displayOrder",
    "inStock",
    "availableQuantity",
    "variantCount",
    "customFields",
    "createdAt",
    "updatedAt",
    "options",
    "images",
    "addOns",
    "customerInputs"
  ],
  "$defs": {
    "AddOnAppliesToRuleDto": {
      "type": "object",
      "properties": {
        "option": {
          "type": "string"
        },
        "values": {
          "type": "array",
          "items": {
            "type": "string"
          }
        }
      },
      "required": [
        "option",
        "values"
      ]
    },
    "IdNameDto": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string"
        },
        "name": {
          "type": "string"
        }
      },
      "required": [
        "id",
        "name"
      ]
    },
    "ImageRefDto": {
      "type": "object",
      "properties": {
        "url": {
          "type": "string"
        }
      },
      "required": [
        "url"
      ]
    },
    "OptionValueDto": {
      "type": "object",
      "properties": {
        "name": {
          "type": "string"
        },
        "value": {
          "type": "string"
        }
      },
      "required": [
        "name",
        "value"
      ]
    },
    "OptionValueSetDto": {
      "type": "object",
      "properties": {
        "name": {
          "type": "string"
        },
        "values": {
          "type": "array",
          "items": {
            "type": "string"
          }
        }
      },
      "required": [
        "name",
        "values"
      ]
    },
    "ProductOptionDto": {
      "type": "object",
      "properties": {
        "name": {
          "type": "string"
        },
        "position": {
          "type": "number"
        },
        "values": {
          "type": "array",
          "items": {
            "type": "string"
          }
        }
      },
      "required": [
        "name",
        "position",
        "values"
      ]
    },
    "StorefrontAddOnChoiceDto": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "description": "Add-on id — echo it back on the cart line."
        },
        "variantId": {
          "type": "string",
          "description": "The variant sold as its own order line."
        },
        "sku": {
          "type": "string"
        },
        "name": {
          "type": "string"
        },
        "price": {
          "type": "number",
          "description": "Add-on price override, else the variant's listed price on this channel."
        },
        "inStock": {
          "type": "boolean"
        },
        "availableQuantity": {
          "type": "number"
        },
        "quantityMode": {
          "type": "string",
          "enum": [
            "PER_UNIT",
            "SELECTABLE"
          ],
          "description": "PER_UNIT: one per main unit. SELECTABLE: buyer picks 1..maxPerUnit per main unit."
        },
        "maxPerUnit": {
          "type": "number"
        },
        "appliesTo": {
          "description": "Every rule must match the selected variant's optionValues. Empty → offered on every variant.",
          "type": "array",
          "items": {
            "$ref": "#/$defs/AddOnAppliesToRuleDto"
          }
        }
      },
      "required": [
        "id",
        "variantId",
        "sku",
        "name",
        "price",
        "inStock",
        "availableQuantity",
        "quantityMode",
        "maxPerUnit",
        "appliesTo"
      ]
    },
    "StorefrontAddOnGroupDto": {
      "type": "object",
      "properties": {
        "label": {
          "type": "string"
        },
        "position": {
          "type": "number"
        },
        "choices": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/StorefrontAddOnChoiceDto"
          }
        }
      },
      "required": [
        "label",
        "position",
        "choices"
      ]
    },
    "StorefrontCustomFieldDto": {
      "type": "object",
      "properties": {
        "key": {
          "type": "string",
          "description": "Stable machine key."
        },
        "label": {
          "type": "string"
        },
        "value": {
          "type": "object",
          "description": "Typed value (string | number | boolean | array | object)."
        },
        "unit": {
          "type": "string",
          "description": "Display unit (NUMBER fields), omitted when unset."
        },
        "type": {
          "type": "string",
          "enum": [
            "text",
            "number",
            "boolean",
            "enum",
            "date",
            "url",
            "json"
          ]
        },
        "group": {
          "type": "string",
          "description": "Spec-table section, omitted when ungrouped."
        },
        "displayOrder": {
          "type": "number",
          "description": "Sort order within the spec table."
        }
      },
      "required": [
        "key",
        "label",
        "value",
        "type",
        "displayOrder"
      ]
    },
    "StorefrontCustomerInputDto": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string"
        },
        "label": {
          "type": "string"
        },
        "inputType": {
          "type": "string",
          "enum": [
            "TEXT",
            "INTEGER",
            "MULTI_LINE_TEXT",
            "DROPDOWN",
            "RADIO",
            "CHECKBOX"
          ],
          "description": "CHECKBOX values are \"Yes\"/\"No\"; DROPDOWN and RADIO values must be one of `choices`."
        },
        "choices": {
          "description": "DROPDOWN / RADIO options, in order; empty otherwise.",
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "required": {
          "type": "boolean"
        },
        "minLength": {
          "type": [
            "number",
            "null"
          ]
        },
        "maxLength": {
          "type": [
            "number",
            "null"
          ]
        },
        "minValue": {
          "type": [
            "number",
            "null"
          ]
        },
        "maxValue": {
          "type": [
            "number",
            "null"
          ]
        }
      },
      "required": [
        "id",
        "label",
        "inputType",
        "choices",
        "required",
        "minLength",
        "maxLength",
        "minValue",
        "maxValue"
      ]
    },
    "StorefrontVariantDto": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string"
        },
        "sku": {
          "type": "string"
        },
        "name": {
          "type": "string"
        },
        "price": {
          "type": "number",
          "description": "What the buyer pays now — the sale price while a sale is on."
        },
        "regularPrice": {
          "type": "number",
          "description": "The regular price; equals price when not on sale."
        },
        "onSale": {
          "type": "boolean",
          "description": "True while a sale window is open on this listing."
        },
        "saleEndsAt": {
          "type": [
            "string",
            "null"
          ],
          "description": "ISO timestamp the sale ends, when one is set."
        },
        "compareAtPrice": {
          "type": [
            "number",
            "null"
          ],
          "description": "\"Was\"/MSRP price. While on sale this is the regular price."
        },
        "map": {
          "type": [
            "number",
            "null"
          ],
          "description": "Minimum advertised price."
        },
        "upc": {
          "type": [
            "string",
            "null"
          ]
        },
        "gtin": {
          "type": [
            "string",
            "null"
          ]
        },
        "mpn": {
          "type": [
            "string",
            "null"
          ]
        },
        "weight": {
          "type": [
            "number",
            "null"
          ]
        },
        "inStock": {
          "type": "boolean"
        },
        "availableQuantity": {
          "type": "number"
        },
        "optionValues": {
          "description": "One value per option: the variant's primary. Use optionValueSets to see every value a family child answers.",
          "type": "array",
          "items": {
            "$ref": "#/$defs/OptionValueDto"
          }
        },
        "optionValueSets": {
          "description": "Every value per option, primary first. A family child may answer several choices on one option (e.g. a part that fits several year ranges); it matches a customer's answers when each answer is in that option's values.",
          "type": "array",
          "items": {
            "$ref": "#/$defs/OptionValueSetDto"
          }
        },
        "images": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/ImageRefDto"
          }
        },
        "customFields": {
          "description": "This variant's effective custom fields (variant value overrides product).",
          "type": "array",
          "items": {
            "$ref": "#/$defs/StorefrontCustomFieldDto"
          }
        }
      },
      "required": [
        "id",
        "sku",
        "name",
        "price",
        "regularPrice",
        "onSale",
        "saleEndsAt",
        "compareAtPrice",
        "map",
        "upc",
        "gtin",
        "mpn",
        "weight",
        "inStock",
        "availableQuantity",
        "optionValues",
        "optionValueSets",
        "images",
        "customFields"
      ]
    }
  }
}