{
 "openapi": "3.1.0",
 "info": {
  "title": "olyone Storefront API",
  "version": "1.0.0",
  "description": "Build a shop's own website on olyone. Read the shop with a publishable site key, keep the bag on the site, and hand the customer to olyone's checkout. Fields are only ever added. Full reference: https://olyone.lk/developers/storefront-api.md"
 },
 "servers": [
  {
   "url": "https://api.olyone.lk/v1/storefront"
  }
 ],
 "security": [
  {
   "siteKey": []
  }
 ],
 "paths": {
  "/shop": {
   "get": {
    "operationId": "getShop",
    "summary": "The shop: name, brand, contact, policies, delivery fee",
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Shop"
        }
       }
      }
     },
     "401": {
      "$ref": "#/components/responses/Error"
     },
     "403": {
      "$ref": "#/components/responses/Error"
     },
     "404": {
      "$ref": "#/components/responses/Error"
     },
     "429": {
      "$ref": "#/components/responses/Error"
     }
    }
   }
  },
  "/products": {
   "get": {
    "operationId": "listProducts",
    "summary": "Product cards, paged",
    "parameters": [
     {
      "name": "limit",
      "in": "query",
      "schema": {
       "type": "integer",
       "minimum": 1,
       "maximum": 50,
       "default": 24
      }
     },
     {
      "name": "cursor",
      "in": "query",
      "schema": {
       "type": "string"
      },
      "description": "The `next` value from the page before"
     },
     {
      "name": "q",
      "in": "query",
      "schema": {
       "type": "string"
      },
      "description": "Search words"
     },
     {
      "name": "collection",
      "in": "query",
      "schema": {
       "type": "string",
       "format": "uuid"
      },
      "description": "Only this collection's products"
     },
     {
      "name": "tag",
      "in": "query",
      "schema": {
       "type": "string"
      },
      "description": "Only products carrying this tag (case-insensitive)"
     },
     {
      "name": "brand",
      "in": "query",
      "schema": {
       "type": "string"
      },
      "description": "Only products by this brand (case-insensitive)"
     }
    ],
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/ProductPage"
        }
       }
      }
     },
     "401": {
      "$ref": "#/components/responses/Error"
     },
     "403": {
      "$ref": "#/components/responses/Error"
     },
     "404": {
      "$ref": "#/components/responses/Error"
     },
     "429": {
      "$ref": "#/components/responses/Error"
     }
    }
   }
  },
  "/products/{idOrHandle}": {
   "get": {
    "operationId": "getProduct",
    "summary": "One product by id or handle",
    "parameters": [
     {
      "name": "idOrHandle",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Product"
        }
       }
      }
     },
     "401": {
      "$ref": "#/components/responses/Error"
     },
     "403": {
      "$ref": "#/components/responses/Error"
     },
     "404": {
      "$ref": "#/components/responses/Error"
     },
     "429": {
      "$ref": "#/components/responses/Error"
     }
    }
   }
  },
  "/collections": {
   "get": {
    "operationId": "listCollections",
    "summary": "The shop's collections",
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/CollectionList"
        }
       }
      }
     },
     "401": {
      "$ref": "#/components/responses/Error"
     },
     "403": {
      "$ref": "#/components/responses/Error"
     },
     "404": {
      "$ref": "#/components/responses/Error"
     },
     "429": {
      "$ref": "#/components/responses/Error"
     }
    }
   }
  },
  "/collections/{id}": {
   "get": {
    "operationId": "getCollection",
    "summary": "One collection with its product cards",
    "parameters": [
     {
      "name": "id",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string",
       "format": "uuid"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Collection"
        }
       }
      }
     },
     "401": {
      "$ref": "#/components/responses/Error"
     },
     "403": {
      "$ref": "#/components/responses/Error"
     },
     "404": {
      "$ref": "#/components/responses/Error"
     },
     "429": {
      "$ref": "#/components/responses/Error"
     }
    }
   }
  },
  "/reviews": {
   "get": {
    "operationId": "listReviews",
    "summary": "Published shop reviews",
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Reviews"
        }
       }
      }
     },
     "401": {
      "$ref": "#/components/responses/Error"
     },
     "403": {
      "$ref": "#/components/responses/Error"
     },
     "404": {
      "$ref": "#/components/responses/Error"
     },
     "429": {
      "$ref": "#/components/responses/Error"
     }
    }
   }
  },
  "/bag": {
   "post": {
    "operationId": "priceBag",
    "summary": "Price a bag and get the link into the shop's checkout. Nothing is saved; no stock is held.",
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/BagRequest"
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Bag"
        }
       }
      }
     },
     "401": {
      "$ref": "#/components/responses/Error"
     },
     "403": {
      "$ref": "#/components/responses/Error"
     },
     "404": {
      "$ref": "#/components/responses/Error"
     },
     "429": {
      "$ref": "#/components/responses/Error"
     },
     "400": {
      "$ref": "#/components/responses/Error"
     }
    }
   }
  },
  "/cart": {
   "post": {
    "operationId": "createCart",
    "summary": "Make a server-side cart (optional alternative to POST /bag). Keep its id.",
    "requestBody": {
     "required": false,
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/CartCreate"
       }
      }
     }
    },
    "responses": {
     "201": {
      "description": "The cart, priced now",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Cart"
        }
       }
      }
     },
     "400": {
      "$ref": "#/components/responses/Error"
     },
     "401": {
      "$ref": "#/components/responses/Error"
     },
     "403": {
      "$ref": "#/components/responses/Error"
     },
     "404": {
      "description": "code: cart_gone - the cart was checked out, expired, or never existed. Make a new one.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "$ref": "#/components/responses/Error"
     }
    }
   }
  },
  "/cart/{id}": {
   "get": {
    "operationId": "getCart",
    "summary": "A cart, priced now",
    "parameters": [
     {
      "name": "id",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string",
       "format": "uuid"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "The cart, priced now",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Cart"
        }
       }
      }
     },
     "400": {
      "$ref": "#/components/responses/Error"
     },
     "401": {
      "$ref": "#/components/responses/Error"
     },
     "403": {
      "$ref": "#/components/responses/Error"
     },
     "404": {
      "description": "code: cart_gone - the cart was checked out, expired, or never existed. Make a new one.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "$ref": "#/components/responses/Error"
     }
    }
   },
   "post": {
    "operationId": "updateCart",
    "summary": "Change a cart: add, set (0 removes), replace lines, set or clear the code and the note",
    "parameters": [
     {
      "name": "id",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string",
       "format": "uuid"
      }
     }
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/CartUpdate"
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "The cart, priced now",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Cart"
        }
       }
      }
     },
     "400": {
      "$ref": "#/components/responses/Error"
     },
     "401": {
      "$ref": "#/components/responses/Error"
     },
     "403": {
      "$ref": "#/components/responses/Error"
     },
     "404": {
      "description": "code: cart_gone - the cart was checked out, expired, or never existed. Make a new one.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "$ref": "#/components/responses/Error"
     }
    }
   }
  },
  "/tags": {
   "get": {
    "operationId": "listTags",
    "summary": "Every tag and brand on the products on sale, with counts",
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/TagList"
        }
       }
      }
     },
     "401": {
      "$ref": "#/components/responses/Error"
     },
     "403": {
      "$ref": "#/components/responses/Error"
     },
     "404": {
      "$ref": "#/components/responses/Error"
     },
     "429": {
      "$ref": "#/components/responses/Error"
     }
    }
   }
  }
 },
 "components": {
  "securitySchemes": {
   "siteKey": {
    "type": "apiKey",
    "in": "header",
    "name": "X-Olyone-Key",
    "description": "The shop's publishable site key (oly_pk_...). Made by the owner in olyone: Settings > Your own website."
   }
  },
  "responses": {
   "Error": {
    "description": "An error, with a message in plain words",
    "content": {
     "application/json": {
      "schema": {
       "$ref": "#/components/schemas/Error"
      }
     }
    }
   }
  },
  "schemas": {
   "Error": {
    "type": "object",
    "properties": {
     "statusCode": {
      "type": "integer"
     },
     "message": {
      "type": "string"
     },
     "code": {
      "type": "string",
      "description": "e.g. upgrade_required"
     }
    }
   },
   "Picture": {
    "type": [
     "object",
     "null"
    ],
    "properties": {
     "src": {
      "type": "string"
     },
     "srcset": {
      "type": [
       "string",
       "null"
      ]
     },
     "alt": {
      "type": "string"
     }
    },
    "required": [
     "src",
     "alt"
    ]
   },
   "Rating": {
    "type": [
     "object",
     "null"
    ],
    "properties": {
     "average": {
      "type": "number"
     },
     "count": {
      "type": "integer"
     }
    }
   },
   "ProductCard": {
    "type": "object",
    "properties": {
     "id": {
      "type": "string",
      "format": "uuid"
     },
     "handle": {
      "type": "string"
     },
     "name": {
      "type": "string"
     },
     "category": {
      "type": [
       "string",
       "null"
      ]
     },
     "price": {
      "type": "number",
      "description": "Starting price in LKR"
     },
     "compareAtPrice": {
      "type": [
       "number",
       "null"
      ]
     },
     "onSale": {
      "type": "boolean"
     },
     "available": {
      "type": "boolean"
     },
     "image": {
      "$ref": "#/components/schemas/Picture"
     },
     "rating": {
      "$ref": "#/components/schemas/Rating"
     },
     "options": {
      "type": "array",
      "items": {
       "type": "object",
       "properties": {
        "name": {
         "type": "string"
        },
        "type": {
         "type": "string",
         "enum": [
          "size",
          "color",
          "other"
         ]
        },
        "values": {
         "type": "array",
         "items": {
          "type": "object",
          "properties": {
           "value": {
            "type": "string"
           },
           "hex": {
            "type": [
             "string",
             "null"
            ]
           }
          }
         }
        }
       }
      }
     },
     "brand": {
      "type": [
       "string",
       "null"
      ],
      "description": "Who makes it - a maker, or a book's author"
     },
     "tags": {
      "type": "array",
      "items": {
       "type": "string"
      },
      "description": "The shop's own labels; [] when none"
     }
    },
    "required": [
     "id",
     "handle",
     "name",
     "price",
     "available"
    ]
   },
   "Review": {
    "type": "object",
    "properties": {
     "id": {
      "type": "string"
     },
     "rating": {
      "type": "integer"
     },
     "title": {
      "type": [
       "string",
       "null"
      ]
     },
     "body": {
      "type": "string"
     },
     "author": {
      "type": "string"
     },
     "verified": {
      "type": "boolean"
     },
     "photo": {
      "$ref": "#/components/schemas/Picture"
     },
     "reply": {
      "type": [
       "string",
       "null"
      ]
     },
     "product": {
      "type": [
       "string",
       "null"
      ]
     },
     "date": {
      "type": [
       "string",
       "null"
      ],
      "format": "date-time"
     }
    }
   },
   "Shop": {
    "type": "object",
    "properties": {
     "name": {
      "type": "string"
     },
     "url": {
      "type": "string",
      "format": "uri"
     },
     "currency": {
      "type": "string",
      "const": "LKR"
     },
     "opening": {
      "type": "boolean",
      "description": "true = not open yet: show Opening soon, no checkout"
     },
     "tagline": {
      "type": [
       "string",
       "null"
      ]
     },
     "description": {
      "type": [
       "string",
       "null"
      ]
     },
     "about": {
      "type": [
       "string",
       "null"
      ]
     },
     "brandColor": {
      "type": [
       "string",
       "null"
      ]
     },
     "logo": {
      "$ref": "#/components/schemas/Picture"
     },
     "banner": {
      "$ref": "#/components/schemas/Picture"
     },
     "contact": {
      "type": "object",
      "properties": {
       "phone": {
        "type": [
         "string",
         "null"
        ]
       },
       "whatsapp": {
        "type": [
         "string",
         "null"
        ]
       },
       "email": {
        "type": [
         "string",
         "null"
        ]
       },
       "instagram": {
        "type": [
         "string",
         "null"
        ]
       },
       "facebook": {
        "type": [
         "string",
         "null"
        ]
       },
       "tiktok": {
        "type": [
         "string",
         "null"
        ]
       }
      }
     },
     "policies": {
      "type": "object",
      "properties": {
       "refund": {
        "type": [
         "string",
         "null"
        ]
       },
       "privacy": {
        "type": [
         "string",
         "null"
        ]
       },
       "terms": {
        "type": [
         "string",
         "null"
        ]
       }
      }
     },
     "delivery": {
      "type": "object",
      "properties": {
       "fee": {
        "type": [
         "number",
         "null"
        ]
       },
       "freeOver": {
        "type": [
         "number",
         "null"
        ]
       }
      }
     },
     "rating": {
      "$ref": "#/components/schemas/Rating"
     }
    }
   },
   "ProductPage": {
    "type": "object",
    "properties": {
     "total": {
      "type": "integer"
     },
     "items": {
      "type": "array",
      "items": {
       "$ref": "#/components/schemas/ProductCard"
      }
     },
     "next": {
      "type": [
       "string",
       "null"
      ],
      "description": "Cursor for the next page; null on the last"
     }
    }
   },
   "Product": {
    "type": "object",
    "properties": {
     "id": {
      "type": "string",
      "format": "uuid"
     },
     "handle": {
      "type": "string"
     },
     "name": {
      "type": "string"
     },
     "description": {
      "type": [
       "string",
       "null"
      ],
      "description": "The shop's own words, as Markdown"
     },
     "category": {
      "type": [
       "string",
       "null"
      ]
     },
     "price": {
      "type": "number"
     },
     "compareAtPrice": {
      "type": [
       "number",
       "null"
      ]
     },
     "onSale": {
      "type": "boolean"
     },
     "available": {
      "type": "boolean"
     },
     "images": {
      "type": "array",
      "items": {
       "type": "object",
       "properties": {
        "src": {
         "type": "string"
        },
        "srcset": {
         "type": [
          "string",
          "null"
         ]
        },
        "alt": {
         "type": "string"
        },
        "optionValueId": {
         "type": [
          "string",
          "null"
         ]
        }
       }
      }
     },
     "options": {
      "type": "array",
      "items": {
       "type": "object",
       "properties": {
        "id": {
         "type": "string"
        },
        "name": {
         "type": "string"
        },
        "type": {
         "type": "string"
        },
        "values": {
         "type": "array",
         "items": {
          "type": "object",
          "properties": {
           "id": {
            "type": "string"
           },
           "value": {
            "type": "string"
           },
           "hex": {
            "type": [
             "string",
             "null"
            ]
           }
          }
         }
        }
       }
      }
     },
     "variants": {
      "type": "array",
      "description": "What a customer buys - send a variant's id to the bag",
      "items": {
       "type": "object",
       "properties": {
        "id": {
         "type": "string",
         "format": "uuid"
        },
        "label": {
         "type": [
          "string",
          "null"
         ]
        },
        "price": {
         "type": "number"
        },
        "available": {
         "type": "boolean"
        },
        "low": {
         "type": "boolean",
         "description": "Only a few left"
        },
        "optionValues": {
         "type": "object",
         "additionalProperties": {
          "type": "string"
         }
        }
       }
      }
     },
     "rating": {
      "$ref": "#/components/schemas/Rating"
     },
     "reviews": {
      "type": "array",
      "items": {
       "$ref": "#/components/schemas/Review"
      }
     },
     "brand": {
      "type": [
       "string",
       "null"
      ],
      "description": "Who makes it - a maker, or a book's author"
     },
     "tags": {
      "type": "array",
      "items": {
       "type": "string"
      },
      "description": "The shop's own labels; [] when none"
     },
     "descriptionHtml": {
      "type": [
       "string",
       "null"
      ],
      "description": "The same text as safe, ready-to-show HTML"
     },
     "fields": {
      "type": "array",
      "description": "The shop's own details it chose to show, in its order; [] when none",
      "items": {
       "$ref": "#/components/schemas/ProductField"
      }
     }
    }
   },
   "CollectionList": {
    "type": "object",
    "properties": {
     "items": {
      "type": "array",
      "items": {
       "type": "object",
       "properties": {
        "id": {
         "type": "string",
         "format": "uuid"
        },
        "name": {
         "type": "string"
        },
        "description": {
         "type": [
          "string",
          "null"
         ]
        },
        "image": {
         "$ref": "#/components/schemas/Picture"
        },
        "featured": {
         "type": "boolean"
        },
        "productCount": {
         "type": "integer"
        }
       }
      }
     }
    }
   },
   "Collection": {
    "type": "object",
    "properties": {
     "id": {
      "type": "string",
      "format": "uuid"
     },
     "name": {
      "type": "string"
     },
     "description": {
      "type": [
       "string",
       "null"
      ]
     },
     "image": {
      "$ref": "#/components/schemas/Picture"
     },
     "products": {
      "type": "array",
      "items": {
       "$ref": "#/components/schemas/ProductCard"
      }
     }
    }
   },
   "Reviews": {
    "type": "object",
    "properties": {
     "rating": {
      "$ref": "#/components/schemas/Rating"
     },
     "items": {
      "type": "array",
      "items": {
       "$ref": "#/components/schemas/Review"
      }
     }
    }
   },
   "BagRequest": {
    "type": "object",
    "required": [
     "items"
    ],
    "properties": {
     "items": {
      "type": "array",
      "minItems": 1,
      "maxItems": 50,
      "items": {
       "type": "object",
       "required": [
        "variantId",
        "qty"
       ],
       "properties": {
        "variantId": {
         "type": "string",
         "format": "uuid"
        },
        "qty": {
         "type": "integer",
         "minimum": 1,
         "maximum": 999
        }
       }
      }
     },
     "returnTo": {
      "type": "string",
      "format": "uri",
      "description": "Server-side calls only: the site the customer returns to. Must be on the key's list."
     },
     "discountCode": {
      "type": "string",
      "maxLength": 40,
      "description": "A code the customer typed on the site; carried into checkout when it is good"
     },
     "note": {
      "type": "string",
      "maxLength": 500,
      "description": "The customer's note for the shop; carried into checkout"
     }
    }
   },
   "Bag": {
    "type": "object",
    "properties": {
     "currency": {
      "type": "string",
      "const": "LKR"
     },
     "lines": {
      "type": "array",
      "items": {
       "type": "object",
       "properties": {
        "variantId": {
         "type": "string"
        },
        "productId": {
         "type": [
          "string",
          "null"
         ]
        },
        "name": {
         "type": "string"
        },
        "label": {
         "type": [
          "string",
          "null"
         ]
        },
        "price": {
         "type": "number"
        },
        "qty": {
         "type": "integer"
        },
        "lineTotal": {
         "type": "number"
        },
        "image": {
         "$ref": "#/components/schemas/Picture"
        },
        "available": {
         "type": "boolean"
        },
        "problem": {
         "type": [
          "string",
          "null"
         ],
         "enum": [
          "sold_out",
          "low_stock",
          "unavailable",
          null
         ]
        }
       }
      }
     },
     "subtotal": {
      "type": "number"
     },
     "deliveryFee": {
      "type": "number"
     },
     "discount": {
      "type": "number"
     },
     "discountLabel": {
      "type": [
       "string",
       "null"
      ]
     },
     "total": {
      "type": "number"
     },
     "canCheckout": {
      "type": "boolean"
     },
     "checkoutUrl": {
      "type": [
       "string",
       "null"
      ],
      "format": "uri",
      "description": "Send the customer here, unchanged"
     },
     "discountCode": {
      "type": [
       "string",
       "null"
      ],
      "description": "The accepted code, or null"
     },
     "discountMessage": {
      "type": [
       "string",
       "null"
      ],
      "description": "Why a code was not accepted"
     }
    }
   },
   "Cart": {
    "allOf": [
     {
      "$ref": "#/components/schemas/Bag"
     },
     {
      "type": "object",
      "properties": {
       "id": {
        "type": "string",
        "format": "uuid",
        "description": "Keep this; it is the cart's secret"
       },
       "note": {
        "type": [
         "string",
         "null"
        ]
       },
       "updatedAt": {
        "type": "string",
        "format": "date-time"
       }
      }
     }
    ]
   },
   "CartCreate": {
    "type": "object",
    "properties": {
     "items": {
      "type": "array",
      "maxItems": 50,
      "items": {
       "type": "object",
       "required": [
        "variantId",
        "qty"
       ],
       "properties": {
        "variantId": {
         "type": "string",
         "format": "uuid"
        },
        "qty": {
         "type": "integer",
         "minimum": 1,
         "maximum": 999
        }
       }
      }
     },
     "discountCode": {
      "type": [
       "string",
       "null"
      ],
      "maxLength": 40
     },
     "note": {
      "type": [
       "string",
       "null"
      ],
      "maxLength": 500
     }
    }
   },
   "CartUpdate": {
    "type": "object",
    "minProperties": 1,
    "properties": {
     "add": {
      "type": "array",
      "maxItems": 50,
      "items": {
       "type": "object",
       "required": [
        "variantId",
        "qty"
       ],
       "properties": {
        "variantId": {
         "type": "string",
         "format": "uuid"
        },
        "qty": {
         "type": "integer",
         "minimum": 1,
         "maximum": 999
        }
       }
      },
      "description": "Adds to a line's quantity"
     },
     "set": {
      "type": "array",
      "maxItems": 50,
      "items": {
       "type": "object",
       "required": [
        "variantId",
        "qty"
       ],
       "properties": {
        "variantId": {
         "type": "string",
         "format": "uuid"
        },
        "qty": {
         "type": "integer",
         "minimum": 0,
         "maximum": 999,
         "description": "0 removes the line"
        }
       }
      },
      "description": "Sets a line's quantity"
     },
     "items": {
      "type": "array",
      "maxItems": 50,
      "items": {
       "type": "object",
       "required": [
        "variantId",
        "qty"
       ],
       "properties": {
        "variantId": {
         "type": "string",
         "format": "uuid"
        },
        "qty": {
         "type": "integer",
         "minimum": 1,
         "maximum": 999
        }
       }
      },
      "description": "Replaces every line"
     },
     "discountCode": {
      "type": [
       "string",
       "null"
      ],
      "maxLength": 40
     },
     "note": {
      "type": [
       "string",
       "null"
      ],
      "maxLength": 500
     }
    }
   },
   "TagList": {
    "type": "object",
    "properties": {
     "tags": {
      "type": "array",
      "items": {
       "type": "object",
       "properties": {
        "name": {
         "type": "string"
        },
        "count": {
         "type": "integer"
        }
       }
      }
     },
     "brands": {
      "type": "array",
      "items": {
       "type": "object",
       "properties": {
        "name": {
         "type": "string"
        },
        "count": {
         "type": "integer"
        }
       }
      }
     }
    }
   },
   "ProductField": {
    "type": "object",
    "required": [
     "key",
     "label",
     "type",
     "value",
     "text"
    ],
    "properties": {
     "key": {
      "type": "string",
      "description": "Never changes once the field is made"
     },
     "label": {
      "type": "string"
     },
     "type": {
      "type": "string",
      "enum": [
       "text",
       "number",
       "boolean",
       "date",
       "url",
       "choice"
      ]
     },
     "value": {
      "type": [
       "string",
       "number",
       "boolean"
      ],
      "description": "The typed value; a date is YYYY-MM-DD"
     },
     "text": {
      "type": "string",
      "description": "The value ready to show: Yes / No, 1,233, 20 Aug 1998"
     }
    }
   }
  }
 }
}