Open meuter opened 2 months ago
Also using java generator and library=native
or library=apache-httpclient
has this problem.
in toUrlQueryString
it gets the list of enums, but then instead of using the right enum type, it uses string:
// add `allowedChatTypes` to the URL query string
if (getAllowedChatTypes() != null) {
int i = 0;
for (String _item : getAllowedChatTypes()) {
......
String _item
is wrong because
public Set<AllowedChatTypesEnum> getAllowedChatTypes() {
return allowedChatTypes;
}
and AllowedChatTypesEnum
is a enum.
Using version 7.7.0.
Bug Report Checklist
Description
When generating the code using the
kotlin-server
generator, if there is a model that is an object where one of the property is an array of enums, the generated kotlin code is incorrect. Here is an example:The model class generated for this enum is the following (removed comments for brievity):
This code does not compile because the constructor for the enum class expects
List<String>
instead of aString
and all the enum variants are constructed with<variant>(<String>)
openapi-generator version
Using version 7.7.0 of the openapi-generator gradle plugin.
OpenAPI declaration file content or url
Generation Details
Using the open-api-generator gradle plugin with the following options (snippets of build.gradle.kts):
(using gradle 8.7)
Steps to reproduce
open-api-generator
7.7.0 gradle pluginsrc/main/kotlin/org/acme/server/models/Foobar.kt
Related issues/PRs
None that I could find.
Suggest a fix
Update the mustache template to fix the code generation. Note that the
kotlin
generator does not suffer from this problem and generates the constructor correctly. Maybe port this portion of the mustashe template to thekotlin-server
generator template?