In my Avro schema, I have a field called myenum of type enum as follows:
{
"name": "myenum",
    "type": {
        "type": "enum",
        "name": "Suit",
        "symbols": ["SPADES", "HEARTS", "DIAMONDS", "CLUBS"]
    }
}
I also want null to be allowed. If I change the type to be a union with the default value as null (as suggested in this post), it looks like this:
{
"name": "myenum",
    "type": ["null", {
        "type": "enum",
        "name": "Suit",
        "symbols": ["SPADES", "HEARTS", "DIAMONDS", "CLUBS"]
    }]
}
When I test it with the following JSON object {"myenum":"HEARTS"}, I get an error - Expected start-union. Got VALUE_STRING.
If I test it with a null value {"myenum": null}, it works. How can I make an enum field optional?