Skip to content

Commit cd58c8e

Browse files
Gama11Goopher Maijenburg
authored andcommitted
[kotlin-client] Fix string comparison in discriminator post-processing (OpenAPITools#21881)
We encountered occassional build failures with the logic introduced in OpenAPITools#21531 due to discriminator properties still being generated in rare cases. Not sure why it didn't happen consistently, may be related to Gradle caching or parallel builds or whatever. Since patching these string comparisons, this has no longer occurred.
1 parent 0371c28 commit cd58c8e

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/KotlinClientCodegen.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -976,7 +976,7 @@ public Map<String, ModelsMap> postProcessAllModels(Map<String, ModelsMap> objs)
976976
continue;
977977
}
978978
// Remove discriminator property from the base class, it is not needed in the generated code
979-
getAllVarProperties(cm).forEach(list -> list.removeIf(var -> var.name == discriminator.getPropertyName()));
979+
getAllVarProperties(cm).forEach(list -> list.removeIf(var -> var.name.equals(discriminator.getPropertyName())));
980980

981981
for (CodegenDiscriminator.MappedModel mappedModel : discriminator.getMappedModels()) {
982982
// Add the mapping name to additionalProperties.disciminatorValue
@@ -989,7 +989,7 @@ public Map<String, ModelsMap> postProcessAllModels(Map<String, ModelsMap> objs)
989989
}
990990
additionalProperties.discriminatorValue = mappedModel.getMappingName();
991991
// Remove the discriminator property from the derived class, it is not needed in the generated code
992-
getAllVarProperties(mappedModel.getModel()).forEach(list -> list.removeIf(prop -> prop.name == discriminator.getPropertyName()));
992+
getAllVarProperties(mappedModel.getModel()).forEach(list -> list.removeIf(prop -> prop.name.equals(discriminator.getPropertyName())));
993993
}
994994

995995
}

0 commit comments

Comments
 (0)