hooklift/gowsdl

Empty strings in enums results in broken code

bensijons opened this issue · 1 comments

If a WSDL file has an enumeration with an empty string value, gowsdl will currently generate broken go code.

For example:

<simpleType name="DriveTrain">
    <restriction base="string">
        <enumeration value="" />
        <enumeration value="Front Wheel Drive" />
        <enumeration value="Rear Wheel Drive" />
        <enumeration value="All Wheel Drive" />
        <enumeration value="Four Wheel Drive" />
    </restriction>
</simpleType>

This XML will generate the following go code:
Screenshot 2022-03-15 at 21 33 26

Since the enum value is being used as part of the name of the const generated, the empty string value will return a const name that is the same as the name of the type generated (In this case DriveTrain)

Good catch @bensijons! Thanks!