swagger-api/swagger-codegen

Enum values OFF and ON not getting generated properly.

Open

#2,559 opened on Apr 11, 2016

View on GitHub
 (6 comments) (0 reactions) (0 assignees)HTML (12,701 stars) (5,474 forks)batch import
Enhancement: FeatureFeature: Enumhelp wanted

Description

I observed this weird issue today when generating java client using maven codegen plugin, that enum values like OFF and ON are somehow ignored. Lets say in my YAML definition, there is:

laziness:
        description: Flag to denote whether laziness should be enabled or disabled.
        type: string
        enum: [ ON, OFF ]

In the above scenario, no enum type is generated, and the class member laziness have the type String. But, If the definition was as follows:

laziness:
        description: Flag to denote whether laziness should be enabled or disabled.
        type: string
        enum: [ ON, OFF, MEH ]

Codegen generates the enum with just one value - MEH, and the class member is assigned the enum type.

But if I put quotes around them, like:

laziness:
        description: Flag to denote whether laziness should be enabled or disabled.
        type: string
        enum: [ "ON", "OFF", "MEH" ]

All values are included in the generated enum.

I use the latest version of swagger-codegen-maven-plugin, version 2.1.6

PS: It works perfectly when generating from editor.swagger.io

Contributor guide