hooklift / gowsdl

WSDL2Go code generation as well as its SOAP proxy
Mozilla Public License 2.0
1.14k stars 390 forks source link

Empty strings in enums results in broken code #236

Closed bensijons closed 2 years ago

bensijons commented 2 years ago

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)

c4milo commented 2 years ago

Good catch @bensijons! Thanks!