{
  "openapi": "3.0.3",
  "info": {
    "title": "MOREH PRATAS — Busca pública",
    "version": "1.0.0",
    "description": "Catálogo somente leitura. Busca textual por relevância, sem modelo generativo; use filtros explícitos para preço e categoria. Não permite compras, reservas ou acesso a dados privados."
  },
  "servers": [
    {
      "url": "https://auzbqkqokzjkcodjqmko.supabase.co/functions/v1"
    }
  ],
  "paths": {
    "/ai-search": {
      "get": {
        "operationId": "searchMorehJewelry",
        "summary": "Pesquisar joias públicas da MOREH",
        "security": [],
        "parameters": [
          {
            "name": "q",
            "in": "query",
            "description": "Texto livre; correspondência textual por palavras, não interpreta orçamento automaticamente.",
            "schema": {
              "type": "string",
              "maxLength": 200
            }
          },
          {
            "name": "category",
            "in": "query",
            "description": "Slug da categoria",
            "schema": {
              "type": "string",
              "maxLength": 200
            }
          },
          {
            "name": "collection",
            "in": "query",
            "description": "Slug da coleção",
            "schema": {
              "type": "string",
              "maxLength": 200
            }
          },
          {
            "name": "material",
            "in": "query",
            "description": "Material informado na peça",
            "schema": {
              "type": "string",
              "maxLength": 200
            }
          },
          {
            "name": "min_price",
            "in": "query",
            "schema": {
              "type": "number",
              "minimum": 0,
              "maximum": 1000000
            }
          },
          {
            "name": "max_price",
            "in": "query",
            "schema": {
              "type": "number",
              "minimum": 0,
              "maximum": 1000000
            }
          },
          {
            "name": "giftable",
            "in": "query",
            "schema": {
              "type": "boolean"
            }
          },
          {
            "name": "available",
            "in": "query",
            "schema": {
              "type": "boolean"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 50,
              "default": 20
            }
          },
          {
            "name": "offset",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 0,
              "maximum": 10000,
              "default": 0
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Resultados públicos; disponibilidade unknown nunca significa em estoque. Cache máximo de 60 segundos.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "total",
                    "limit",
                    "offset",
                    "results",
                    "updated_at"
                  ],
                  "properties": {
                    "total": {
                      "type": "integer"
                    },
                    "limit": {
                      "type": "integer"
                    },
                    "offset": {
                      "type": "integer"
                    },
                    "updated_at": {
                      "type": "string",
                      "format": "date-time"
                    },
                    "source": {
                      "type": "string",
                      "format": "uri"
                    },
                    "price_notice": {
                      "type": "string"
                    },
                    "results": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Product"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Parâmetros inválidos"
          },
          "405": {
            "description": "Método não permitido"
          },
          "503": {
            "description": "Catálogo temporariamente indisponível"
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Product": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "id",
          "name",
          "price",
          "currency",
          "url",
          "availability"
        ],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "name": {
            "type": "string"
          },
          "slug": {
            "type": "string"
          },
          "description": {
            "type": "string"
          },
          "material": {
            "type": "string",
            "nullable": true
          },
          "category": {
            "type": "string",
            "nullable": true
          },
          "category_slug": {
            "type": "string",
            "nullable": true
          },
          "collection": {
            "type": "string",
            "nullable": true
          },
          "collection_slug": {
            "type": "string",
            "nullable": true
          },
          "image": {
            "type": "string",
            "nullable": true
          },
          "price": {
            "type": "number",
            "minimum": 0
          },
          "currency": {
            "type": "string",
            "enum": [
              "BRL"
            ]
          },
          "url": {
            "type": "string",
            "format": "uri"
          },
          "giftable": {
            "type": "boolean"
          },
          "availability": {
            "type": "string",
            "enum": [
              "in_stock",
              "out_of_stock",
              "unknown"
            ]
          }
        }
      }
    }
  }
}