{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://betterbeans.com/developers/catalog.schema.json",
  "definitions": {
    "Product": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "id",
        "roaster_id",
        "name",
        "slug",
        "canonical_url",
        "seller",
        "listing_available",
        "facts",
        "normalized",
        "content_updated_at",
        "approved_facts",
        "variants"
      ],
      "properties": {
        "id": {
          "type": "string",
          "format": "uuid"
        },
        "roaster_id": {
          "type": "string",
          "format": "uuid"
        },
        "name": {
          "type": [
            "string",
            "null"
          ]
        },
        "slug": {
          "type": "string"
        },
        "canonical_url": {
          "type": "string"
        },
        "seller": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "id",
            "name",
            "canonical_url"
          ],
          "properties": {
            "id": {
              "type": "string"
            },
            "name": {
              "type": "string"
            },
            "canonical_url": {
              "type": "string"
            }
          }
        },
        "listing_available": {
          "type": "boolean"
        },
        "facts": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "coffee_name",
            "coffee_description",
            "coffee_type",
            "origin",
            "roast_level",
            "process_method",
            "is_caffeinated",
            "acidity_level",
            "flavor_tags",
            "certification_types",
            "bean_variety",
            "brewing_methods",
            "image_url"
          ],
          "properties": {
            "coffee_name": {
              "type": [
                "string",
                "null"
              ]
            },
            "coffee_description": {
              "type": [
                "string",
                "null"
              ]
            },
            "coffee_type": {
              "type": [
                "string",
                "null"
              ]
            },
            "origin": {
              "type": [
                "array",
                "null"
              ],
              "items": {
                "type": "string"
              }
            },
            "roast_level": {
              "type": [
                "array",
                "null"
              ],
              "items": {
                "type": "string"
              }
            },
            "process_method": {
              "type": [
                "string",
                "null"
              ]
            },
            "is_caffeinated": {
              "type": [
                "boolean",
                "null"
              ]
            },
            "acidity_level": {
              "type": [
                "string",
                "null"
              ]
            },
            "flavor_tags": {
              "type": [
                "array",
                "null"
              ],
              "items": {
                "type": "string"
              }
            },
            "certification_types": {
              "type": [
                "array",
                "null"
              ],
              "items": {
                "type": "string"
              }
            },
            "bean_variety": {
              "type": [
                "array",
                "null"
              ],
              "items": {
                "type": "string"
              }
            },
            "brewing_methods": {
              "type": [
                "array",
                "null"
              ],
              "items": {
                "type": "string"
              }
            },
            "image_url": {
              "type": [
                "string",
                "null"
              ]
            }
          }
        },
        "normalized": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "roast_level",
            "origin_country",
            "origin_region",
            "processing_family",
            "fermentation",
            "tasting_notes",
            "certifications",
            "mapping_version",
            "decaf_method",
            "caffeine_status",
            "added_flavoring",
            "sensory_acidity",
            "blend_components",
            "verification_status"
          ],
          "properties": {
            "roast_level": {
              "type": [
                "array",
                "null"
              ],
              "items": {
                "type": "string"
              }
            },
            "origin_country": {
              "type": [
                "array",
                "null"
              ],
              "items": {
                "type": "string"
              }
            },
            "origin_region": {
              "type": [
                "array",
                "null"
              ],
              "items": {
                "type": "string"
              }
            },
            "processing_family": {
              "type": [
                "array",
                "null"
              ],
              "items": {
                "type": "string"
              }
            },
            "fermentation": {
              "type": [
                "array",
                "null"
              ],
              "items": {
                "type": "string"
              }
            },
            "tasting_notes": {
              "type": [
                "array",
                "null"
              ],
              "items": {
                "type": "string"
              }
            },
            "certifications": {
              "type": [
                "array",
                "null"
              ],
              "items": {
                "type": "string"
              }
            },
            "mapping_version": {
              "type": "string"
            },
            "decaf_method": {
              "type": [
                "string",
                "null"
              ]
            },
            "caffeine_status": {
              "type": [
                "string",
                "null"
              ]
            },
            "added_flavoring": {
              "type": [
                "boolean",
                "null"
              ]
            },
            "sensory_acidity": {
              "type": [
                "string",
                "null"
              ]
            },
            "blend_components": {
              "type": "null"
            },
            "verification_status": {
              "const": "legacy_unverified"
            }
          }
        },
        "content_updated_at": {
          "type": [
            "string",
            "null"
          ],
          "format": "date-time"
        },
        "approved_facts": {
          "type": "array",
          "items": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "field",
              "value",
              "source_url",
              "source_type",
              "observed_at",
              "verified_at",
              "mapping_version",
              "confidence"
            ],
            "properties": {
              "field": {
                "type": "string"
              },
              "value": {},
              "source_url": {
                "type": "string"
              },
              "source_type": {
                "type": "string"
              },
              "observed_at": {
                "type": [
                  "string",
                  "null"
                ],
                "format": "date-time"
              },
              "verified_at": {
                "type": [
                  "string",
                  "null"
                ],
                "format": "date-time"
              },
              "mapping_version": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "confidence": {
                "type": [
                  "string",
                  "null"
                ]
              }
            }
          }
        },
        "variants": {
          "type": "array",
          "items": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "id",
              "size_label",
              "unit_weight_grams",
              "pack_count",
              "form",
              "grind_options",
              "listing_available",
              "price",
              "purchase_type",
              "seller_url"
            ],
            "properties": {
              "id": {
                "type": "string",
                "format": "uuid"
              },
              "size_label": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "unit_weight_grams": {
                "type": [
                  "string",
                  "null"
                ],
                "pattern": "^\\d+(\\.\\d+)?$"
              },
              "pack_count": {
                "type": [
                  "integer",
                  "null"
                ],
                "minimum": 1
              },
              "form": {
                "enum": [
                  "whole_bean",
                  "ground",
                  null
                ]
              },
              "grind_options": {
                "type": [
                  "array",
                  "null"
                ],
                "items": {
                  "type": "string"
                }
              },
              "listing_available": {
                "type": "boolean"
              },
              "price": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "amount",
                  "currency",
                  "observed_at",
                  "verification_status"
                ],
                "properties": {
                  "amount": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "pattern": "^\\d+(\\.\\d+)?$"
                  },
                  "currency": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "pattern": "^[A-Z]{3}$"
                  },
                  "observed_at": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "format": "date-time"
                  },
                  "verification_status": {
                    "enum": [
                      "source_observed",
                      "unverified"
                    ]
                  }
                }
              },
              "purchase_type": {
                "enum": [
                  "one_time",
                  "unknown"
                ]
              },
              "seller_url": {
                "type": [
                  "string",
                  "null"
                ]
              }
            }
          }
        }
      }
    },
    "Variant": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "id",
        "size_label",
        "unit_weight_grams",
        "pack_count",
        "form",
        "grind_options",
        "listing_available",
        "price",
        "purchase_type",
        "seller_url"
      ],
      "properties": {
        "id": {
          "type": "string",
          "format": "uuid"
        },
        "size_label": {
          "type": [
            "string",
            "null"
          ]
        },
        "unit_weight_grams": {
          "type": [
            "string",
            "null"
          ],
          "pattern": "^\\d+(\\.\\d+)?$"
        },
        "pack_count": {
          "type": [
            "integer",
            "null"
          ],
          "minimum": 1
        },
        "form": {
          "enum": [
            "whole_bean",
            "ground",
            null
          ]
        },
        "grind_options": {
          "type": [
            "array",
            "null"
          ],
          "items": {
            "type": "string"
          }
        },
        "listing_available": {
          "type": "boolean"
        },
        "price": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "amount",
            "currency",
            "observed_at",
            "verification_status"
          ],
          "properties": {
            "amount": {
              "type": [
                "string",
                "null"
              ],
              "pattern": "^\\d+(\\.\\d+)?$"
            },
            "currency": {
              "type": [
                "string",
                "null"
              ],
              "pattern": "^[A-Z]{3}$"
            },
            "observed_at": {
              "type": [
                "string",
                "null"
              ],
              "format": "date-time"
            },
            "verification_status": {
              "enum": [
                "source_observed",
                "unverified"
              ]
            }
          }
        },
        "purchase_type": {
          "enum": [
            "one_time",
            "unknown"
          ]
        },
        "seller_url": {
          "type": [
            "string",
            "null"
          ]
        }
      }
    },
    "Roaster": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "id",
        "name",
        "slug",
        "canonical_url",
        "seller_url",
        "city",
        "state",
        "description",
        "logo_url",
        "social_urls",
        "locations",
        "capabilities"
      ],
      "properties": {
        "id": {
          "type": "string",
          "format": "uuid"
        },
        "name": {
          "type": [
            "string",
            "null"
          ]
        },
        "slug": {
          "type": "string"
        },
        "canonical_url": {
          "type": "string"
        },
        "seller_url": {
          "type": [
            "string",
            "null"
          ]
        },
        "city": {
          "type": [
            "string",
            "null"
          ]
        },
        "state": {
          "type": [
            "string",
            "null"
          ]
        },
        "description": {
          "type": [
            "string",
            "null"
          ]
        },
        "logo_url": {
          "type": [
            "string",
            "null"
          ]
        },
        "social_urls": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "locations": {
          "type": "array",
          "items": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "id",
              "name",
              "country",
              "address_line1",
              "address_line2",
              "city",
              "state",
              "postal_code",
              "location_type",
              "public_access",
              "timezone",
              "public_phone",
              "source_url",
              "verified_at",
              "latitude",
              "longitude",
              "hours"
            ],
            "properties": {
              "id": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "name": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "country": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "address_line1": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "address_line2": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "city": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "state": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "postal_code": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "location_type": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "public_access": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "timezone": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "public_phone": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "source_url": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "verified_at": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "latitude": {
                "type": [
                  "number",
                  "null"
                ]
              },
              "longitude": {
                "type": [
                  "number",
                  "null"
                ]
              },
              "hours": {
                "type": [
                  "array",
                  "null"
                ],
                "items": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "day",
                    "opens",
                    "closes"
                  ],
                  "properties": {
                    "day": {
                      "type": "string"
                    },
                    "opens": {
                      "type": "string"
                    },
                    "closes": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        },
        "capabilities": {
          "type": "array",
          "items": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "capability",
              "value",
              "source_url",
              "verified_at"
            ],
            "properties": {
              "capability": {
                "type": "string"
              },
              "value": {
                "oneOf": [
                  {
                    "type": "boolean"
                  },
                  {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  }
                ]
              },
              "source_url": {
                "type": "string"
              },
              "verified_at": {
                "type": "string"
              }
            }
          }
        }
      }
    },
    "ProductPage": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "schema_version",
        "data",
        "pagination"
      ],
      "properties": {
        "schema_version": {
          "const": "1.0"
        },
        "data": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/Product"
          }
        },
        "pagination": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "limit",
            "total",
            "total_unit",
            "next_cursor",
            "next"
          ],
          "properties": {
            "limit": {
              "type": "integer",
              "minimum": 1,
              "maximum": 50
            },
            "total": {
              "type": "integer",
              "minimum": 0
            },
            "total_unit": {
              "const": "products"
            },
            "next_cursor": {
              "type": [
                "string",
                "null"
              ]
            },
            "next": {
              "type": [
                "string",
                "null"
              ]
            }
          }
        }
      }
    },
    "RoasterPage": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "schema_version",
        "data",
        "pagination"
      ],
      "properties": {
        "schema_version": {
          "const": "1.0"
        },
        "data": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/Roaster"
          }
        },
        "pagination": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "limit",
            "total",
            "total_unit",
            "next_cursor",
            "next"
          ],
          "properties": {
            "limit": {
              "type": "integer",
              "minimum": 1,
              "maximum": 50
            },
            "total": {
              "type": "integer",
              "minimum": 0
            },
            "total_unit": {
              "const": "roasters"
            },
            "next_cursor": {
              "type": [
                "string",
                "null"
              ]
            },
            "next": {
              "type": [
                "string",
                "null"
              ]
            }
          }
        }
      }
    }
  },
  "oneOf": [
    {
      "$ref": "#/definitions/ProductPage"
    },
    {
      "$ref": "#/definitions/RoasterPage"
    }
  ]
}
