Skip to content

Commit

Permalink
[Kotlin Server] Remove the option to enable Kotlin serialization
Browse files Browse the repository at this point in the history
  • Loading branch information
Stexxe committed Dec 10, 2024
1 parent 4763a37 commit c345e6a
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 34 deletions.
1 change: 0 additions & 1 deletion docs/generators/kotlin-server.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|apiSuffix|suffix for api classes| |Api|
|artifactId|Generated artifact id (name of jar).| |kotlin-server|
|artifactVersion|Generated artifact's package version.| |1.0.0|
|enableKotlinSerialization|enableKotlinSerialization| |true|
|enumPropertyNaming|Naming convention for enum properties: 'camelCase', 'PascalCase', 'snake_case', 'UPPERCASE', and 'original'| |original|
|featureAutoHead|Automatically provide responses to HEAD requests for existing routes that have the GET verb defined.| |true|
|featureCORS|Ktor by default provides an interceptor for implementing proper support for Cross-Origin Resource Sharing (CORS). See enable-cors.org.| |false|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,6 @@ public class KotlinServerCodegen extends AbstractKotlinCodegen implements BeanVa
@Getter @Setter
private Boolean compressionFeatureEnabled = true;
@Getter @Setter
private Boolean kotlinSerializationEnabled = true;
@Getter @Setter
private Boolean resourcesFeatureEnabled = true;
@Getter @Setter
private Boolean metricsFeatureEnabled = true;
Expand Down Expand Up @@ -138,7 +136,6 @@ public KotlinServerCodegen() {
addSwitch(Constants.AUTOMATIC_HEAD_REQUESTS, Constants.AUTOMATIC_HEAD_REQUESTS_DESC, getAutoHeadFeatureEnabled());
addSwitch(Constants.CONDITIONAL_HEADERS, Constants.CONDITIONAL_HEADERS_DESC, getConditionalHeadersFeatureEnabled());
addSwitch(Constants.HSTS, Constants.HSTS_DESC, getHstsFeatureEnabled());
addSwitch(Constants.KOTLIN_SERIALIZATION, Constants.KOTLIN_SERIALIZATION, getKotlinSerializationEnabled());
addSwitch(Constants.CORS, Constants.CORS_DESC, getCorsFeatureEnabled());
addSwitch(Constants.COMPRESSION, Constants.COMPRESSION_DESC, getCompressionFeatureEnabled());
addSwitch(Constants.RESOURCES, Constants.RESOURCES_DESC, getResourcesFeatureEnabled());
Expand Down Expand Up @@ -295,11 +292,7 @@ public void processOpts() {
supportingFiles.add(new SupportingFile("gradle.properties", "", "gradle.properties"));

if (isKtor()) {
if (additionalProperties.containsKey(Constants.KOTLIN_SERIALIZATION)) {
setKotlinSerializationEnabled(convertPropertyToBooleanAndWriteBack(Constants.KOTLIN_SERIALIZATION));
} else {
additionalProperties.put(Constants.KOTLIN_SERIALIZATION, getKotlinSerializationEnabled());
}
additionalProperties.put(Constants.IS_KTOR, true);

supportingFiles.add(new SupportingFile("AppMain.kt.mustache", packageFolder, "AppMain.kt"));
supportingFiles.add(new SupportingFile("Configuration.kt.mustache", packageFolder, "Configuration.kt"));
Expand Down Expand Up @@ -367,7 +360,7 @@ public static class Constants {
public static final String USE_MUTINY_DESC = "Whether to use Mutiny (should not be used with useCoroutines). This option is currently supported only when using jaxrs-spec library.";
public static final String OMIT_GRADLE_WRAPPER = "omitGradleWrapper";
public static final String OMIT_GRADLE_WRAPPER_DESC = "Whether to omit Gradle wrapper for creating a sub project.";
public static final String KOTLIN_SERIALIZATION = "enableKotlinSerialization";
public static final String IS_KTOR = "isKtor";
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
{{#parcelizeModels}}
import android.os.Parcelable
import kotlinx.parcelize.Parcelize
{{/parcelizeModels}}
{{#serializableModel}}
import java.io.Serializable
{{/serializableModel}}
{{#enableKotlinSerialization}}
{{#isKtor}}
import kotlinx.serialization.Serializable
{{/enableKotlinSerialization}}
{{/isKtor}}
{{^isKtor}}
{{#parcelizeModels}}
import android.os.Parcelable
import kotlinx.parcelize.Parcelize
{{/parcelizeModels}}
{{#serializableModel}}
import java.io.Serializable
{{/serializableModel}}
{{/isKtor}}
/**
* {{{description}}}
{{#vars}}
Expand All @@ -17,16 +19,16 @@ import kotlinx.serialization.Serializable
{{#parcelizeModels}}
@Parcelize
{{/parcelizeModels}}
{{#enableKotlinSerialization}}
{{#isKtor}}
@Serializable
{{/enableKotlinSerialization}}
{{/isKtor}}
{{#hasVars}}data {{/hasVars}}class {{classname}}(
{{#requiredVars}}
{{>data_class_req_var}}{{^-last}},
{{/-last}}{{/requiredVars}}{{#hasRequired}}{{#hasOptional}},
{{/hasOptional}}{{/hasRequired}}{{#optionalVars}}{{>data_class_opt_var}}{{^-last}},
{{/-last}}{{/optionalVars}}
){{^serializableModel}}{{#parcelizeModels}} : Parcelable{{/parcelizeModels}}{{/serializableModel}}{{^parcelizeModels}}{{#serializableModel}}: Serializable {{/serializableModel}}{{/parcelizeModels}}{{#parcelizeModels}}{{#serializableModel}} : Parcelable, Serializable {{/serializableModel}}{{/parcelizeModels}}
){{^isKtor}}{{^serializableModel}}{{#parcelizeModels}} : Parcelable{{/parcelizeModels}}{{/serializableModel}}{{^parcelizeModels}}{{#serializableModel}}: Serializable {{/serializableModel}}{{/parcelizeModels}}{{#parcelizeModels}}{{#serializableModel}} : Parcelable, Serializable {{/serializableModel}}{{/parcelizeModels}}{{/isKtor}}
{{#vendorExtensions.x-has-data-class-body}}
{
{{/vendorExtensions.x-has-data-class-body}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
package org.openapitools.server.models


import java.io.Serializable
import kotlinx.serialization.Serializable
/**
* A category for a pet
Expand All @@ -23,7 +22,7 @@ import kotlinx.serialization.Serializable
data class Category(
val id: kotlin.Long? = null,
val name: kotlin.String? = null
): Serializable
)
{
}

Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
package org.openapitools.server.models


import java.io.Serializable
import kotlinx.serialization.Serializable
/**
* Describes the result of uploading an image resource
Expand All @@ -25,7 +24,7 @@ data class ModelApiResponse(
val code: kotlin.Int? = null,
val type: kotlin.String? = null,
val message: kotlin.String? = null
): Serializable
)
{
}

Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
package org.openapitools.server.models


import java.io.Serializable
import kotlinx.serialization.Serializable
/**
* An order for a pets from the pet store
Expand All @@ -32,7 +31,7 @@ data class Order(
/* Order Status */
val status: Order.Status? = null,
val complete: kotlin.Boolean? = false
): Serializable
)
{
/**
* Order Status
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ package org.openapitools.server.models
import org.openapitools.server.models.Category
import org.openapitools.server.models.Tag

import java.io.Serializable
import kotlinx.serialization.Serializable
/**
* A pet for sale in the pet store
Expand All @@ -34,7 +33,7 @@ data class Pet(
val tags: kotlin.collections.List<Tag>? = null,
/* pet status in the store */
val status: Pet.Status? = null
): Serializable
)
{
/**
* pet status in the store
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
package org.openapitools.server.models


import java.io.Serializable
import kotlinx.serialization.Serializable
/**
* A tag for a pet
Expand All @@ -23,7 +22,7 @@ import kotlinx.serialization.Serializable
data class Tag(
val id: kotlin.Long? = null,
val name: kotlin.String? = null
): Serializable
)
{
}

Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
package org.openapitools.server.models


import java.io.Serializable
import kotlinx.serialization.Serializable
/**
* A User who is purchasing from the pet store
Expand All @@ -36,7 +35,7 @@ data class User(
val phone: kotlin.String? = null,
/* User Status */
val userStatus: kotlin.Int? = null
): Serializable
)
{
}

0 comments on commit c345e6a

Please sign in to comment.