You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Confluent Schema Registry中JSON Schema数组管理问题求助

正确的JSON Schema写法(适配Confluent S3 Sink Connector)

你遇到的报错核心原因是:JSON Schema中数组类型的items字段被错误定义为数组格式,而Confluent Schema Registry及S3 Connector要求,当数组内所有元素类型一致时,items必须是单个Schema对象。

修正后的JSON Schema

{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "title":  "my_messages",
  "type": "object",
  "properties": {
    "messageType": {
      "type": ["string", "null"]
    },
    "timestamp": {
      "type": ["integer", "null"]
    },
    "fieldId": {
      "type": ["integer", "null"]
    },
    "number": {
      "type": ["integer", "null"]
    },
    "contains": {
      "type": ["array", "null"],
      "items": {
        "type": ["string", "null"]
      }
    }
  },
  "additionalProperties": true
}

关键修改说明

  • 将contains字段下的items从数组格式[{...}]改为单个对象{...},完全符合JSON Schema Draft 04对同类型元素数组的定义规范
  • 该Schema支持contains字段为null、空数组,或包含任意数量的字符串/空值元素,完全匹配你的业务需求

规范参考

Confluent Schema Registry对JSON Schema的兼容遵循官方JSON Schema规范:数组类型的items字段,若用于定义所有元素的统一类型,需指定单个Schema对象;仅当数组内元素类型各不相同(按位置匹配)时,才使用数组形式的items定义。

内容的提问来源于stack exchange,提问作者Stefano

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.25 11:15:37