You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am using the OpenApiGenerator via the Gradle plugin in my Kotlin Android project. I noticed an issue where the configuration value for mutable model attributes is not working as expected.
I have noticed that in my particular case, setting any value results in mutable models. The lack of a value all together is what actually results in immutable models.
For example, if I set mutableModel to either true or false, the models generated are made up of all var attributes:
@Parcelize
@JsonClass(generateAdapter = true)
data class UserDto (
@Json(name = "id")
var id: kotlin.String,
@Json(name = "email")
var email: kotlin.String,
@Json(name = "isVerified")
var isVerified: kotlin.Boolean,
@Json(name = "givenName")
var givenName: kotlin.String,
@Json(name = "familyName")
var familyName: kotlin.String
) : Parcelable
If I leave the configuration value off completely, attributes default to val:
@Parcelize
@JsonClass(generateAdapter = true)
data class UserDto (
@Json(name = "id")
val id: kotlin.String,
@Json(name = "email")
val email: kotlin.String,
@Json(name = "isVerified")
val isVerified: kotlin.Boolean,
@Json(name = "givenName")
val givenName: kotlin.String,
@Json(name = "familyName")
val familyName: kotlin.String
) : Parcelable
Description
I am using the OpenApiGenerator via the Gradle plugin in my Kotlin Android project. I noticed an issue where the configuration value for mutable model attributes is not working as expected.
According to the documentation for the Kotlin generator, a configuration option for
mutableModel
can be set. The description of this option is simply, "Create mutable models" and the default value isfalse
.https://github.com/OpenAPITools/openapi-generator/blob/master/docs/generators/kotlin.md
I have noticed that in my particular case, setting any value results in mutable models. The lack of a value all together is what actually results in immutable models.
For example, if I set
mutableModel
to eithertrue
orfalse
, the models generated are made up of allvar
attributes:If I leave the configuration value off completely, attributes default to
val
:My Configuration
build.gradle
App-level build.gradle:
openapi-generator-config.json
Related Tickets
#4115
#3803
The text was updated successfully, but these errors were encountered: