Handle abbreviated union types for code generation

Fixes #701 
You haven't handled the case where `field.Name` is empty or null.

I think it's better to use `String.mapi` than explicitly check for empty or null strings.