swagger-api/swagger-codegen

Enum values OFF and ON not getting generated properly.

Open

#2,559 创建于 2016年4月11日

在 GitHub 查看
 (6 评论) (0 反应) (0 负责人)HTML (5,474 fork)batch import
Enhancement: FeatureFeature: Enumhelp wanted

仓库指标

Star
 (12,701 star)
PR 合并指标
 (30 天内没有已合并 PR)

描述

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

贡献者指南