forked from loafle/openapi-generator-original
[kotlin][client] Kotlinx Serialization code formating (#12922)
* [kotlin][client] Kotlinx Serialization cleanup * [kotlin][client] Kotlinx Serialization cleanup
This commit is contained in:
parent
1a5b5924ed
commit
8d62e597ae
@ -596,13 +596,13 @@ public class KotlinClientCodegen extends AbstractKotlinCodegen {
|
||||
|
||||
private void addSupportingSerializerAdapters(final String infrastructureFolder) {
|
||||
supportingFiles.add(new SupportingFile("jvm-common/infrastructure/Serializer.kt.mustache", infrastructureFolder, "Serializer.kt"));
|
||||
supportingFiles.add(new SupportingFile("jvm-common/infrastructure/ByteArrayAdapter.kt.mustache", infrastructureFolder, "ByteArrayAdapter.kt"));
|
||||
|
||||
switch (getSerializationLibrary()) {
|
||||
case moshi:
|
||||
if (enumUnknownDefaultCase) {
|
||||
supportingFiles.add(new SupportingFile("jvm-common/infrastructure/SerializerHelper.kt.mustache", infrastructureFolder, "SerializerHelper.kt"));
|
||||
}
|
||||
supportingFiles.add(new SupportingFile("jvm-common/infrastructure/ByteArrayAdapter.kt.mustache", infrastructureFolder, "ByteArrayAdapter.kt"));
|
||||
supportingFiles.add(new SupportingFile("jvm-common/infrastructure/UUIDAdapter.kt.mustache", infrastructureFolder, "UUIDAdapter.kt"));
|
||||
supportingFiles.add(new SupportingFile("jvm-common/infrastructure/LocalDateAdapter.kt.mustache", infrastructureFolder, "LocalDateAdapter.kt"));
|
||||
supportingFiles.add(new SupportingFile("jvm-common/infrastructure/LocalDateTimeAdapter.kt.mustache", infrastructureFolder, "LocalDateTimeAdapter.kt"));
|
||||
@ -613,6 +613,7 @@ public class KotlinClientCodegen extends AbstractKotlinCodegen {
|
||||
break;
|
||||
|
||||
case gson:
|
||||
supportingFiles.add(new SupportingFile("jvm-common/infrastructure/ByteArrayAdapter.kt.mustache", infrastructureFolder, "ByteArrayAdapter.kt"));
|
||||
supportingFiles.add(new SupportingFile("jvm-common/infrastructure/LocalDateAdapter.kt.mustache", infrastructureFolder, "LocalDateAdapter.kt"));
|
||||
supportingFiles.add(new SupportingFile("jvm-common/infrastructure/LocalDateTimeAdapter.kt.mustache", infrastructureFolder, "LocalDateTimeAdapter.kt"));
|
||||
supportingFiles.add(new SupportingFile("jvm-common/infrastructure/OffsetDateTimeAdapter.kt.mustache", infrastructureFolder, "OffsetDateTimeAdapter.kt"));
|
||||
|
@ -10,7 +10,7 @@ import kotlinx.serialization.descriptors.SerialDescriptor
|
||||
import java.util.concurrent.atomic.AtomicBoolean
|
||||
|
||||
@Serializer(forClass = AtomicBoolean::class)
|
||||
object AtomicBooleanAdapter : KSerializer<AtomicBoolean> {
|
||||
{{#nonPublicApi}}internal {{/nonPublicApi}}object AtomicBooleanAdapter : KSerializer<AtomicBoolean> {
|
||||
override fun serialize(encoder: Encoder, value: AtomicBoolean) {
|
||||
encoder.encodeBoolean(value.get())
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ import kotlinx.serialization.descriptors.SerialDescriptor
|
||||
import java.util.concurrent.atomic.AtomicInteger
|
||||
|
||||
@Serializer(forClass = AtomicInteger::class)
|
||||
object AtomicIntegerAdapter : KSerializer<AtomicInteger> {
|
||||
{{#nonPublicApi}}internal {{/nonPublicApi}}object AtomicIntegerAdapter : KSerializer<AtomicInteger> {
|
||||
override fun serialize(encoder: Encoder, value: AtomicInteger) {
|
||||
encoder.encodeInt(value.get())
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ import kotlinx.serialization.descriptors.SerialDescriptor
|
||||
import java.util.concurrent.atomic.AtomicLong
|
||||
|
||||
@Serializer(forClass = AtomicLong::class)
|
||||
object AtomicLongAdapter : KSerializer<AtomicLong> {
|
||||
{{#nonPublicApi}}internal {{/nonPublicApi}}object AtomicLongAdapter : KSerializer<AtomicLong> {
|
||||
override fun serialize(encoder: Encoder, value: AtomicLong) {
|
||||
encoder.encodeLong(value.get())
|
||||
}
|
||||
|
@ -15,12 +15,16 @@ import com.squareup.moshi.ToJson
|
||||
{{/moshi}}
|
||||
import java.math.BigDecimal
|
||||
|
||||
{{#kotlinx_serialization}}@Serializer(forClass = BigDecimal::class)
|
||||
object BigDecimalAdapter : KSerializer<BigDecimal> {
|
||||
{{#kotlinx_serialization}}
|
||||
@Serializer(forClass = BigDecimal::class)
|
||||
{{#nonPublicApi}}internal {{/nonPublicApi}}object BigDecimalAdapter : KSerializer<BigDecimal> {
|
||||
override val descriptor: SerialDescriptor = PrimitiveSerialDescriptor("BigDecimal", PrimitiveKind.STRING)
|
||||
override fun deserialize(decoder: Decoder): BigDecimal = BigDecimal(decoder.decodeString())
|
||||
override fun serialize(encoder: Encoder, value: BigDecimal) = encoder.encodeString(value.toPlainString())
|
||||
}{{/kotlinx_serialization}}{{#moshi}}{{#nonPublicApi}}internal {{/nonPublicApi}}class BigDecimalAdapter {
|
||||
}
|
||||
{{/kotlinx_serialization}}
|
||||
{{#moshi}}
|
||||
{{#nonPublicApi}}internal {{/nonPublicApi}}class BigDecimalAdapter {
|
||||
@ToJson
|
||||
fun toJson(value: BigDecimal): String {
|
||||
return value.toPlainString()
|
||||
@ -30,4 +34,5 @@ object BigDecimalAdapter : KSerializer<BigDecimal> {
|
||||
fun fromJson(value: String): BigDecimal {
|
||||
return BigDecimal(value)
|
||||
}
|
||||
}{{/moshi}}
|
||||
}
|
||||
{{/moshi}}
|
||||
|
@ -15,8 +15,9 @@ import com.squareup.moshi.ToJson
|
||||
{{/moshi}}
|
||||
import java.math.BigInteger
|
||||
|
||||
{{#kotlinx_serialization}}@Serializer(forClass = BigInteger::class)
|
||||
object BigIntegerAdapter : KSerializer<BigInteger> {
|
||||
{{#kotlinx_serialization}}
|
||||
@Serializer(forClass = BigInteger::class)
|
||||
{{#nonPublicApi}}internal {{/nonPublicApi}}object BigIntegerAdapter : KSerializer<BigInteger> {
|
||||
override val descriptor: SerialDescriptor = PrimitiveSerialDescriptor("BigInteger", PrimitiveKind.STRING)
|
||||
override fun deserialize(decoder: Decoder): BigInteger {
|
||||
return BigInteger(decoder.decodeString())
|
||||
@ -25,7 +26,10 @@ object BigIntegerAdapter : KSerializer<BigInteger> {
|
||||
override fun serialize(encoder: Encoder, value: BigInteger) {
|
||||
encoder.encodeString(value.toString())
|
||||
}
|
||||
}{{/kotlinx_serialization}}{{#moshi}}{{#nonPublicApi}}internal {{/nonPublicApi}}class BigIntegerAdapter {
|
||||
}
|
||||
{{/kotlinx_serialization}}
|
||||
{{#moshi}}
|
||||
{{#nonPublicApi}}internal {{/nonPublicApi}}class BigIntegerAdapter {
|
||||
@ToJson
|
||||
fun toJson(value: BigInteger): String {
|
||||
return value.toString()
|
||||
@ -35,4 +39,5 @@ object BigIntegerAdapter : KSerializer<BigInteger> {
|
||||
fun fromJson(value: String): BigInteger {
|
||||
return BigInteger(value)
|
||||
}
|
||||
}{{/moshi}}
|
||||
}
|
||||
{{/moshi}}
|
@ -9,7 +9,7 @@ import kotlinx.serialization.descriptors.PrimitiveKind
|
||||
import kotlinx.serialization.descriptors.SerialDescriptor
|
||||
|
||||
@Serializer(forClass = StringBuilder::class)
|
||||
object StringBuilderAdapter : KSerializer<StringBuilder> {
|
||||
{{#nonPublicApi}}internal {{/nonPublicApi}}object StringBuilderAdapter : KSerializer<StringBuilder> {
|
||||
override fun serialize(encoder: Encoder, value: StringBuilder) {
|
||||
encoder.encodeString(value.toString())
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ import kotlinx.serialization.descriptors.SerialDescriptor
|
||||
import java.net.URL
|
||||
|
||||
@Serializer(forClass = URL::class)
|
||||
object URLAdapter : KSerializer<URL> {
|
||||
{{#nonPublicApi}}internal {{/nonPublicApi}}object URLAdapter : KSerializer<URL> {
|
||||
override fun serialize(encoder: Encoder, value: URL) {
|
||||
encoder.encodeString(value.toExternalForm())
|
||||
}
|
||||
|
@ -20,7 +20,6 @@ src/main/kotlin/org/openapitools/client/apis/UserApi.kt
|
||||
src/main/kotlin/org/openapitools/client/infrastructure/ApiAbstractions.kt
|
||||
src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt
|
||||
src/main/kotlin/org/openapitools/client/infrastructure/ApiResponse.kt
|
||||
src/main/kotlin/org/openapitools/client/infrastructure/ByteArrayAdapter.kt
|
||||
src/main/kotlin/org/openapitools/client/infrastructure/Errors.kt
|
||||
src/main/kotlin/org/openapitools/client/infrastructure/PartConfig.kt
|
||||
src/main/kotlin/org/openapitools/client/infrastructure/RequestConfig.kt
|
||||
|
@ -28,7 +28,6 @@ src/main/kotlin/org/openapitools/client/infrastructure/AtomicIntegerAdapter.kt
|
||||
src/main/kotlin/org/openapitools/client/infrastructure/AtomicLongAdapter.kt
|
||||
src/main/kotlin/org/openapitools/client/infrastructure/BigDecimalAdapter.kt
|
||||
src/main/kotlin/org/openapitools/client/infrastructure/BigIntegerAdapter.kt
|
||||
src/main/kotlin/org/openapitools/client/infrastructure/ByteArrayAdapter.kt
|
||||
src/main/kotlin/org/openapitools/client/infrastructure/CollectionFormats.kt
|
||||
src/main/kotlin/org/openapitools/client/infrastructure/LocalDateAdapter.kt
|
||||
src/main/kotlin/org/openapitools/client/infrastructure/LocalDateTimeAdapter.kt
|
||||
|
@ -1,3 +0,0 @@
|
||||
package org.openapitools.client.infrastructure
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user