Naw, I appreciate any opinions and insights. My goal is just educate myself of the options available and their pros and cons.
I would use the Jackdaw EDN serde until you need something better.
I have a question around error reporting for schema coercion:
(def +registry+
(merge jav/+base-schema-type-registry+
jav/+UUID-type-registry+))
(def schema-type
(jav/make-coercion-stack
+registry+))
(defn parse-schema [clj-schema]
(.parse (Schema$Parser.) ^String (json/write-str clj-schema)))
(def person-schema
{:type "record"
:name "PersonSchema"
:fields [{:type [{:type "record"
:name "value"
:fields [{:type "long" :name "age"}]}]
:name "person"}]})
(jav/clj->avro (schema-type (parse-schema person-schema)) {:person {}} []) --> throws an ExceptionInfo clojure.lang.PersistentArrayMap is not a valid type for union [RECORD] clojure.core/ex-info (core.clj:4739)
(def person-schema-no-union
{:type "record"
:name "PersonSchema"
:fields [{:type {:type "record"
:name "value"
:fields [{:type "long" :name "age"}]}
:name "person"}]})
(jav/clj->avro (schema-type (parse-schema person-schema)) {:person {}} []) --> throws an AvroRuntimeException Field age type:LONG pos:0 not set and has no default value org.apache.avro.generic.GenericData.getDefaultValue (GenericData.java:984)
For union types there is less information returned that would be useful to decipher what is wrong with the clj map passed in. Would it be useful to have UnionTypes return an error response more similar to the second coercion?Probably.