【问题标题】:Confluent Schema Registry: POST simple JSON schema with object having single propertyConfluent Schema Registry:POST简单的JSON模式,对象具有单一属性
【发布时间】:2020-09-28 19:21:01
【问题描述】:
OS:  Ubuntu 18.x
docker image (from dockerhub.com, as of 2020-09-25):  confluentinc/cp-schema-registry:latest

我正在探索 Confluent Schema Registry 的 HTTP API。首先,关于注册表假定的 JSON Schema 定义的版本是否有明确的断言?现在,我假设Draft v7.0。更广泛地说,我相信返回支持模式的 API 应该列出版本。例如,而不是:

$ curl -X GET http://localhost:8081/schemas/types
["JSON","PROTOBUF","AVRO"]

你会:

$ curl -X GET http://localhost:8081/schemas/types
[{"flavor": "JSON", "version": "7.0"}, {"flavor": "PROTOBUF", "version": "1.2"}, {"flavor": "AVRO", "version": "3.5"}]

所以至少程序员可以确定架构注册表的假设。

撇开这个问题不谈,我似乎无法将一个相当简单的 JSON 模式发布到注册表:

$ curl -X POST -H "Content-Type: application/vnd.schemaregistry.v1+json" --data '{ "schema": "{ \"type\": \"object\", \"properties\": { \"f1\": { \"type\": \"string\" } } }" }' http://localhost:8081/subjects/mytest-value/versions
{"error_code":42201,"message":"Either the input schema or one its references is invalid"}

在这里,我将架构发布到 mytest 主题。顺便说一下,我从 Confluent 文档中抓取了架构,然后相应地对其进行了转义。

你能说出为什么这个模式没有 POST 到注册表吗?更一般地说,我可以假设完全支持 JSON Schema 定义的 Draft v7.0 吗?

【问题讨论】:

    标签: confluent-platform confluent-schema-registry


    【解决方案1】:

    您需要传递 schemaType 标志。 “如果未提供 schemaType,则假定 schemaType 为 AVRO。” https://docs.confluent.io/current/schema-registry/develop/api.html#post--subjects-(string-%20subject)-versions:

    '{"schemaType":"JSON","schema":"{\"type\":\"object\",\"fields\":[{\"name\":\"f1\",\"type\":\"string\"}]}"}'
    

    我同意输出受支持的版本会有所帮助。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-01-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多