json - schema-registry JSON Schema FULL 兼容性检查
问题描述
给定以下 Kafka 主题和架构:
$kafka-json-schema-console-producer \
> --broker-list localhost:9092 \
> --topic topicFull \
> --property value.schema='{"type":"object","properties":{"a":{"type":"string"}}, "required" : ["a"], "additionalProperties" : true}'
{"a" : "bip"}
兼容性FULL
:
# FULL compatibility
$curl -s -X GET http://localhost:8081/config/topicFull-value
{"error_code":40401,"message":"Subject 'topicFull-value' not found."}
$curl -s -X GET http://localhost:8081/config
{"compatibilityLevel":"FULL"}
我检查了添加必填字段 ,b
是否兼容:
$curl -s -X POST -H "Content-Type: application/vnd.schemaregistry.v1+json" \
> --data '{"schemaType": "JSON", "schema": "{\"type\":\"object\",\"properties\":{\"a\":{\"type\":\"string\"}, \"b\":{\"type\":\"string\"}},\"required\":[\"a\", \"b\"],\"additionalProperties\":true}"}' \
> http://localhost:8081/compatibility/subjects/topicFull-value/versions/1 | jq
{
"is_compatible": false
}
API显示它不兼容。
但是,我不明白为什么添加可选字段 ,b
不兼容:
$curl -s -X POST -H "Content-Type: application/vnd.schemaregistry.v1+json" \
> --data '{"schemaType": "JSON", "schema": "{\"type\":\"object\",\"properties\":{\"a\":{\"type\":\"string\"}, \"b\":{\"type\":\"string\"}},\"required\":[\"a\"],\"additionalProperties\":true}"}' \
> http://localhost:8081/compatibility/subjects/topicFull-value/versions/1 | jq
{
"is_compatible": false
}
您能解释一下为什么添加可选字段无法通过兼容性检查吗?
解决方案
推荐阅读
- powerbi - DAX 公式根据项目是否存在来标记订单
- python - BlueZ 自动重新连接作为设备到 PC
- javascript - 如何在 JavaScript 中将多个 jsons 数组合并为一个与子数组交叉的数组?
- python - 实体关系提取斯坦福 CoreNLP
- typescript - 为什么 Node.js 显示 Node.js 模块方法而 Typescript 不显示?(Visual Studio 代码)
- java - 如何在项目之间共享 Hibernate TypeDefs 和 GenericGenerator 定义?
- sql - SQL - 使用交叉表创建表
- java - LayoutParams 上的 ClassCastException 从 LinearLayout 到 AbsListView
- python - 按 dtype 子集 pandas 数据帧
- mongodb - Mongo Express 码头工人