swagger-api/swagger-codegen

Enum values OFF and ON not getting generated properly.

Open

#2559 aperta il 11 apr 2016

Vedi su GitHub
 (6 commenti) (0 reazioni) (0 assegnatari)HTML (5474 fork)batch import
Enhancement: FeatureFeature: Enumhelp wanted

Metriche repository

Star
 (12.701 star)
Metriche merge PR
 (Nessuna PR mergiata in 30 g)

Descrizione

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

Guida contributor