[JAVA] Bug generating bad enum classes with extra double quotes
Description
I am seeing what appears to be a regression with the swagger codegen releases 2.2.x, compared to 2.1.6 which behaves correctly. If I define enums in the yml file, the generated java classes contain enums that don't compile due to duplicated double-quotes around the constant strings.
Example:
status:
type: "string"
enum:
- "upToDate"
- "stale"
produces uncompilable java code:
public enum StatusEnum {
UPTODATE(""upToDate""),
STALE(""stale"");
Swagger-codegen version
Works with 2.1.6, fails (duplicate double-quotes) with 2.2.0 - 2.2.3
Swagger declaration file content or url
definitions:
Test:
type: "object"
properties:
status:
type: "string"
enum:
- "upToDate"
- "stale"
Command line used for generation
Gradle task:
import io.swagger.codegen.config.CodegenConfigurator
import io.swagger.codegen.DefaultGenerator
task generateApi {
def swaggerInput = ".../swagger.yml"
def swaggerOutputDir = file('generated/swagger')
inputs.file(swaggerInput)
outputs.dir(swaggerOutputDir)
doLast {
def config = new CodegenConfigurator()
config.setInputSpec(swaggerInput)
config.setOutputDir(swaggerOutputDir.path)
config.setLang('java')
config.setLibrary('jersey2')
config.setTemplateDir('src/main/resources/templates')
config.setModelPackage('...model')
config.setInvokerPackage('...')
config.setApiPackage('...')
config.setAdditionalProperties([
'dateLibrary' : 'java8'
])
new DefaultGenerator().opts(config.toClientOptInput()).generate()
}
Steps to reproduce
Run "gradle generateAPI"
Related issues/PRs
https://github.com/swagger-api/swagger-codegen/issues/3593
Suggest a fix/enhancement
Regression from 2.1 to 2.2 release.
We do have test cases to cover this. Can you please try the latest master to see if the issue still occurs? Snapshot version available at https://github.com/swagger-api/swagger-codegen#compatibility
Will try that and report results.
Hi Im trying to upgarde to 2.4.39 still see same issue can you help