{
  "openapi": "3.1.0",
  "info": {
    "title": "idesain — Catálogo público de productos",
    "version": "1.0.0",
    "description": "Lista de solo lectura de los productos visibles en https://idesain.com.mx. Precios en MXN. Para comprar, entrega a la persona el cart_url (o arma https://idesain.com.mx/carrito?agregar=slug[:variante][:cantidad],...); ella revisa y paga en la tienda. No hay endpoints de pago ni de pedidos.",
    "contact": {
      "name": "idesain",
      "url": "https://idesain.com.mx/contacto"
    }
  },
  "servers": [
    {
      "url": "https://idesain.com.mx"
    }
  ],
  "paths": {
    "/api/public/products": {
      "get": {
        "operationId": "listProducts",
        "summary": "Buscar productos",
        "parameters": [
          {
            "name": "q",
            "in": "query",
            "schema": {
              "type": "string",
              "maxLength": 100
            },
            "description": "Texto a buscar (nombre, marca, modelo, SKU, color, almacenamiento)."
          },
          {
            "name": "categoria",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Categoría, por ejemplo smartphones, laptops, tablets, smartwatches, audio, accesorios."
          },
          {
            "name": "marca",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Marca, por ejemplo Apple o Samsung."
          },
          {
            "name": "condicion",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "nuevo",
                "reacondicionado",
                "caja_abierta"
              ]
            }
          },
          {
            "name": "disponible",
            "in": "query",
            "schema": {
              "type": "boolean"
            },
            "description": "true: solo productos que se pueden comprar ahora (en existencia o sobre pedido)."
          },
          {
            "name": "slug",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Devuelve solo el producto con este identificador."
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 24
            }
          },
          {
            "name": "offset",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 0,
              "default": 0
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Productos encontrados",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProductList"
                }
              }
            }
          },
          "400": {
            "description": "Parámetros inválidos"
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "ProductList": {
        "type": "object",
        "properties": {
          "currency": {
            "type": "string",
            "const": "MXN"
          },
          "shipping": {
            "type": "object",
            "properties": {
              "cost": {
                "type": "number"
              },
              "free_from": {
                "type": "number"
              }
            }
          },
          "total": {
            "type": "integer"
          },
          "offset": {
            "type": "integer"
          },
          "count": {
            "type": "integer"
          },
          "cart_link_format": {
            "type": "string"
          },
          "products": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Product"
            }
          }
        }
      },
      "Product": {
        "type": "object",
        "properties": {
          "slug": {
            "type": "string"
          },
          "url": {
            "type": "string",
            "format": "uri"
          },
          "name": {
            "type": "string"
          },
          "brand": {
            "type": "string"
          },
          "category": {
            "type": "string"
          },
          "condition": {
            "type": "string"
          },
          "condition_label": {
            "type": "string"
          },
          "type": {
            "type": "string",
            "enum": [
              "producto",
              "servicio"
            ]
          },
          "sku": {
            "type": [
              "string",
              "null"
            ]
          },
          "currency": {
            "type": "string"
          },
          "price": {
            "type": "number",
            "description": "Precio de venta en MXN (con variantes, el más bajo)."
          },
          "regular_price": {
            "type": [
              "number",
              "null"
            ],
            "description": "Precio regular antes de la oferta."
          },
          "availability": {
            "type": "string",
            "enum": [
              "InStock",
              "PreOrder",
              "OutOfStock"
            ],
            "description": "InStock: disponible. PreOrder: «Sobre pedido», se puede comprar. OutOfStock: agotado."
          },
          "images": {
            "type": "array",
            "items": {
              "type": "string",
              "format": "uri"
            }
          },
          "description": {
            "type": "string"
          },
          "specs": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            }
          },
          "variants": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Variant"
            }
          },
          "cart_url": {
            "type": [
              "string",
              "null"
            ],
            "format": "uri",
            "description": "Enlace de carrito con 1 pieza. Es null si hay variantes: usa el cart_url de la variante."
          }
        }
      },
      "Variant": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "type": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "sku": {
            "type": [
              "string",
              "null"
            ]
          },
          "price": {
            "type": "number"
          },
          "availability": {
            "type": "string",
            "enum": [
              "InStock",
              "PreOrder",
              "OutOfStock"
            ],
            "description": "InStock: disponible. PreOrder: «Sobre pedido», se puede comprar. OutOfStock: agotado."
          },
          "image": {
            "type": [
              "string",
              "null"
            ]
          },
          "cart_url": {
            "type": "string",
            "format": "uri"
          }
        }
      }
    }
  }
}