swagger-api/swagger-codegen

[Java] Discriminator present twice since 3.0.47

chkpnt opened this issue · 1 comments

Description

Since 3.0.47, a snake-cased discriminator property is generated twice in the Java client's serialized model.

application_type is generated as application_type and applicationType.

Swagger-codegen version

With 3.0.46, everything was fine. The issue doesn't seem to be related to swagger-codegen-generators, as the newest Java template (1.0.46) is working fine with swagger-codegen-cli 3.0.46.

Swagger declaration file content or url

https://github.com/chkpnt/swagger-issue-demonstrator/blob/main/api/src/main/specs/application-api.yml

Command line used for generation

./gradlew updateGeneratedApiClient, which uses the following settings:

swaggerSources {
    create("apiClient") {
        setInputFile(file(ospLbsApiSpecificationFile))
        code(closureOf<GenerateSwaggerCode> {
            language = "java"
            additionalProperties = mapOf(
                "library" to "jersey2",
                "modelPackage" to "org.example.applicationapi.model",
                "apiPackage" to "org.example.applicationapi.api",
                "invokerPackage" to "org.example.applicationapi",
                "hideGenerationTimestamp" to "true",
                "dateLibrary" to "java8",
                "java8" to "true"
            )
            outputs.upToDateWhen { false }
            templateDir = file("template")
        })
    }
}
Steps to reproduce
  1. Clone the demonstrator project https://github.com/chkpnt/swagger-issue-demonstrator
  2. Run the test PassierscheinA38Test#testSerialization() on tag 3.0.46.
  3. Run the same test on tag 3.0.47, it fails due to the additional property applicationType.
Related issues/PRs

According to the diff between 3.0.46 and 3.0.47, there is no change in the code but only in the dependencies: swagger-codegen-generators has been updated from 1.0.42 to 1.0.43.

So I guess swagger-api/swagger-codegen-generators#1184 is the change that introduced this bug. But as the issue doesn't occur if I'm using the Java template of swagger-codegen-generators 1.0.46 with swaggercodegen-cli 3.0.46, I'm a bit confused. Therefore I'm filing this issue in this repository instead of swagger-codegen-generators.

Suggest a fix/enhancement

Hi @chkpnt this issue should be fixed by latest swagger-codegen 3.0.55 release