Kafka架构注册表的架构问题

问题描述 投票:0回答:1

我知道我带着任何消息来找你,但我无法解决一个可能是我的错的问题,实际上我无法意识到解决方案是什么。我正在使用Confluent平台的独立安装(4.0.0开源版本),以演示如何为特定用例采用该平台。试图证明使用模式注册表的价值我面临以下问题与Postman发布新模式。

请求是:http://host:8081/subjects/test/versions ,方法POST,Header:Accept:application / vnd.schemaregistry.v1 + json,application / vnd.schemaregistry + json,application / json Content-Type:application / json,Body:{“schema”:“{{\”namespace \ “:\” com.testlab \” \ “名称\”:\ “测试\” \ “类型\”:\ “记录\” \ “字段\”:[{\ “名称\”:\ “resourcepath \”,\“type \”:\“string \”},{\“name \”:\“resource \”,\“type \”:\“string \”}]}}“}

响应是:{“error_code”:42201,“message”:“输入架构是无效的Avro架构”}

看看文档和谷歌搜索后,我没有选择。有什么建议吗?谢谢你的时间R.

avro confluent confluent-schema-registry
1个回答
0
投票

您在架构字段周围有额外的{}

测试这个的一种方法是使用jq

之前

$ echo '{"schema":"{{\"namespace\":\"com.testlab\",\"name\":\"test\",\"type\":\"record\",\"fields\":[{\"name\":\"resourcepath\",\"type\":\"string\"},{\"name\":\"resource\",\"type\":\"string\"}]}}" }' | jq '.schema|fromjson'
jq: error (at <stdin>:1): Objects must consist of key:value pairs at line 1, column 146 (while parsing '{{"namespace":"com.testlab","name":"test","type":"record","fields":[{"name":"resourcepath","type":"string"},{"name":"resource","type":"string"}]}}')

$ echo '{"schema":"{\"namespace\":\"com.testlab\",\"name\":\"test\",\"type\":\"record\",\"fields\":[{\"name\":\"resourcepath\",\"type\":\"string\"},{\"name\":\"resource\",\"type\":\"string\"}]}" }' | jq  '.schema|fromjson'
{
  "namespace": "com.testlab",
  "name": "test",
  "type": "record",
  "fields": [
    {
      "name": "resourcepath",
      "type": "string"
    },
    {
      "name": "resource",
      "type": "string"
    }
  ]
}

有关导入AVSC文件的信息,请参阅my comment here,以便您无需在CLI上输入JSON

© www.soinside.com 2019 - 2024. All rights reserved.