OpenAPITools / openapi-generator

OpenAPI Generator allows generation of API client libraries (SDK generation), server stubs, documentation and configuration automatically given an OpenAPI Spec (v2, v3)
https://openapi-generator.tech
Apache License 2.0
20.76k stars 6.32k forks source link

[BUG][Kotlin] Enum type name starts lowecased and causes a build-error #18836

Open hrach opened 1 month ago

hrach commented 1 month ago

Bug Report Checklist

Description

After updating to 7.6.0 (from 7.4.0) there is a regression. The produced code does not compile:

data class FavoritesEndpointItemsDto constructor (
    @Json(name = "user_gender")
    val userGender: FavoritesEndpointItemsDto.UserGender? = null,
) {
    /**
     * 
     *
     * Values: MALE,FEMALE
     */
    enum class userGender(val value: kotlin.String) {
        @Json(name = "male") MALE("male"),
        @Json(name = "female") FEMALE("female");
    }
}
openapi-generator version

7.6.0, yes, a regression

OpenAPI declaration file content or url
            "FavoritesEndpoint_Items": {
                "type": "object",
                "properties": {
                    "user_gender": {
                        "type": "string",
                        "enum": [
                            "male",
                            "female"
                        ]
                    }
                },
                "required": [
                ]
            },
Related issues/PRs
hrach commented 1 month ago

Tested 7.5.0, it is broken as well, so it is in its changes.

piotrantosik commented 2 weeks ago

Error still occurs in 7.7.0

egrimstad commented 1 week ago

I also had this problem, and finally found out it was due to me having overridden the data_class.mustache template. There seems to have been quite a few changes to the template since 7.4.0 (https://github.com/OpenAPITools/openapi-generator/commits/master/modules/openapi-generator/src/main/resources/kotlin-client/data_class.mustache), so when I updated my local override the issue was fixed.