From 05bd4e17600f45a3dffaff364db03f5b4c6975f2 Mon Sep 17 00:00:00 2001 From: Nikita Karnaukh Date: Sun, 22 Nov 2020 19:46:59 +0300 Subject: [PATCH] Added BigDecimalAdapter and BigIntegerAdapter adapter for Kotlin Client Moshi --- .../languages/KotlinClientCodegen.java | 2 ++ .../BigDecimalAdapter.kt.mustache | 20 +++++++++++++++++-- .../BigIntegerAdapter.kt.mustache | 20 +++++++++++++++++-- .../infrastructure/Serializer.kt.mustache | 2 ++ .../codegen/DefaultGeneratorTest.java | 8 ++++---- .../.openapi-generator/FILES | 2 ++ .../infrastructure/BigDecimalAdapter.kt | 17 ++++++++++++++++ .../infrastructure/BigIntegerAdapter.kt | 17 ++++++++++++++++ .../client/infrastructure/Serializer.kt | 2 ++ .../.openapi-generator/FILES | 2 ++ .../infrastructure/BigDecimalAdapter.kt | 17 ++++++++++++++++ .../infrastructure/BigIntegerAdapter.kt | 17 ++++++++++++++++ .../client/infrastructure/Serializer.kt | 2 ++ .../kotlin-nonpublic/.openapi-generator/FILES | 2 ++ .../infrastructure/BigDecimalAdapter.kt | 17 ++++++++++++++++ .../infrastructure/BigIntegerAdapter.kt | 17 ++++++++++++++++ .../client/infrastructure/Serializer.kt | 2 ++ .../kotlin-nullable/.openapi-generator/FILES | 2 ++ .../infrastructure/BigDecimalAdapter.kt | 17 ++++++++++++++++ .../infrastructure/BigIntegerAdapter.kt | 17 ++++++++++++++++ .../client/infrastructure/Serializer.kt | 2 ++ .../kotlin-okhttp3/.openapi-generator/FILES | 2 ++ .../infrastructure/BigDecimalAdapter.kt | 17 ++++++++++++++++ .../infrastructure/BigIntegerAdapter.kt | 17 ++++++++++++++++ .../client/infrastructure/Serializer.kt | 2 ++ .../.openapi-generator/FILES | 2 ++ .../infrastructure/BigDecimalAdapter.kt | 17 ++++++++++++++++ .../infrastructure/BigIntegerAdapter.kt | 17 ++++++++++++++++ .../client/infrastructure/Serializer.kt | 2 ++ .../kotlin-retrofit2/.openapi-generator/FILES | 2 ++ .../infrastructure/BigDecimalAdapter.kt | 17 ++++++++++++++++ .../infrastructure/BigIntegerAdapter.kt | 17 ++++++++++++++++ .../client/infrastructure/Serializer.kt | 2 ++ .../kotlin-string/.openapi-generator/FILES | 2 ++ .../infrastructure/BigDecimalAdapter.kt | 17 ++++++++++++++++ .../infrastructure/BigIntegerAdapter.kt | 17 ++++++++++++++++ .../client/infrastructure/Serializer.kt | 2 ++ .../.openapi-generator/FILES | 2 ++ .../infrastructure/BigDecimalAdapter.kt | 17 ++++++++++++++++ .../infrastructure/BigIntegerAdapter.kt | 17 ++++++++++++++++ .../client/infrastructure/Serializer.kt | 2 ++ .../petstore/kotlin/.openapi-generator/FILES | 2 ++ .../infrastructure/BigDecimalAdapter.kt | 17 ++++++++++++++++ .../infrastructure/BigIntegerAdapter.kt | 17 ++++++++++++++++ .../client/infrastructure/Serializer.kt | 2 ++ 45 files changed, 424 insertions(+), 8 deletions(-) create mode 100644 samples/client/petstore/kotlin-json-request-string/src/main/kotlin/org/openapitools/client/infrastructure/BigDecimalAdapter.kt create mode 100644 samples/client/petstore/kotlin-json-request-string/src/main/kotlin/org/openapitools/client/infrastructure/BigIntegerAdapter.kt create mode 100644 samples/client/petstore/kotlin-moshi-codegen/src/main/kotlin/org/openapitools/client/infrastructure/BigDecimalAdapter.kt create mode 100644 samples/client/petstore/kotlin-moshi-codegen/src/main/kotlin/org/openapitools/client/infrastructure/BigIntegerAdapter.kt create mode 100644 samples/client/petstore/kotlin-nonpublic/src/main/kotlin/org/openapitools/client/infrastructure/BigDecimalAdapter.kt create mode 100644 samples/client/petstore/kotlin-nonpublic/src/main/kotlin/org/openapitools/client/infrastructure/BigIntegerAdapter.kt create mode 100644 samples/client/petstore/kotlin-nullable/src/main/kotlin/org/openapitools/client/infrastructure/BigDecimalAdapter.kt create mode 100644 samples/client/petstore/kotlin-nullable/src/main/kotlin/org/openapitools/client/infrastructure/BigIntegerAdapter.kt create mode 100644 samples/client/petstore/kotlin-okhttp3/src/main/kotlin/org/openapitools/client/infrastructure/BigDecimalAdapter.kt create mode 100644 samples/client/petstore/kotlin-okhttp3/src/main/kotlin/org/openapitools/client/infrastructure/BigIntegerAdapter.kt create mode 100644 samples/client/petstore/kotlin-retrofit2-rx3/src/main/kotlin/org/openapitools/client/infrastructure/BigDecimalAdapter.kt create mode 100644 samples/client/petstore/kotlin-retrofit2-rx3/src/main/kotlin/org/openapitools/client/infrastructure/BigIntegerAdapter.kt create mode 100644 samples/client/petstore/kotlin-retrofit2/src/main/kotlin/org/openapitools/client/infrastructure/BigDecimalAdapter.kt create mode 100644 samples/client/petstore/kotlin-retrofit2/src/main/kotlin/org/openapitools/client/infrastructure/BigIntegerAdapter.kt create mode 100644 samples/client/petstore/kotlin-string/src/main/kotlin/org/openapitools/client/infrastructure/BigDecimalAdapter.kt create mode 100644 samples/client/petstore/kotlin-string/src/main/kotlin/org/openapitools/client/infrastructure/BigIntegerAdapter.kt create mode 100644 samples/client/petstore/kotlin-threetenbp/src/main/kotlin/org/openapitools/client/infrastructure/BigDecimalAdapter.kt create mode 100644 samples/client/petstore/kotlin-threetenbp/src/main/kotlin/org/openapitools/client/infrastructure/BigIntegerAdapter.kt create mode 100644 samples/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/infrastructure/BigDecimalAdapter.kt create mode 100644 samples/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/infrastructure/BigIntegerAdapter.kt diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/KotlinClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/KotlinClientCodegen.java index 4b470a95f570..5b7a4ec2bace 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/KotlinClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/KotlinClientCodegen.java @@ -464,6 +464,8 @@ private void addSupportingSerializerAdapters(final String infrastructureFolder) 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")); + supportingFiles.add(new SupportingFile("jvm-common/infrastructure/BigDecimalAdapter.kt.mustache", infrastructureFolder, "BigDecimalAdapter.kt")); + supportingFiles.add(new SupportingFile("jvm-common/infrastructure/BigIntegerAdapter.kt.mustache", infrastructureFolder, "BigIntegerAdapter.kt")); break; case gson: diff --git a/modules/openapi-generator/src/main/resources/kotlin-client/jvm-common/infrastructure/BigDecimalAdapter.kt.mustache b/modules/openapi-generator/src/main/resources/kotlin-client/jvm-common/infrastructure/BigDecimalAdapter.kt.mustache index 5efc613a20e5..7cc68c35cf1a 100644 --- a/modules/openapi-generator/src/main/resources/kotlin-client/jvm-common/infrastructure/BigDecimalAdapter.kt.mustache +++ b/modules/openapi-generator/src/main/resources/kotlin-client/jvm-common/infrastructure/BigDecimalAdapter.kt.mustache @@ -1,5 +1,6 @@ package {{packageName}}.infrastructure +{{#kotlinx_serialization}} import kotlinx.serialization.KSerializer import kotlinx.serialization.Serializer import kotlinx.serialization.encoding.Decoder @@ -7,13 +8,28 @@ import kotlinx.serialization.encoding.Encoder import kotlinx.serialization.descriptors.PrimitiveSerialDescriptor import kotlinx.serialization.descriptors.PrimitiveKind import kotlinx.serialization.descriptors.SerialDescriptor +{{/kotlinx_serialization}} +{{#moshi}} +import com.squareup.moshi.FromJson +import com.squareup.moshi.ToJson +{{/moshi}} import java.math.BigDecimal -@Serializer(forClass = BigDecimal::class) +{{#kotlinx_serialization}}@Serializer(forClass = BigDecimal::class) object BigDecimalAdapter : KSerializer { 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()) -} \ No newline at end of file +}{{/kotlinx_serialization}}{{#moshi}}{{#nonPublicApi}}internal {{/nonPublicApi}}class BigDecimalAdapter { + @ToJson + fun toJson(value: BigDecimal): String { + return value.toPlainString() + } + + @FromJson + fun fromJson(value: String): BigDecimal { + return BigDecimal(value) + } +}{{/moshi}} \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/kotlin-client/jvm-common/infrastructure/BigIntegerAdapter.kt.mustache b/modules/openapi-generator/src/main/resources/kotlin-client/jvm-common/infrastructure/BigIntegerAdapter.kt.mustache index bd2b4d3c8e9b..db86e143e143 100644 --- a/modules/openapi-generator/src/main/resources/kotlin-client/jvm-common/infrastructure/BigIntegerAdapter.kt.mustache +++ b/modules/openapi-generator/src/main/resources/kotlin-client/jvm-common/infrastructure/BigIntegerAdapter.kt.mustache @@ -1,5 +1,6 @@ package {{packageName}}.infrastructure +{{#kotlinx_serialization}} import kotlinx.serialization.KSerializer import kotlinx.serialization.Serializer import kotlinx.serialization.encoding.Decoder @@ -7,9 +8,14 @@ import kotlinx.serialization.encoding.Encoder import kotlinx.serialization.descriptors.PrimitiveSerialDescriptor import kotlinx.serialization.descriptors.PrimitiveKind import kotlinx.serialization.descriptors.SerialDescriptor +{{/kotlinx_serialization}} +{{#moshi}} +import com.squareup.moshi.FromJson +import com.squareup.moshi.ToJson +{{/moshi}} import java.math.BigInteger -@Serializer(forClass = BigInteger::class) +{{#kotlinx_serialization}}@Serializer(forClass = BigInteger::class) object BigIntegerAdapter : KSerializer { override val descriptor: SerialDescriptor = PrimitiveSerialDescriptor("BigInteger", PrimitiveKind.STRING) @@ -20,4 +26,14 @@ object BigIntegerAdapter : KSerializer { override fun serialize(encoder: Encoder, value: BigInteger) { encoder.encodeString(value.toString()) } -} \ No newline at end of file +}{{/kotlinx_serialization}}{{#moshi}}{{#nonPublicApi}}internal {{/nonPublicApi}}class BigIntegerAdapter { + @ToJson + fun toJson(value: BigInteger): String { + return value.toString() + } + + @FromJson + fun fromJson(value: String): BigInteger { + return BigInteger(value) + } +}{{/moshi}} \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/kotlin-client/jvm-common/infrastructure/Serializer.kt.mustache b/modules/openapi-generator/src/main/resources/kotlin-client/jvm-common/infrastructure/Serializer.kt.mustache index 4920d6b8f361..59146a842ebc 100644 --- a/modules/openapi-generator/src/main/resources/kotlin-client/jvm-common/infrastructure/Serializer.kt.mustache +++ b/modules/openapi-generator/src/main/resources/kotlin-client/jvm-common/infrastructure/Serializer.kt.mustache @@ -64,6 +64,8 @@ import java.util.concurrent.atomic.AtomicLong .add(LocalDateAdapter()) .add(UUIDAdapter()) .add(ByteArrayAdapter()) + .add(BigDecimalAdapter()) + .add(BigIntegerAdapter()) {{^moshiCodeGen}} .add(KotlinJsonAdapterFactory()) {{/moshiCodeGen}} diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/DefaultGeneratorTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/DefaultGeneratorTest.java index 13c710deeb37..d144f5bbc376 100644 --- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/DefaultGeneratorTest.java +++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/DefaultGeneratorTest.java @@ -459,7 +459,7 @@ public void testBuiltinLibraryTemplates() throws IOException { List files = generator.opts(clientOptInput).generate(); - Assert.assertEquals(files.size(), 25); + Assert.assertEquals(files.size(), 27); // Generator should report a library templated file as a generated file TestUtils.ensureContainsFile(files, output, "src/main/kotlin/org/openapitools/client/infrastructure/Errors.kt"); @@ -501,7 +501,7 @@ public void testBuiltinNonLibraryTemplates() throws IOException { List files = generator.opts(clientOptInput).generate(); - Assert.assertEquals(files.size(), 25); + Assert.assertEquals(files.size(), 27); // Generator should report README.md as a generated file TestUtils.ensureContainsFile(files, output, "README.md"); @@ -566,7 +566,7 @@ public void testCustomLibraryTemplates() throws IOException { List files = generator.opts(clientOptInput).generate(); - Assert.assertEquals(files.size(), 25); + Assert.assertEquals(files.size(), 27); // Generator should report a library templated file as a generated file TestUtils.ensureContainsFile(files, output, "src/main/kotlin/org/openapitools/client/infrastructure/Errors.kt"); @@ -620,7 +620,7 @@ public void testCustomNonLibraryTemplates() throws IOException { List files = generator.opts(clientOptInput).generate(); - Assert.assertEquals(files.size(), 25); + Assert.assertEquals(files.size(), 27); // Generator should report README.md as a generated file TestUtils.ensureContainsFile(files, output, "README.md"); diff --git a/samples/client/petstore/kotlin-json-request-string/.openapi-generator/FILES b/samples/client/petstore/kotlin-json-request-string/.openapi-generator/FILES index 905f2e1599e3..7c649eb5bd49 100644 --- a/samples/client/petstore/kotlin-json-request-string/.openapi-generator/FILES +++ b/samples/client/petstore/kotlin-json-request-string/.openapi-generator/FILES @@ -22,6 +22,8 @@ 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/ApiInfrastructureResponse.kt src/main/kotlin/org/openapitools/client/infrastructure/ApplicationDelegates.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/Errors.kt src/main/kotlin/org/openapitools/client/infrastructure/LocalDateAdapter.kt diff --git a/samples/client/petstore/kotlin-json-request-string/src/main/kotlin/org/openapitools/client/infrastructure/BigDecimalAdapter.kt b/samples/client/petstore/kotlin-json-request-string/src/main/kotlin/org/openapitools/client/infrastructure/BigDecimalAdapter.kt new file mode 100644 index 000000000000..fb2c972cf8d4 --- /dev/null +++ b/samples/client/petstore/kotlin-json-request-string/src/main/kotlin/org/openapitools/client/infrastructure/BigDecimalAdapter.kt @@ -0,0 +1,17 @@ +package org.openapitools.client.infrastructure + +import com.squareup.moshi.FromJson +import com.squareup.moshi.ToJson +import java.math.BigDecimal + +class BigDecimalAdapter { + @ToJson + fun toJson(value: BigDecimal): String { + return value.toPlainString() + } + + @FromJson + fun fromJson(value: String): BigDecimal { + return BigDecimal(value) + } +} \ No newline at end of file diff --git a/samples/client/petstore/kotlin-json-request-string/src/main/kotlin/org/openapitools/client/infrastructure/BigIntegerAdapter.kt b/samples/client/petstore/kotlin-json-request-string/src/main/kotlin/org/openapitools/client/infrastructure/BigIntegerAdapter.kt new file mode 100644 index 000000000000..4b6963110c9e --- /dev/null +++ b/samples/client/petstore/kotlin-json-request-string/src/main/kotlin/org/openapitools/client/infrastructure/BigIntegerAdapter.kt @@ -0,0 +1,17 @@ +package org.openapitools.client.infrastructure + +import com.squareup.moshi.FromJson +import com.squareup.moshi.ToJson +import java.math.BigInteger + +class BigIntegerAdapter { + @ToJson + fun toJson(value: BigInteger): String { + return value.toString() + } + + @FromJson + fun fromJson(value: String): BigInteger { + return BigInteger(value) + } +} \ No newline at end of file diff --git a/samples/client/petstore/kotlin-json-request-string/src/main/kotlin/org/openapitools/client/infrastructure/Serializer.kt b/samples/client/petstore/kotlin-json-request-string/src/main/kotlin/org/openapitools/client/infrastructure/Serializer.kt index 697559b2ec16..888651c6c14d 100644 --- a/samples/client/petstore/kotlin-json-request-string/src/main/kotlin/org/openapitools/client/infrastructure/Serializer.kt +++ b/samples/client/petstore/kotlin-json-request-string/src/main/kotlin/org/openapitools/client/infrastructure/Serializer.kt @@ -14,6 +14,8 @@ object Serializer { .add(LocalDateAdapter()) .add(UUIDAdapter()) .add(ByteArrayAdapter()) + .add(BigDecimalAdapter()) + .add(BigIntegerAdapter()) .add(KotlinJsonAdapterFactory()) @JvmStatic diff --git a/samples/client/petstore/kotlin-moshi-codegen/.openapi-generator/FILES b/samples/client/petstore/kotlin-moshi-codegen/.openapi-generator/FILES index 905f2e1599e3..7c649eb5bd49 100644 --- a/samples/client/petstore/kotlin-moshi-codegen/.openapi-generator/FILES +++ b/samples/client/petstore/kotlin-moshi-codegen/.openapi-generator/FILES @@ -22,6 +22,8 @@ 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/ApiInfrastructureResponse.kt src/main/kotlin/org/openapitools/client/infrastructure/ApplicationDelegates.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/Errors.kt src/main/kotlin/org/openapitools/client/infrastructure/LocalDateAdapter.kt diff --git a/samples/client/petstore/kotlin-moshi-codegen/src/main/kotlin/org/openapitools/client/infrastructure/BigDecimalAdapter.kt b/samples/client/petstore/kotlin-moshi-codegen/src/main/kotlin/org/openapitools/client/infrastructure/BigDecimalAdapter.kt new file mode 100644 index 000000000000..fb2c972cf8d4 --- /dev/null +++ b/samples/client/petstore/kotlin-moshi-codegen/src/main/kotlin/org/openapitools/client/infrastructure/BigDecimalAdapter.kt @@ -0,0 +1,17 @@ +package org.openapitools.client.infrastructure + +import com.squareup.moshi.FromJson +import com.squareup.moshi.ToJson +import java.math.BigDecimal + +class BigDecimalAdapter { + @ToJson + fun toJson(value: BigDecimal): String { + return value.toPlainString() + } + + @FromJson + fun fromJson(value: String): BigDecimal { + return BigDecimal(value) + } +} \ No newline at end of file diff --git a/samples/client/petstore/kotlin-moshi-codegen/src/main/kotlin/org/openapitools/client/infrastructure/BigIntegerAdapter.kt b/samples/client/petstore/kotlin-moshi-codegen/src/main/kotlin/org/openapitools/client/infrastructure/BigIntegerAdapter.kt new file mode 100644 index 000000000000..4b6963110c9e --- /dev/null +++ b/samples/client/petstore/kotlin-moshi-codegen/src/main/kotlin/org/openapitools/client/infrastructure/BigIntegerAdapter.kt @@ -0,0 +1,17 @@ +package org.openapitools.client.infrastructure + +import com.squareup.moshi.FromJson +import com.squareup.moshi.ToJson +import java.math.BigInteger + +class BigIntegerAdapter { + @ToJson + fun toJson(value: BigInteger): String { + return value.toString() + } + + @FromJson + fun fromJson(value: String): BigInteger { + return BigInteger(value) + } +} \ No newline at end of file diff --git a/samples/client/petstore/kotlin-moshi-codegen/src/main/kotlin/org/openapitools/client/infrastructure/Serializer.kt b/samples/client/petstore/kotlin-moshi-codegen/src/main/kotlin/org/openapitools/client/infrastructure/Serializer.kt index 06d9fe0bdc8a..2db7c640224b 100644 --- a/samples/client/petstore/kotlin-moshi-codegen/src/main/kotlin/org/openapitools/client/infrastructure/Serializer.kt +++ b/samples/client/petstore/kotlin-moshi-codegen/src/main/kotlin/org/openapitools/client/infrastructure/Serializer.kt @@ -13,6 +13,8 @@ object Serializer { .add(LocalDateAdapter()) .add(UUIDAdapter()) .add(ByteArrayAdapter()) + .add(BigDecimalAdapter()) + .add(BigIntegerAdapter()) @JvmStatic val moshi: Moshi by lazy { diff --git a/samples/client/petstore/kotlin-nonpublic/.openapi-generator/FILES b/samples/client/petstore/kotlin-nonpublic/.openapi-generator/FILES index 905f2e1599e3..7c649eb5bd49 100644 --- a/samples/client/petstore/kotlin-nonpublic/.openapi-generator/FILES +++ b/samples/client/petstore/kotlin-nonpublic/.openapi-generator/FILES @@ -22,6 +22,8 @@ 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/ApiInfrastructureResponse.kt src/main/kotlin/org/openapitools/client/infrastructure/ApplicationDelegates.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/Errors.kt src/main/kotlin/org/openapitools/client/infrastructure/LocalDateAdapter.kt diff --git a/samples/client/petstore/kotlin-nonpublic/src/main/kotlin/org/openapitools/client/infrastructure/BigDecimalAdapter.kt b/samples/client/petstore/kotlin-nonpublic/src/main/kotlin/org/openapitools/client/infrastructure/BigDecimalAdapter.kt new file mode 100644 index 000000000000..8aa11ef98577 --- /dev/null +++ b/samples/client/petstore/kotlin-nonpublic/src/main/kotlin/org/openapitools/client/infrastructure/BigDecimalAdapter.kt @@ -0,0 +1,17 @@ +package org.openapitools.client.infrastructure + +import com.squareup.moshi.FromJson +import com.squareup.moshi.ToJson +import java.math.BigDecimal + +internal class BigDecimalAdapter { + @ToJson + fun toJson(value: BigDecimal): String { + return value.toPlainString() + } + + @FromJson + fun fromJson(value: String): BigDecimal { + return BigDecimal(value) + } +} \ No newline at end of file diff --git a/samples/client/petstore/kotlin-nonpublic/src/main/kotlin/org/openapitools/client/infrastructure/BigIntegerAdapter.kt b/samples/client/petstore/kotlin-nonpublic/src/main/kotlin/org/openapitools/client/infrastructure/BigIntegerAdapter.kt new file mode 100644 index 000000000000..fbd0beed7f28 --- /dev/null +++ b/samples/client/petstore/kotlin-nonpublic/src/main/kotlin/org/openapitools/client/infrastructure/BigIntegerAdapter.kt @@ -0,0 +1,17 @@ +package org.openapitools.client.infrastructure + +import com.squareup.moshi.FromJson +import com.squareup.moshi.ToJson +import java.math.BigInteger + +internal class BigIntegerAdapter { + @ToJson + fun toJson(value: BigInteger): String { + return value.toString() + } + + @FromJson + fun fromJson(value: String): BigInteger { + return BigInteger(value) + } +} \ No newline at end of file diff --git a/samples/client/petstore/kotlin-nonpublic/src/main/kotlin/org/openapitools/client/infrastructure/Serializer.kt b/samples/client/petstore/kotlin-nonpublic/src/main/kotlin/org/openapitools/client/infrastructure/Serializer.kt index 371e2a7013e5..ce9e152b0bb8 100644 --- a/samples/client/petstore/kotlin-nonpublic/src/main/kotlin/org/openapitools/client/infrastructure/Serializer.kt +++ b/samples/client/petstore/kotlin-nonpublic/src/main/kotlin/org/openapitools/client/infrastructure/Serializer.kt @@ -14,6 +14,8 @@ internal object Serializer { .add(LocalDateAdapter()) .add(UUIDAdapter()) .add(ByteArrayAdapter()) + .add(BigDecimalAdapter()) + .add(BigIntegerAdapter()) .add(KotlinJsonAdapterFactory()) @JvmStatic diff --git a/samples/client/petstore/kotlin-nullable/.openapi-generator/FILES b/samples/client/petstore/kotlin-nullable/.openapi-generator/FILES index 905f2e1599e3..7c649eb5bd49 100644 --- a/samples/client/petstore/kotlin-nullable/.openapi-generator/FILES +++ b/samples/client/petstore/kotlin-nullable/.openapi-generator/FILES @@ -22,6 +22,8 @@ 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/ApiInfrastructureResponse.kt src/main/kotlin/org/openapitools/client/infrastructure/ApplicationDelegates.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/Errors.kt src/main/kotlin/org/openapitools/client/infrastructure/LocalDateAdapter.kt diff --git a/samples/client/petstore/kotlin-nullable/src/main/kotlin/org/openapitools/client/infrastructure/BigDecimalAdapter.kt b/samples/client/petstore/kotlin-nullable/src/main/kotlin/org/openapitools/client/infrastructure/BigDecimalAdapter.kt new file mode 100644 index 000000000000..fb2c972cf8d4 --- /dev/null +++ b/samples/client/petstore/kotlin-nullable/src/main/kotlin/org/openapitools/client/infrastructure/BigDecimalAdapter.kt @@ -0,0 +1,17 @@ +package org.openapitools.client.infrastructure + +import com.squareup.moshi.FromJson +import com.squareup.moshi.ToJson +import java.math.BigDecimal + +class BigDecimalAdapter { + @ToJson + fun toJson(value: BigDecimal): String { + return value.toPlainString() + } + + @FromJson + fun fromJson(value: String): BigDecimal { + return BigDecimal(value) + } +} \ No newline at end of file diff --git a/samples/client/petstore/kotlin-nullable/src/main/kotlin/org/openapitools/client/infrastructure/BigIntegerAdapter.kt b/samples/client/petstore/kotlin-nullable/src/main/kotlin/org/openapitools/client/infrastructure/BigIntegerAdapter.kt new file mode 100644 index 000000000000..4b6963110c9e --- /dev/null +++ b/samples/client/petstore/kotlin-nullable/src/main/kotlin/org/openapitools/client/infrastructure/BigIntegerAdapter.kt @@ -0,0 +1,17 @@ +package org.openapitools.client.infrastructure + +import com.squareup.moshi.FromJson +import com.squareup.moshi.ToJson +import java.math.BigInteger + +class BigIntegerAdapter { + @ToJson + fun toJson(value: BigInteger): String { + return value.toString() + } + + @FromJson + fun fromJson(value: String): BigInteger { + return BigInteger(value) + } +} \ No newline at end of file diff --git a/samples/client/petstore/kotlin-nullable/src/main/kotlin/org/openapitools/client/infrastructure/Serializer.kt b/samples/client/petstore/kotlin-nullable/src/main/kotlin/org/openapitools/client/infrastructure/Serializer.kt index 697559b2ec16..888651c6c14d 100644 --- a/samples/client/petstore/kotlin-nullable/src/main/kotlin/org/openapitools/client/infrastructure/Serializer.kt +++ b/samples/client/petstore/kotlin-nullable/src/main/kotlin/org/openapitools/client/infrastructure/Serializer.kt @@ -14,6 +14,8 @@ object Serializer { .add(LocalDateAdapter()) .add(UUIDAdapter()) .add(ByteArrayAdapter()) + .add(BigDecimalAdapter()) + .add(BigIntegerAdapter()) .add(KotlinJsonAdapterFactory()) @JvmStatic diff --git a/samples/client/petstore/kotlin-okhttp3/.openapi-generator/FILES b/samples/client/petstore/kotlin-okhttp3/.openapi-generator/FILES index 905f2e1599e3..7c649eb5bd49 100644 --- a/samples/client/petstore/kotlin-okhttp3/.openapi-generator/FILES +++ b/samples/client/petstore/kotlin-okhttp3/.openapi-generator/FILES @@ -22,6 +22,8 @@ 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/ApiInfrastructureResponse.kt src/main/kotlin/org/openapitools/client/infrastructure/ApplicationDelegates.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/Errors.kt src/main/kotlin/org/openapitools/client/infrastructure/LocalDateAdapter.kt diff --git a/samples/client/petstore/kotlin-okhttp3/src/main/kotlin/org/openapitools/client/infrastructure/BigDecimalAdapter.kt b/samples/client/petstore/kotlin-okhttp3/src/main/kotlin/org/openapitools/client/infrastructure/BigDecimalAdapter.kt new file mode 100644 index 000000000000..fb2c972cf8d4 --- /dev/null +++ b/samples/client/petstore/kotlin-okhttp3/src/main/kotlin/org/openapitools/client/infrastructure/BigDecimalAdapter.kt @@ -0,0 +1,17 @@ +package org.openapitools.client.infrastructure + +import com.squareup.moshi.FromJson +import com.squareup.moshi.ToJson +import java.math.BigDecimal + +class BigDecimalAdapter { + @ToJson + fun toJson(value: BigDecimal): String { + return value.toPlainString() + } + + @FromJson + fun fromJson(value: String): BigDecimal { + return BigDecimal(value) + } +} \ No newline at end of file diff --git a/samples/client/petstore/kotlin-okhttp3/src/main/kotlin/org/openapitools/client/infrastructure/BigIntegerAdapter.kt b/samples/client/petstore/kotlin-okhttp3/src/main/kotlin/org/openapitools/client/infrastructure/BigIntegerAdapter.kt new file mode 100644 index 000000000000..4b6963110c9e --- /dev/null +++ b/samples/client/petstore/kotlin-okhttp3/src/main/kotlin/org/openapitools/client/infrastructure/BigIntegerAdapter.kt @@ -0,0 +1,17 @@ +package org.openapitools.client.infrastructure + +import com.squareup.moshi.FromJson +import com.squareup.moshi.ToJson +import java.math.BigInteger + +class BigIntegerAdapter { + @ToJson + fun toJson(value: BigInteger): String { + return value.toString() + } + + @FromJson + fun fromJson(value: String): BigInteger { + return BigInteger(value) + } +} \ No newline at end of file diff --git a/samples/client/petstore/kotlin-okhttp3/src/main/kotlin/org/openapitools/client/infrastructure/Serializer.kt b/samples/client/petstore/kotlin-okhttp3/src/main/kotlin/org/openapitools/client/infrastructure/Serializer.kt index 697559b2ec16..888651c6c14d 100644 --- a/samples/client/petstore/kotlin-okhttp3/src/main/kotlin/org/openapitools/client/infrastructure/Serializer.kt +++ b/samples/client/petstore/kotlin-okhttp3/src/main/kotlin/org/openapitools/client/infrastructure/Serializer.kt @@ -14,6 +14,8 @@ object Serializer { .add(LocalDateAdapter()) .add(UUIDAdapter()) .add(ByteArrayAdapter()) + .add(BigDecimalAdapter()) + .add(BigIntegerAdapter()) .add(KotlinJsonAdapterFactory()) @JvmStatic diff --git a/samples/client/petstore/kotlin-retrofit2-rx3/.openapi-generator/FILES b/samples/client/petstore/kotlin-retrofit2-rx3/.openapi-generator/FILES index f8c171a95c60..4e12e8dd2b39 100644 --- a/samples/client/petstore/kotlin-retrofit2-rx3/.openapi-generator/FILES +++ b/samples/client/petstore/kotlin-retrofit2-rx3/.openapi-generator/FILES @@ -23,6 +23,8 @@ src/main/kotlin/org/openapitools/client/auth/OAuth.kt src/main/kotlin/org/openapitools/client/auth/OAuthFlow.kt src/main/kotlin/org/openapitools/client/auth/OAuthOkHttpClient.kt src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.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 diff --git a/samples/client/petstore/kotlin-retrofit2-rx3/src/main/kotlin/org/openapitools/client/infrastructure/BigDecimalAdapter.kt b/samples/client/petstore/kotlin-retrofit2-rx3/src/main/kotlin/org/openapitools/client/infrastructure/BigDecimalAdapter.kt new file mode 100644 index 000000000000..fb2c972cf8d4 --- /dev/null +++ b/samples/client/petstore/kotlin-retrofit2-rx3/src/main/kotlin/org/openapitools/client/infrastructure/BigDecimalAdapter.kt @@ -0,0 +1,17 @@ +package org.openapitools.client.infrastructure + +import com.squareup.moshi.FromJson +import com.squareup.moshi.ToJson +import java.math.BigDecimal + +class BigDecimalAdapter { + @ToJson + fun toJson(value: BigDecimal): String { + return value.toPlainString() + } + + @FromJson + fun fromJson(value: String): BigDecimal { + return BigDecimal(value) + } +} \ No newline at end of file diff --git a/samples/client/petstore/kotlin-retrofit2-rx3/src/main/kotlin/org/openapitools/client/infrastructure/BigIntegerAdapter.kt b/samples/client/petstore/kotlin-retrofit2-rx3/src/main/kotlin/org/openapitools/client/infrastructure/BigIntegerAdapter.kt new file mode 100644 index 000000000000..4b6963110c9e --- /dev/null +++ b/samples/client/petstore/kotlin-retrofit2-rx3/src/main/kotlin/org/openapitools/client/infrastructure/BigIntegerAdapter.kt @@ -0,0 +1,17 @@ +package org.openapitools.client.infrastructure + +import com.squareup.moshi.FromJson +import com.squareup.moshi.ToJson +import java.math.BigInteger + +class BigIntegerAdapter { + @ToJson + fun toJson(value: BigInteger): String { + return value.toString() + } + + @FromJson + fun fromJson(value: String): BigInteger { + return BigInteger(value) + } +} \ No newline at end of file diff --git a/samples/client/petstore/kotlin-retrofit2-rx3/src/main/kotlin/org/openapitools/client/infrastructure/Serializer.kt b/samples/client/petstore/kotlin-retrofit2-rx3/src/main/kotlin/org/openapitools/client/infrastructure/Serializer.kt index 697559b2ec16..888651c6c14d 100644 --- a/samples/client/petstore/kotlin-retrofit2-rx3/src/main/kotlin/org/openapitools/client/infrastructure/Serializer.kt +++ b/samples/client/petstore/kotlin-retrofit2-rx3/src/main/kotlin/org/openapitools/client/infrastructure/Serializer.kt @@ -14,6 +14,8 @@ object Serializer { .add(LocalDateAdapter()) .add(UUIDAdapter()) .add(ByteArrayAdapter()) + .add(BigDecimalAdapter()) + .add(BigIntegerAdapter()) .add(KotlinJsonAdapterFactory()) @JvmStatic diff --git a/samples/client/petstore/kotlin-retrofit2/.openapi-generator/FILES b/samples/client/petstore/kotlin-retrofit2/.openapi-generator/FILES index f8c171a95c60..4e12e8dd2b39 100644 --- a/samples/client/petstore/kotlin-retrofit2/.openapi-generator/FILES +++ b/samples/client/petstore/kotlin-retrofit2/.openapi-generator/FILES @@ -23,6 +23,8 @@ src/main/kotlin/org/openapitools/client/auth/OAuth.kt src/main/kotlin/org/openapitools/client/auth/OAuthFlow.kt src/main/kotlin/org/openapitools/client/auth/OAuthOkHttpClient.kt src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.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 diff --git a/samples/client/petstore/kotlin-retrofit2/src/main/kotlin/org/openapitools/client/infrastructure/BigDecimalAdapter.kt b/samples/client/petstore/kotlin-retrofit2/src/main/kotlin/org/openapitools/client/infrastructure/BigDecimalAdapter.kt new file mode 100644 index 000000000000..fb2c972cf8d4 --- /dev/null +++ b/samples/client/petstore/kotlin-retrofit2/src/main/kotlin/org/openapitools/client/infrastructure/BigDecimalAdapter.kt @@ -0,0 +1,17 @@ +package org.openapitools.client.infrastructure + +import com.squareup.moshi.FromJson +import com.squareup.moshi.ToJson +import java.math.BigDecimal + +class BigDecimalAdapter { + @ToJson + fun toJson(value: BigDecimal): String { + return value.toPlainString() + } + + @FromJson + fun fromJson(value: String): BigDecimal { + return BigDecimal(value) + } +} \ No newline at end of file diff --git a/samples/client/petstore/kotlin-retrofit2/src/main/kotlin/org/openapitools/client/infrastructure/BigIntegerAdapter.kt b/samples/client/petstore/kotlin-retrofit2/src/main/kotlin/org/openapitools/client/infrastructure/BigIntegerAdapter.kt new file mode 100644 index 000000000000..4b6963110c9e --- /dev/null +++ b/samples/client/petstore/kotlin-retrofit2/src/main/kotlin/org/openapitools/client/infrastructure/BigIntegerAdapter.kt @@ -0,0 +1,17 @@ +package org.openapitools.client.infrastructure + +import com.squareup.moshi.FromJson +import com.squareup.moshi.ToJson +import java.math.BigInteger + +class BigIntegerAdapter { + @ToJson + fun toJson(value: BigInteger): String { + return value.toString() + } + + @FromJson + fun fromJson(value: String): BigInteger { + return BigInteger(value) + } +} \ No newline at end of file diff --git a/samples/client/petstore/kotlin-retrofit2/src/main/kotlin/org/openapitools/client/infrastructure/Serializer.kt b/samples/client/petstore/kotlin-retrofit2/src/main/kotlin/org/openapitools/client/infrastructure/Serializer.kt index 697559b2ec16..888651c6c14d 100644 --- a/samples/client/petstore/kotlin-retrofit2/src/main/kotlin/org/openapitools/client/infrastructure/Serializer.kt +++ b/samples/client/petstore/kotlin-retrofit2/src/main/kotlin/org/openapitools/client/infrastructure/Serializer.kt @@ -14,6 +14,8 @@ object Serializer { .add(LocalDateAdapter()) .add(UUIDAdapter()) .add(ByteArrayAdapter()) + .add(BigDecimalAdapter()) + .add(BigIntegerAdapter()) .add(KotlinJsonAdapterFactory()) @JvmStatic diff --git a/samples/client/petstore/kotlin-string/.openapi-generator/FILES b/samples/client/petstore/kotlin-string/.openapi-generator/FILES index 905f2e1599e3..7c649eb5bd49 100644 --- a/samples/client/petstore/kotlin-string/.openapi-generator/FILES +++ b/samples/client/petstore/kotlin-string/.openapi-generator/FILES @@ -22,6 +22,8 @@ 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/ApiInfrastructureResponse.kt src/main/kotlin/org/openapitools/client/infrastructure/ApplicationDelegates.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/Errors.kt src/main/kotlin/org/openapitools/client/infrastructure/LocalDateAdapter.kt diff --git a/samples/client/petstore/kotlin-string/src/main/kotlin/org/openapitools/client/infrastructure/BigDecimalAdapter.kt b/samples/client/petstore/kotlin-string/src/main/kotlin/org/openapitools/client/infrastructure/BigDecimalAdapter.kt new file mode 100644 index 000000000000..fb2c972cf8d4 --- /dev/null +++ b/samples/client/petstore/kotlin-string/src/main/kotlin/org/openapitools/client/infrastructure/BigDecimalAdapter.kt @@ -0,0 +1,17 @@ +package org.openapitools.client.infrastructure + +import com.squareup.moshi.FromJson +import com.squareup.moshi.ToJson +import java.math.BigDecimal + +class BigDecimalAdapter { + @ToJson + fun toJson(value: BigDecimal): String { + return value.toPlainString() + } + + @FromJson + fun fromJson(value: String): BigDecimal { + return BigDecimal(value) + } +} \ No newline at end of file diff --git a/samples/client/petstore/kotlin-string/src/main/kotlin/org/openapitools/client/infrastructure/BigIntegerAdapter.kt b/samples/client/petstore/kotlin-string/src/main/kotlin/org/openapitools/client/infrastructure/BigIntegerAdapter.kt new file mode 100644 index 000000000000..4b6963110c9e --- /dev/null +++ b/samples/client/petstore/kotlin-string/src/main/kotlin/org/openapitools/client/infrastructure/BigIntegerAdapter.kt @@ -0,0 +1,17 @@ +package org.openapitools.client.infrastructure + +import com.squareup.moshi.FromJson +import com.squareup.moshi.ToJson +import java.math.BigInteger + +class BigIntegerAdapter { + @ToJson + fun toJson(value: BigInteger): String { + return value.toString() + } + + @FromJson + fun fromJson(value: String): BigInteger { + return BigInteger(value) + } +} \ No newline at end of file diff --git a/samples/client/petstore/kotlin-string/src/main/kotlin/org/openapitools/client/infrastructure/Serializer.kt b/samples/client/petstore/kotlin-string/src/main/kotlin/org/openapitools/client/infrastructure/Serializer.kt index 697559b2ec16..888651c6c14d 100644 --- a/samples/client/petstore/kotlin-string/src/main/kotlin/org/openapitools/client/infrastructure/Serializer.kt +++ b/samples/client/petstore/kotlin-string/src/main/kotlin/org/openapitools/client/infrastructure/Serializer.kt @@ -14,6 +14,8 @@ object Serializer { .add(LocalDateAdapter()) .add(UUIDAdapter()) .add(ByteArrayAdapter()) + .add(BigDecimalAdapter()) + .add(BigIntegerAdapter()) .add(KotlinJsonAdapterFactory()) @JvmStatic diff --git a/samples/client/petstore/kotlin-threetenbp/.openapi-generator/FILES b/samples/client/petstore/kotlin-threetenbp/.openapi-generator/FILES index 905f2e1599e3..7c649eb5bd49 100644 --- a/samples/client/petstore/kotlin-threetenbp/.openapi-generator/FILES +++ b/samples/client/petstore/kotlin-threetenbp/.openapi-generator/FILES @@ -22,6 +22,8 @@ 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/ApiInfrastructureResponse.kt src/main/kotlin/org/openapitools/client/infrastructure/ApplicationDelegates.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/Errors.kt src/main/kotlin/org/openapitools/client/infrastructure/LocalDateAdapter.kt diff --git a/samples/client/petstore/kotlin-threetenbp/src/main/kotlin/org/openapitools/client/infrastructure/BigDecimalAdapter.kt b/samples/client/petstore/kotlin-threetenbp/src/main/kotlin/org/openapitools/client/infrastructure/BigDecimalAdapter.kt new file mode 100644 index 000000000000..fb2c972cf8d4 --- /dev/null +++ b/samples/client/petstore/kotlin-threetenbp/src/main/kotlin/org/openapitools/client/infrastructure/BigDecimalAdapter.kt @@ -0,0 +1,17 @@ +package org.openapitools.client.infrastructure + +import com.squareup.moshi.FromJson +import com.squareup.moshi.ToJson +import java.math.BigDecimal + +class BigDecimalAdapter { + @ToJson + fun toJson(value: BigDecimal): String { + return value.toPlainString() + } + + @FromJson + fun fromJson(value: String): BigDecimal { + return BigDecimal(value) + } +} \ No newline at end of file diff --git a/samples/client/petstore/kotlin-threetenbp/src/main/kotlin/org/openapitools/client/infrastructure/BigIntegerAdapter.kt b/samples/client/petstore/kotlin-threetenbp/src/main/kotlin/org/openapitools/client/infrastructure/BigIntegerAdapter.kt new file mode 100644 index 000000000000..4b6963110c9e --- /dev/null +++ b/samples/client/petstore/kotlin-threetenbp/src/main/kotlin/org/openapitools/client/infrastructure/BigIntegerAdapter.kt @@ -0,0 +1,17 @@ +package org.openapitools.client.infrastructure + +import com.squareup.moshi.FromJson +import com.squareup.moshi.ToJson +import java.math.BigInteger + +class BigIntegerAdapter { + @ToJson + fun toJson(value: BigInteger): String { + return value.toString() + } + + @FromJson + fun fromJson(value: String): BigInteger { + return BigInteger(value) + } +} \ No newline at end of file diff --git a/samples/client/petstore/kotlin-threetenbp/src/main/kotlin/org/openapitools/client/infrastructure/Serializer.kt b/samples/client/petstore/kotlin-threetenbp/src/main/kotlin/org/openapitools/client/infrastructure/Serializer.kt index 697559b2ec16..888651c6c14d 100644 --- a/samples/client/petstore/kotlin-threetenbp/src/main/kotlin/org/openapitools/client/infrastructure/Serializer.kt +++ b/samples/client/petstore/kotlin-threetenbp/src/main/kotlin/org/openapitools/client/infrastructure/Serializer.kt @@ -14,6 +14,8 @@ object Serializer { .add(LocalDateAdapter()) .add(UUIDAdapter()) .add(ByteArrayAdapter()) + .add(BigDecimalAdapter()) + .add(BigIntegerAdapter()) .add(KotlinJsonAdapterFactory()) @JvmStatic diff --git a/samples/client/petstore/kotlin/.openapi-generator/FILES b/samples/client/petstore/kotlin/.openapi-generator/FILES index 905f2e1599e3..7c649eb5bd49 100644 --- a/samples/client/petstore/kotlin/.openapi-generator/FILES +++ b/samples/client/petstore/kotlin/.openapi-generator/FILES @@ -22,6 +22,8 @@ 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/ApiInfrastructureResponse.kt src/main/kotlin/org/openapitools/client/infrastructure/ApplicationDelegates.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/Errors.kt src/main/kotlin/org/openapitools/client/infrastructure/LocalDateAdapter.kt diff --git a/samples/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/infrastructure/BigDecimalAdapter.kt b/samples/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/infrastructure/BigDecimalAdapter.kt new file mode 100644 index 000000000000..fb2c972cf8d4 --- /dev/null +++ b/samples/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/infrastructure/BigDecimalAdapter.kt @@ -0,0 +1,17 @@ +package org.openapitools.client.infrastructure + +import com.squareup.moshi.FromJson +import com.squareup.moshi.ToJson +import java.math.BigDecimal + +class BigDecimalAdapter { + @ToJson + fun toJson(value: BigDecimal): String { + return value.toPlainString() + } + + @FromJson + fun fromJson(value: String): BigDecimal { + return BigDecimal(value) + } +} \ No newline at end of file diff --git a/samples/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/infrastructure/BigIntegerAdapter.kt b/samples/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/infrastructure/BigIntegerAdapter.kt new file mode 100644 index 000000000000..4b6963110c9e --- /dev/null +++ b/samples/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/infrastructure/BigIntegerAdapter.kt @@ -0,0 +1,17 @@ +package org.openapitools.client.infrastructure + +import com.squareup.moshi.FromJson +import com.squareup.moshi.ToJson +import java.math.BigInteger + +class BigIntegerAdapter { + @ToJson + fun toJson(value: BigInteger): String { + return value.toString() + } + + @FromJson + fun fromJson(value: String): BigInteger { + return BigInteger(value) + } +} \ No newline at end of file diff --git a/samples/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/infrastructure/Serializer.kt b/samples/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/infrastructure/Serializer.kt index 697559b2ec16..888651c6c14d 100644 --- a/samples/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/infrastructure/Serializer.kt +++ b/samples/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/infrastructure/Serializer.kt @@ -14,6 +14,8 @@ object Serializer { .add(LocalDateAdapter()) .add(UUIDAdapter()) .add(ByteArrayAdapter()) + .add(BigDecimalAdapter()) + .add(BigIntegerAdapter()) .add(KotlinJsonAdapterFactory()) @JvmStatic