swagger-codegen icon indicating copy to clipboard operation
swagger-codegen copied to clipboard

[Swift] Ensure that enumeration types do not conflict with variable name

Open jaz-ah opened this issue 10 years ago • 0 comments

Swagger generator: 2.1.5 Language: swift

(This is w/ Swift 2 on XCode7.2)

If we have a swagger specification like this:

https://gist.github.com/jaz-ah/f6394360065650000c96

The generated code produced is:

public enum EnumTest: String {
    case Abc = "abc"
    case Def = "def"
}

public var EnumTest: EnumTest?

which produces a complier error:

'EnumTest' used within its own type

We need to protect against this condition by ensuring our enumeration name always is different than the variable name.

jaz-ah avatar Jan 27 '16 17:01 jaz-ah