swagger-api/swagger-codegen-generators

[java][okhttp4-gson] ApiClient.mustache Generates invalid code in Baseclass

FrostbittenKing opened this issue · 0 comments

Basically same issue as in #617 imho.
When using an enum as a discriminator in an inheritance hierarchy, the okhttp4-gson code generates an invalid java object.
As far as i can tell the cause is the following part in pojo.mustache:
{#gson}} {{#discriminator}} public {{classname}}() { this.{{discriminator.propertyName}} = this.getClass().getSimpleName(); // HERE this would assign to an enum a string } {{/discriminator}} {{/gson}}
This very issue existed in the 2.x codebase and has been fixed here: https://github.com/swagger-api/swagger-codegen/pull/9207/files
And especially this: https://github.com/swagger-api/swagger-codegen/pull/9983/files
As far as I can tell, but unfortunately, this has been reintroduced in the 3.x codebase for okhttp4-gson.
I know this worked in the past, since we're about to migrate our old generated cliient to okhttp4-gson, which fails to be generated with the new 3.x codebase.
It still works for jersey3, which is probably our workaround.