stealthly/xml-avro — pull request #6 by lucamilanesio (2014-11-04 13:16:58+00:00)
Title: Encode optional value as Avro Union with “null” as first element

Optional values were correctly encoded as Avro Union type, but
unfortunately the “null” was placed on the second position, meaning
that the default value was actually required (and not optional).

The correct pattern to use Avro Union for optional values is described
in the Apache Avro documentation:

“Unions
Unions, as mentioned above, are represented using JSON arrays.
For example, ["null", "string"] declares a schema which may be either
a null or string.

(Note that when a default value is specified for a record field whose
type is a union, the type of the default value must match the first
element of the union. Thus, for unions containing "null", the "null"
is usually listed first, since the default value of such unions is
typically null.)”