diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractKotlinCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractKotlinCodegen.java index a00fc670c3c4..e980427505ef 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractKotlinCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractKotlinCodegen.java @@ -416,6 +416,10 @@ public abstract class AbstractKotlinCodegen extends DefaultCodegen implements Co LOGGER.info("NOTE: To enable file post-processing, 'enablePostProcessFile' must be set to `true` (--enable-post-process-file for CLI)."); } + if (additionalProperties.containsKey(MODEL_MUTABLE)) { + additionalProperties.put(MODEL_MUTABLE, Boolean.parseBoolean(additionalProperties.get(MODEL_MUTABLE).toString())); + } + if (additionalProperties.containsKey(CodegenConstants.ENUM_PROPERTY_NAMING)) { setEnumPropertyNaming((String) additionalProperties.get(CodegenConstants.ENUM_PROPERTY_NAMING)); } diff --git a/samples/server/petstore/kotlin/vertx/src/main/kotlin/org/openapitools/server/api/model/Category.kt b/samples/server/petstore/kotlin/vertx/src/main/kotlin/org/openapitools/server/api/model/Category.kt index 29aaa19c2c2f..7768072a83d8 100644 --- a/samples/server/petstore/kotlin/vertx/src/main/kotlin/org/openapitools/server/api/model/Category.kt +++ b/samples/server/petstore/kotlin/vertx/src/main/kotlin/org/openapitools/server/api/model/Category.kt @@ -24,8 +24,8 @@ import com.fasterxml.jackson.annotation.JsonInclude @JsonInclude(JsonInclude.Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) data class Category ( - var id: kotlin.Long? = null, - var name: kotlin.String? = null + val id: kotlin.Long? = null, + val name: kotlin.String? = null ) { } diff --git a/samples/server/petstore/kotlin/vertx/src/main/kotlin/org/openapitools/server/api/model/ModelApiResponse.kt b/samples/server/petstore/kotlin/vertx/src/main/kotlin/org/openapitools/server/api/model/ModelApiResponse.kt index ce8326960332..332a3c0f6e7b 100644 --- a/samples/server/petstore/kotlin/vertx/src/main/kotlin/org/openapitools/server/api/model/ModelApiResponse.kt +++ b/samples/server/petstore/kotlin/vertx/src/main/kotlin/org/openapitools/server/api/model/ModelApiResponse.kt @@ -25,9 +25,9 @@ import com.fasterxml.jackson.annotation.JsonInclude @JsonInclude(JsonInclude.Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) data class ModelApiResponse ( - var code: kotlin.Int? = null, - var type: kotlin.String? = null, - var message: kotlin.String? = null + val code: kotlin.Int? = null, + val type: kotlin.String? = null, + val message: kotlin.String? = null ) { } diff --git a/samples/server/petstore/kotlin/vertx/src/main/kotlin/org/openapitools/server/api/model/Order.kt b/samples/server/petstore/kotlin/vertx/src/main/kotlin/org/openapitools/server/api/model/Order.kt index a25f7e74bc7f..9078e0bdd256 100644 --- a/samples/server/petstore/kotlin/vertx/src/main/kotlin/org/openapitools/server/api/model/Order.kt +++ b/samples/server/petstore/kotlin/vertx/src/main/kotlin/org/openapitools/server/api/model/Order.kt @@ -28,13 +28,13 @@ import com.fasterxml.jackson.annotation.JsonInclude @JsonInclude(JsonInclude.Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) data class Order ( - var id: kotlin.Long? = null, - var petId: kotlin.Long? = null, - var quantity: kotlin.Int? = null, - var shipDate: java.time.OffsetDateTime? = null, + val id: kotlin.Long? = null, + val petId: kotlin.Long? = null, + val quantity: kotlin.Int? = null, + val shipDate: java.time.OffsetDateTime? = null, /* Order Status */ - var status: Order.Status? = null, - var complete: kotlin.Boolean? = false + val status: Order.Status? = null, + val complete: kotlin.Boolean? = false ) { /** diff --git a/samples/server/petstore/kotlin/vertx/src/main/kotlin/org/openapitools/server/api/model/Pet.kt b/samples/server/petstore/kotlin/vertx/src/main/kotlin/org/openapitools/server/api/model/Pet.kt index e80d49fc3f5f..6061c8e01549 100644 --- a/samples/server/petstore/kotlin/vertx/src/main/kotlin/org/openapitools/server/api/model/Pet.kt +++ b/samples/server/petstore/kotlin/vertx/src/main/kotlin/org/openapitools/server/api/model/Pet.kt @@ -30,13 +30,13 @@ import com.fasterxml.jackson.annotation.JsonInclude @JsonInclude(JsonInclude.Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) data class Pet ( - @SerializedName("name") private var _name: kotlin.String?, - @SerializedName("photoUrls") private var _photoUrls: kotlin.Array?, - var id: kotlin.Long? = null, - var category: Category? = null, - var tags: kotlin.Array? = null, + @SerializedName("name") private val _name: kotlin.String?, + @SerializedName("photoUrls") private val _photoUrls: kotlin.Array?, + val id: kotlin.Long? = null, + val category: Category? = null, + val tags: kotlin.Array? = null, /* pet status in the store */ - var status: Pet.Status? = null + val status: Pet.Status? = null ) { /** @@ -53,9 +53,9 @@ data class Pet ( } - var name get() = _name ?: throw IllegalArgumentException("name is required") - set(value){ _name = value } - var photoUrls get() = _photoUrls ?: throw IllegalArgumentException("photoUrls is required") - set(value){ _photoUrls = value } + val name get() = _name ?: throw IllegalArgumentException("name is required") + + val photoUrls get() = _photoUrls ?: throw IllegalArgumentException("photoUrls is required") + } diff --git a/samples/server/petstore/kotlin/vertx/src/main/kotlin/org/openapitools/server/api/model/Tag.kt b/samples/server/petstore/kotlin/vertx/src/main/kotlin/org/openapitools/server/api/model/Tag.kt index 359a53af6091..b444b341a9e3 100644 --- a/samples/server/petstore/kotlin/vertx/src/main/kotlin/org/openapitools/server/api/model/Tag.kt +++ b/samples/server/petstore/kotlin/vertx/src/main/kotlin/org/openapitools/server/api/model/Tag.kt @@ -24,8 +24,8 @@ import com.fasterxml.jackson.annotation.JsonInclude @JsonInclude(JsonInclude.Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) data class Tag ( - var id: kotlin.Long? = null, - var name: kotlin.String? = null + val id: kotlin.Long? = null, + val name: kotlin.String? = null ) { } diff --git a/samples/server/petstore/kotlin/vertx/src/main/kotlin/org/openapitools/server/api/model/User.kt b/samples/server/petstore/kotlin/vertx/src/main/kotlin/org/openapitools/server/api/model/User.kt index 791d0b882333..e8b5bb5e7051 100644 --- a/samples/server/petstore/kotlin/vertx/src/main/kotlin/org/openapitools/server/api/model/User.kt +++ b/samples/server/petstore/kotlin/vertx/src/main/kotlin/org/openapitools/server/api/model/User.kt @@ -30,15 +30,15 @@ import com.fasterxml.jackson.annotation.JsonInclude @JsonInclude(JsonInclude.Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) data class User ( - var id: kotlin.Long? = null, - var username: kotlin.String? = null, - var firstName: kotlin.String? = null, - var lastName: kotlin.String? = null, - var email: kotlin.String? = null, - var password: kotlin.String? = null, - var phone: kotlin.String? = null, + val id: kotlin.Long? = null, + val username: kotlin.String? = null, + val firstName: kotlin.String? = null, + val lastName: kotlin.String? = null, + val email: kotlin.String? = null, + val password: kotlin.String? = null, + val phone: kotlin.String? = null, /* User Status */ - var userStatus: kotlin.Int? = null + val userStatus: kotlin.Int? = null ) { }