将avro有效负载发布到kafka-rest服务时,如果value_schema中的某个字段定义了默认值,并且在记录中省略了该字段。似乎kafka-rest仍然坚持将其记录在内。这样做的正确方法是什么?
例如
curl -X POST -H "Content-Type: application/vnd.kafka.avro.v1+json" \
--data '{"value_schema": "{\"type\": \"record\", \"name\": \"User\", \"fields\": [{\"name\": \"name\", \"type\": \"string\"}, {\"name\":\"age\",\"type\":\"int\",\"default\":18}, {\"name\":\"id\",\"type\":\"string\"}]}", "records": [{"value": {"name": "testUser", "id": "001"}}]}' \
"http://localhost:8082/topics/avrotest"
输出
{"error_code":42203,"message":"Conversion of JSON to Avro failed: Failed to convert JSON to Avro: Expected field name not found: age"}