confluent-schema-registry icon indicating copy to clipboard operation
confluent-schema-registry copied to clipboard

Avro: UnionTypes not supported by lib but supported by the confluent registry

Open jeduden opened this issue 5 years ago • 1 comments

It seems that union types are not supported by this lib, since the validation assumes that the type has a name.

The confluent registry however accepts union types just fine. They also have test cases for the KafkaAvroSerializer testing union support: https://github.com/confluentinc/schema-registry/blob/master/avro-serializer/src/test/java/io/confluent/kafka/serializers/KafkaAvroSerializerTest.java#L440

Currently, i bumped into the following spots with the union schema:

  • readAVSC - https://github.com/kafkajs/confluent-schema-registry/blob/master/src/utils/readAVSC.ts#L11
  • AvroHelper.validate: https://github.com/kafkajs/confluent-schema-registry/blob/master/src/AvroHelper.ts#L25

jeduden avatar Apr 01 '21 11:04 jeduden

It looks like that the subject naming strategy is limited to "TopicNameStrategy" when using union types, which forced me to wrap the union in a record with a single field.

jeduden avatar Apr 01 '21 13:04 jeduden