mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-10-14 16:33:56 +00:00
[kotlin-client] Fix string comparison in discriminator post-processing (#21881)
We encountered occassional build failures with the logic introduced in #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.
This commit is contained in:
parent
3029ac62f7
commit
29a817afdb
@ -976,7 +976,7 @@ public class KotlinClientCodegen extends AbstractKotlinCodegen {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// Remove discriminator property from the base class, it is not needed in the generated code
|
// Remove discriminator property from the base class, it is not needed in the generated code
|
||||||
getAllVarProperties(cm).forEach(list -> list.removeIf(var -> var.name == discriminator.getPropertyName()));
|
getAllVarProperties(cm).forEach(list -> list.removeIf(var -> var.name.equals(discriminator.getPropertyName())));
|
||||||
|
|
||||||
for (CodegenDiscriminator.MappedModel mappedModel : discriminator.getMappedModels()) {
|
for (CodegenDiscriminator.MappedModel mappedModel : discriminator.getMappedModels()) {
|
||||||
// Add the mapping name to additionalProperties.disciminatorValue
|
// Add the mapping name to additionalProperties.disciminatorValue
|
||||||
@ -989,7 +989,7 @@ public class KotlinClientCodegen extends AbstractKotlinCodegen {
|
|||||||
}
|
}
|
||||||
additionalProperties.discriminatorValue = mappedModel.getMappingName();
|
additionalProperties.discriminatorValue = mappedModel.getMappingName();
|
||||||
// Remove the discriminator property from the derived class, it is not needed in the generated code
|
// Remove the discriminator property from the derived class, it is not needed in the generated code
|
||||||
getAllVarProperties(mappedModel.getModel()).forEach(list -> list.removeIf(prop -> prop.name == discriminator.getPropertyName()));
|
getAllVarProperties(mappedModel.getModel()).forEach(list -> list.removeIf(prop -> prop.name.equals(discriminator.getPropertyName())));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user