forked from loafle/openapi-generator-original
[kotlin][client] small improvements (#9640)
* [kotlin][client] standardize adapter type names * [kotlin][client] remove unused class * [kotlin][client] fix IDE warning * [kotlin][client] improve import layout * [kotlin][client] update sample projects
This commit is contained in:
@@ -525,7 +525,6 @@ public class KotlinClientCodegen extends AbstractKotlinCodegen {
|
||||
setLibrary(JVM_OKHTTP);
|
||||
|
||||
// jvm specific supporting files
|
||||
supportingFiles.add(new SupportingFile("infrastructure/ApplicationDelegates.kt.mustache", infrastructureFolder, "ApplicationDelegates.kt"));
|
||||
supportingFiles.add(new SupportingFile("infrastructure/Errors.kt.mustache", infrastructureFolder, "Errors.kt"));
|
||||
supportingFiles.add(new SupportingFile("infrastructure/ResponseExtensions.kt.mustache", infrastructureFolder, "ResponseExtensions.kt"));
|
||||
supportingFiles.add(new SupportingFile("infrastructure/ApiInfrastructureResponse.kt.mustache", infrastructureFolder, "ApiInfrastructureResponse.kt"));
|
||||
|
||||
@@ -60,7 +60,7 @@ import java.util.concurrent.atomic.AtomicLong
|
||||
.add(LocalDateAdapter())
|
||||
.add(UUIDAdapter())
|
||||
.add(ByteArrayAdapter())
|
||||
.add(UriAdapter())
|
||||
.add(URIAdapter())
|
||||
{{^moshiCodeGen}}
|
||||
.add(KotlinJsonAdapterFactory())
|
||||
{{/moshiCodeGen}}
|
||||
@@ -105,8 +105,8 @@ import java.util.concurrent.atomic.AtomicLong
|
||||
contextual(AtomicInteger::class, AtomicIntegerAdapter)
|
||||
contextual(AtomicLong::class, AtomicLongAdapter)
|
||||
contextual(AtomicBoolean::class, AtomicBooleanAdapter)
|
||||
contextual(URI::class, UriAdapter)
|
||||
contextual(URL::class, UrlAdapter)
|
||||
contextual(URI::class, URIAdapter)
|
||||
contextual(URL::class, URLAdapter)
|
||||
contextual(StringBuilder::class, StringBuilderAdapter)
|
||||
}
|
||||
|
||||
|
||||
@@ -16,17 +16,17 @@ import com.squareup.moshi.ToJson
|
||||
import java.net.URI
|
||||
|
||||
{{#moshi}}
|
||||
{{#nonPublicApi}}internal {{/nonPublicApi}}class UriAdapter {
|
||||
{{#nonPublicApi}}internal {{/nonPublicApi}}class URIAdapter {
|
||||
@ToJson
|
||||
fun toJson(uri: URI) = uri.toString()
|
||||
|
||||
@FromJson
|
||||
fun fromJson(s: String) = URI.create(s)
|
||||
fun fromJson(s: String): URI = URI.create(s)
|
||||
}
|
||||
{{/moshi}}
|
||||
{{#kotlinx_serialization}}
|
||||
@Serializer(forClass = URI::class)
|
||||
object UriAdapter : KSerializer<URI> {
|
||||
object URIAdapter : KSerializer<URI> {
|
||||
override fun serialize(encoder: Encoder, value: URI) {
|
||||
encoder.encodeString(value.toASCIIString())
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ import kotlinx.serialization.descriptors.SerialDescriptor
|
||||
import java.net.URL
|
||||
|
||||
@Serializer(forClass = URL::class)
|
||||
object UrlAdapter : KSerializer<URL> {
|
||||
object URLAdapter : KSerializer<URL> {
|
||||
override fun serialize(encoder: Encoder, value: URL) {
|
||||
encoder.encodeString(value.toExternalForm())
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ import java.util.UUID
|
||||
fun toJson(uuid: UUID) = uuid.toString()
|
||||
|
||||
@FromJson
|
||||
fun fromJson(s: String) = UUID.fromString(s)
|
||||
fun fromJson(s: String): UUID = UUID.fromString(s)
|
||||
}
|
||||
{{/moshi}}
|
||||
{{#kotlinx_serialization}}
|
||||
|
||||
@@ -3,7 +3,11 @@ package {{packageName}}.infrastructure
|
||||
{{#supportAndroidApiLevel25AndBelow}}
|
||||
import android.os.Build
|
||||
{{/supportAndroidApiLevel25AndBelow}}
|
||||
{{#hasAuthMethods}}
|
||||
{{#isBasicBasic}}
|
||||
import okhttp3.Credentials
|
||||
{{/isBasicBasic}}
|
||||
{{/hasAuthMethods}}
|
||||
import okhttp3.OkHttpClient
|
||||
import okhttp3.RequestBody
|
||||
{{#jvm-okhttp3}}
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
package {{packageName}}.infrastructure
|
||||
|
||||
import kotlin.properties.ReadWriteProperty
|
||||
import kotlin.reflect.KProperty
|
||||
|
||||
{{#nonPublicApi}}internal {{/nonPublicApi}}object ApplicationDelegates {
|
||||
/**
|
||||
* Provides a property delegate, allowing the property to be set once and only once.
|
||||
*
|
||||
* If unset (no default value), a get on the property will throw [IllegalStateException].
|
||||
*/
|
||||
fun <T> setOnce(defaultValue: T? = null) : ReadWriteProperty<Any?, T> = SetOnce(defaultValue)
|
||||
|
||||
private class SetOnce<T>(defaultValue: T? = null) : ReadWriteProperty<Any?, T> {
|
||||
private var isSet = false
|
||||
private var value: T? = defaultValue
|
||||
|
||||
override fun getValue(thisRef: Any?, property: KProperty<*>): T {
|
||||
return value ?: throw IllegalStateException("${property.name} not initialized")
|
||||
}
|
||||
|
||||
override fun setValue(thisRef: Any?, property: KProperty<*>, value: T) = synchronized(this) {
|
||||
if (!isSet) {
|
||||
this.value = value
|
||||
isSet = true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -459,7 +459,7 @@ public class DefaultGeneratorTest {
|
||||
|
||||
List<File> files = generator.opts(clientOptInput).generate();
|
||||
|
||||
Assert.assertEquals(files.size(), 27);
|
||||
Assert.assertEquals(files.size(), 26);
|
||||
|
||||
// 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 class DefaultGeneratorTest {
|
||||
|
||||
List<File> files = generator.opts(clientOptInput).generate();
|
||||
|
||||
Assert.assertEquals(files.size(), 27);
|
||||
Assert.assertEquals(files.size(), 26);
|
||||
|
||||
// Generator should report README.md as a generated file
|
||||
TestUtils.ensureContainsFile(files, output, "README.md");
|
||||
@@ -566,7 +566,7 @@ public class DefaultGeneratorTest {
|
||||
|
||||
List<File> files = generator.opts(clientOptInput).generate();
|
||||
|
||||
Assert.assertEquals(files.size(), 27);
|
||||
Assert.assertEquals(files.size(), 26);
|
||||
|
||||
// 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 class DefaultGeneratorTest {
|
||||
|
||||
List<File> files = generator.opts(clientOptInput).generate();
|
||||
|
||||
Assert.assertEquals(files.size(), 27);
|
||||
Assert.assertEquals(files.size(), 26);
|
||||
|
||||
// Generator should report README.md as a generated file
|
||||
TestUtils.ensureContainsFile(files, output, "README.md");
|
||||
|
||||
@@ -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/ApiInfrastructureResponse.kt
|
||||
src/main/kotlin/org/openapitools/client/infrastructure/ApplicationDelegates.kt
|
||||
src/main/kotlin/org/openapitools/client/infrastructure/ByteArrayAdapter.kt
|
||||
src/main/kotlin/org/openapitools/client/infrastructure/DateAdapter.kt
|
||||
src/main/kotlin/org/openapitools/client/infrastructure/Errors.kt
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package org.openapitools.client.infrastructure
|
||||
|
||||
import okhttp3.Credentials
|
||||
import okhttp3.OkHttpClient
|
||||
import okhttp3.RequestBody
|
||||
import okhttp3.RequestBody.Companion.asRequestBody
|
||||
|
||||
@@ -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/ApiInfrastructureResponse.kt
|
||||
src/main/kotlin/org/openapitools/client/infrastructure/ApplicationDelegates.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/RequestConfig.kt
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package org.openapitools.client.infrastructure
|
||||
|
||||
import okhttp3.Credentials
|
||||
import okhttp3.OkHttpClient
|
||||
import okhttp3.RequestBody
|
||||
import okhttp3.RequestBody.Companion.asRequestBody
|
||||
|
||||
@@ -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/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
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package org.openapitools.client.infrastructure
|
||||
|
||||
import android.os.Build
|
||||
import okhttp3.Credentials
|
||||
import okhttp3.OkHttpClient
|
||||
import okhttp3.RequestBody
|
||||
import okhttp3.RequestBody.Companion.asRequestBody
|
||||
|
||||
@@ -12,7 +12,7 @@ object Serializer {
|
||||
.add(LocalDateAdapter())
|
||||
.add(UUIDAdapter())
|
||||
.add(ByteArrayAdapter())
|
||||
.add(UriAdapter())
|
||||
.add(URIAdapter())
|
||||
.add(KotlinJsonAdapterFactory())
|
||||
.add(BigDecimalAdapter())
|
||||
.add(BigIntegerAdapter())
|
||||
|
||||
@@ -4,10 +4,10 @@ import com.squareup.moshi.FromJson
|
||||
import com.squareup.moshi.ToJson
|
||||
import java.net.URI
|
||||
|
||||
class UriAdapter {
|
||||
class URIAdapter {
|
||||
@ToJson
|
||||
fun toJson(uri: URI) = uri.toString()
|
||||
|
||||
@FromJson
|
||||
fun fromJson(s: String) = URI.create(s)
|
||||
fun fromJson(s: String): URI = URI.create(s)
|
||||
}
|
||||
|
||||
@@ -9,5 +9,5 @@ class UUIDAdapter {
|
||||
fun toJson(uuid: UUID) = uuid.toString()
|
||||
|
||||
@FromJson
|
||||
fun fromJson(s: String) = UUID.fromString(s)
|
||||
fun fromJson(s: String): UUID = UUID.fromString(s)
|
||||
}
|
||||
|
||||
@@ -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/ApiInfrastructureResponse.kt
|
||||
src/main/kotlin/org/openapitools/client/infrastructure/ApplicationDelegates.kt
|
||||
src/main/kotlin/org/openapitools/client/infrastructure/ByteArrayAdapter.kt
|
||||
src/main/kotlin/org/openapitools/client/infrastructure/DateAdapter.kt
|
||||
src/main/kotlin/org/openapitools/client/infrastructure/Errors.kt
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package org.openapitools.client.infrastructure
|
||||
|
||||
import okhttp3.Credentials
|
||||
import okhttp3.OkHttpClient
|
||||
import okhttp3.RequestBody
|
||||
import okhttp3.RequestBody.Companion.asRequestBody
|
||||
|
||||
@@ -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/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
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package org.openapitools.client.infrastructure
|
||||
|
||||
import okhttp3.Credentials
|
||||
import okhttp3.OkHttpClient
|
||||
import okhttp3.RequestBody
|
||||
import okhttp3.RequestBody.Companion.asRequestBody
|
||||
|
||||
@@ -11,7 +11,7 @@ object Serializer {
|
||||
.add(LocalDateAdapter())
|
||||
.add(UUIDAdapter())
|
||||
.add(ByteArrayAdapter())
|
||||
.add(UriAdapter())
|
||||
.add(URIAdapter())
|
||||
.add(BigDecimalAdapter())
|
||||
.add(BigIntegerAdapter())
|
||||
|
||||
|
||||
@@ -4,10 +4,10 @@ import com.squareup.moshi.FromJson
|
||||
import com.squareup.moshi.ToJson
|
||||
import java.net.URI
|
||||
|
||||
class UriAdapter {
|
||||
class URIAdapter {
|
||||
@ToJson
|
||||
fun toJson(uri: URI) = uri.toString()
|
||||
|
||||
@FromJson
|
||||
fun fromJson(s: String) = URI.create(s)
|
||||
fun fromJson(s: String): URI = URI.create(s)
|
||||
}
|
||||
|
||||
@@ -9,5 +9,5 @@ class UUIDAdapter {
|
||||
fun toJson(uuid: UUID) = uuid.toString()
|
||||
|
||||
@FromJson
|
||||
fun fromJson(s: String) = UUID.fromString(s)
|
||||
fun fromJson(s: String): UUID = UUID.fromString(s)
|
||||
}
|
||||
|
||||
@@ -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/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
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package org.openapitools.client.infrastructure
|
||||
|
||||
import okhttp3.Credentials
|
||||
import okhttp3.OkHttpClient
|
||||
import okhttp3.RequestBody
|
||||
import okhttp3.RequestBody.Companion.asRequestBody
|
||||
|
||||
@@ -12,7 +12,7 @@ internal object Serializer {
|
||||
.add(LocalDateAdapter())
|
||||
.add(UUIDAdapter())
|
||||
.add(ByteArrayAdapter())
|
||||
.add(UriAdapter())
|
||||
.add(URIAdapter())
|
||||
.add(KotlinJsonAdapterFactory())
|
||||
.add(BigDecimalAdapter())
|
||||
.add(BigIntegerAdapter())
|
||||
|
||||
@@ -4,10 +4,10 @@ import com.squareup.moshi.FromJson
|
||||
import com.squareup.moshi.ToJson
|
||||
import java.net.URI
|
||||
|
||||
internal class UriAdapter {
|
||||
internal class URIAdapter {
|
||||
@ToJson
|
||||
fun toJson(uri: URI) = uri.toString()
|
||||
|
||||
@FromJson
|
||||
fun fromJson(s: String) = URI.create(s)
|
||||
fun fromJson(s: String): URI = URI.create(s)
|
||||
}
|
||||
|
||||
@@ -9,5 +9,5 @@ internal class UUIDAdapter {
|
||||
fun toJson(uuid: UUID) = uuid.toString()
|
||||
|
||||
@FromJson
|
||||
fun fromJson(s: String) = UUID.fromString(s)
|
||||
fun fromJson(s: String): UUID = UUID.fromString(s)
|
||||
}
|
||||
|
||||
@@ -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/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
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package org.openapitools.client.infrastructure
|
||||
|
||||
import okhttp3.Credentials
|
||||
import okhttp3.OkHttpClient
|
||||
import okhttp3.RequestBody
|
||||
import okhttp3.RequestBody.Companion.asRequestBody
|
||||
|
||||
@@ -12,7 +12,7 @@ object Serializer {
|
||||
.add(LocalDateAdapter())
|
||||
.add(UUIDAdapter())
|
||||
.add(ByteArrayAdapter())
|
||||
.add(UriAdapter())
|
||||
.add(URIAdapter())
|
||||
.add(KotlinJsonAdapterFactory())
|
||||
.add(BigDecimalAdapter())
|
||||
.add(BigIntegerAdapter())
|
||||
|
||||
@@ -4,10 +4,10 @@ import com.squareup.moshi.FromJson
|
||||
import com.squareup.moshi.ToJson
|
||||
import java.net.URI
|
||||
|
||||
class UriAdapter {
|
||||
class URIAdapter {
|
||||
@ToJson
|
||||
fun toJson(uri: URI) = uri.toString()
|
||||
|
||||
@FromJson
|
||||
fun fromJson(s: String) = URI.create(s)
|
||||
fun fromJson(s: String): URI = URI.create(s)
|
||||
}
|
||||
|
||||
@@ -9,5 +9,5 @@ class UUIDAdapter {
|
||||
fun toJson(uuid: UUID) = uuid.toString()
|
||||
|
||||
@FromJson
|
||||
fun fromJson(s: String) = UUID.fromString(s)
|
||||
fun fromJson(s: String): UUID = UUID.fromString(s)
|
||||
}
|
||||
|
||||
@@ -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/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
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package org.openapitools.client.infrastructure
|
||||
|
||||
import okhttp3.Credentials
|
||||
import okhttp3.OkHttpClient
|
||||
import okhttp3.RequestBody
|
||||
import okhttp3.MediaType
|
||||
|
||||
@@ -12,7 +12,7 @@ object Serializer {
|
||||
.add(LocalDateAdapter())
|
||||
.add(UUIDAdapter())
|
||||
.add(ByteArrayAdapter())
|
||||
.add(UriAdapter())
|
||||
.add(URIAdapter())
|
||||
.add(KotlinJsonAdapterFactory())
|
||||
.add(BigDecimalAdapter())
|
||||
.add(BigIntegerAdapter())
|
||||
|
||||
@@ -4,10 +4,10 @@ import com.squareup.moshi.FromJson
|
||||
import com.squareup.moshi.ToJson
|
||||
import java.net.URI
|
||||
|
||||
class UriAdapter {
|
||||
class URIAdapter {
|
||||
@ToJson
|
||||
fun toJson(uri: URI) = uri.toString()
|
||||
|
||||
@FromJson
|
||||
fun fromJson(s: String) = URI.create(s)
|
||||
fun fromJson(s: String): URI = URI.create(s)
|
||||
}
|
||||
|
||||
@@ -9,5 +9,5 @@ class UUIDAdapter {
|
||||
fun toJson(uuid: UUID) = uuid.toString()
|
||||
|
||||
@FromJson
|
||||
fun fromJson(s: String) = UUID.fromString(s)
|
||||
fun fromJson(s: String): UUID = UUID.fromString(s)
|
||||
}
|
||||
|
||||
@@ -28,8 +28,8 @@ object Serializer {
|
||||
contextual(AtomicInteger::class, AtomicIntegerAdapter)
|
||||
contextual(AtomicLong::class, AtomicLongAdapter)
|
||||
contextual(AtomicBoolean::class, AtomicBooleanAdapter)
|
||||
contextual(URI::class, UriAdapter)
|
||||
contextual(URL::class, UrlAdapter)
|
||||
contextual(URI::class, URIAdapter)
|
||||
contextual(URL::class, URLAdapter)
|
||||
contextual(StringBuilder::class, StringBuilderAdapter)
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ import kotlinx.serialization.descriptors.SerialDescriptor
|
||||
import java.net.URI
|
||||
|
||||
@Serializer(forClass = URI::class)
|
||||
object UriAdapter : KSerializer<URI> {
|
||||
object URIAdapter : KSerializer<URI> {
|
||||
override fun serialize(encoder: Encoder, value: URI) {
|
||||
encoder.encodeString(value.toASCIIString())
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ import kotlinx.serialization.descriptors.SerialDescriptor
|
||||
import java.net.URL
|
||||
|
||||
@Serializer(forClass = URL::class)
|
||||
object UrlAdapter : KSerializer<URL> {
|
||||
object URLAdapter : KSerializer<URL> {
|
||||
override fun serialize(encoder: Encoder, value: URL) {
|
||||
encoder.encodeString(value.toExternalForm())
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ object Serializer {
|
||||
.add(LocalDateAdapter())
|
||||
.add(UUIDAdapter())
|
||||
.add(ByteArrayAdapter())
|
||||
.add(UriAdapter())
|
||||
.add(URIAdapter())
|
||||
.add(KotlinJsonAdapterFactory())
|
||||
.add(BigDecimalAdapter())
|
||||
.add(BigIntegerAdapter())
|
||||
|
||||
@@ -4,10 +4,10 @@ import com.squareup.moshi.FromJson
|
||||
import com.squareup.moshi.ToJson
|
||||
import java.net.URI
|
||||
|
||||
class UriAdapter {
|
||||
class URIAdapter {
|
||||
@ToJson
|
||||
fun toJson(uri: URI) = uri.toString()
|
||||
|
||||
@FromJson
|
||||
fun fromJson(s: String) = URI.create(s)
|
||||
fun fromJson(s: String): URI = URI.create(s)
|
||||
}
|
||||
|
||||
@@ -9,5 +9,5 @@ class UUIDAdapter {
|
||||
fun toJson(uuid: UUID) = uuid.toString()
|
||||
|
||||
@FromJson
|
||||
fun fromJson(s: String) = UUID.fromString(s)
|
||||
fun fromJson(s: String): UUID = UUID.fromString(s)
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ object Serializer {
|
||||
.add(LocalDateAdapter())
|
||||
.add(UUIDAdapter())
|
||||
.add(ByteArrayAdapter())
|
||||
.add(UriAdapter())
|
||||
.add(URIAdapter())
|
||||
.add(KotlinJsonAdapterFactory())
|
||||
.add(BigDecimalAdapter())
|
||||
.add(BigIntegerAdapter())
|
||||
|
||||
@@ -4,10 +4,10 @@ import com.squareup.moshi.FromJson
|
||||
import com.squareup.moshi.ToJson
|
||||
import java.net.URI
|
||||
|
||||
class UriAdapter {
|
||||
class URIAdapter {
|
||||
@ToJson
|
||||
fun toJson(uri: URI) = uri.toString()
|
||||
|
||||
@FromJson
|
||||
fun fromJson(s: String) = URI.create(s)
|
||||
fun fromJson(s: String): URI = URI.create(s)
|
||||
}
|
||||
|
||||
@@ -9,5 +9,5 @@ class UUIDAdapter {
|
||||
fun toJson(uuid: UUID) = uuid.toString()
|
||||
|
||||
@FromJson
|
||||
fun fromJson(s: String) = UUID.fromString(s)
|
||||
fun fromJson(s: String): UUID = UUID.fromString(s)
|
||||
}
|
||||
|
||||
@@ -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/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
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package org.openapitools.client.infrastructure
|
||||
|
||||
import okhttp3.Credentials
|
||||
import okhttp3.OkHttpClient
|
||||
import okhttp3.RequestBody
|
||||
import okhttp3.RequestBody.Companion.asRequestBody
|
||||
|
||||
@@ -12,7 +12,7 @@ object Serializer {
|
||||
.add(LocalDateAdapter())
|
||||
.add(UUIDAdapter())
|
||||
.add(ByteArrayAdapter())
|
||||
.add(UriAdapter())
|
||||
.add(URIAdapter())
|
||||
.add(KotlinJsonAdapterFactory())
|
||||
.add(BigDecimalAdapter())
|
||||
.add(BigIntegerAdapter())
|
||||
|
||||
@@ -4,10 +4,10 @@ import com.squareup.moshi.FromJson
|
||||
import com.squareup.moshi.ToJson
|
||||
import java.net.URI
|
||||
|
||||
class UriAdapter {
|
||||
class URIAdapter {
|
||||
@ToJson
|
||||
fun toJson(uri: URI) = uri.toString()
|
||||
|
||||
@FromJson
|
||||
fun fromJson(s: String) = URI.create(s)
|
||||
fun fromJson(s: String): URI = URI.create(s)
|
||||
}
|
||||
|
||||
@@ -9,5 +9,5 @@ class UUIDAdapter {
|
||||
fun toJson(uuid: UUID) = uuid.toString()
|
||||
|
||||
@FromJson
|
||||
fun fromJson(s: String) = UUID.fromString(s)
|
||||
fun fromJson(s: String): UUID = UUID.fromString(s)
|
||||
}
|
||||
|
||||
@@ -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/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
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package org.openapitools.client.infrastructure
|
||||
|
||||
import okhttp3.Credentials
|
||||
import okhttp3.OkHttpClient
|
||||
import okhttp3.RequestBody
|
||||
import okhttp3.RequestBody.Companion.asRequestBody
|
||||
|
||||
@@ -12,7 +12,7 @@ object Serializer {
|
||||
.add(LocalDateAdapter())
|
||||
.add(UUIDAdapter())
|
||||
.add(ByteArrayAdapter())
|
||||
.add(UriAdapter())
|
||||
.add(URIAdapter())
|
||||
.add(KotlinJsonAdapterFactory())
|
||||
.add(BigDecimalAdapter())
|
||||
.add(BigIntegerAdapter())
|
||||
|
||||
@@ -4,10 +4,10 @@ import com.squareup.moshi.FromJson
|
||||
import com.squareup.moshi.ToJson
|
||||
import java.net.URI
|
||||
|
||||
class UriAdapter {
|
||||
class URIAdapter {
|
||||
@ToJson
|
||||
fun toJson(uri: URI) = uri.toString()
|
||||
|
||||
@FromJson
|
||||
fun fromJson(s: String) = URI.create(s)
|
||||
fun fromJson(s: String): URI = URI.create(s)
|
||||
}
|
||||
|
||||
@@ -9,5 +9,5 @@ class UUIDAdapter {
|
||||
fun toJson(uuid: UUID) = uuid.toString()
|
||||
|
||||
@FromJson
|
||||
fun fromJson(s: String) = UUID.fromString(s)
|
||||
fun fromJson(s: String): UUID = UUID.fromString(s)
|
||||
}
|
||||
|
||||
@@ -11,7 +11,6 @@ src/main/kotlin/org/openapitools/client/apis/EnumApi.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/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
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package org.openapitools.client.infrastructure
|
||||
|
||||
import okhttp3.Credentials
|
||||
import okhttp3.OkHttpClient
|
||||
import okhttp3.RequestBody
|
||||
import okhttp3.RequestBody.Companion.asRequestBody
|
||||
|
||||
@@ -12,7 +12,7 @@ object Serializer {
|
||||
.add(LocalDateAdapter())
|
||||
.add(UUIDAdapter())
|
||||
.add(ByteArrayAdapter())
|
||||
.add(UriAdapter())
|
||||
.add(URIAdapter())
|
||||
.add(KotlinJsonAdapterFactory())
|
||||
.add(BigDecimalAdapter())
|
||||
.add(BigIntegerAdapter())
|
||||
|
||||
@@ -4,10 +4,10 @@ import com.squareup.moshi.FromJson
|
||||
import com.squareup.moshi.ToJson
|
||||
import java.net.URI
|
||||
|
||||
class UriAdapter {
|
||||
class URIAdapter {
|
||||
@ToJson
|
||||
fun toJson(uri: URI) = uri.toString()
|
||||
|
||||
@FromJson
|
||||
fun fromJson(s: String) = URI.create(s)
|
||||
fun fromJson(s: String): URI = URI.create(s)
|
||||
}
|
||||
|
||||
@@ -9,5 +9,5 @@ class UUIDAdapter {
|
||||
fun toJson(uuid: UUID) = uuid.toString()
|
||||
|
||||
@FromJson
|
||||
fun fromJson(s: String) = UUID.fromString(s)
|
||||
fun fromJson(s: String): UUID = UUID.fromString(s)
|
||||
}
|
||||
|
||||
@@ -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/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
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package org.openapitools.client.infrastructure
|
||||
|
||||
import okhttp3.Credentials
|
||||
import okhttp3.OkHttpClient
|
||||
import okhttp3.RequestBody
|
||||
import okhttp3.RequestBody.Companion.asRequestBody
|
||||
|
||||
@@ -12,7 +12,7 @@ object Serializer {
|
||||
.add(LocalDateAdapter())
|
||||
.add(UUIDAdapter())
|
||||
.add(ByteArrayAdapter())
|
||||
.add(UriAdapter())
|
||||
.add(URIAdapter())
|
||||
.add(KotlinJsonAdapterFactory())
|
||||
.add(BigDecimalAdapter())
|
||||
.add(BigIntegerAdapter())
|
||||
|
||||
@@ -4,10 +4,10 @@ import com.squareup.moshi.FromJson
|
||||
import com.squareup.moshi.ToJson
|
||||
import java.net.URI
|
||||
|
||||
class UriAdapter {
|
||||
class URIAdapter {
|
||||
@ToJson
|
||||
fun toJson(uri: URI) = uri.toString()
|
||||
|
||||
@FromJson
|
||||
fun fromJson(s: String) = URI.create(s)
|
||||
fun fromJson(s: String): URI = URI.create(s)
|
||||
}
|
||||
|
||||
@@ -9,5 +9,5 @@ class UUIDAdapter {
|
||||
fun toJson(uuid: UUID) = uuid.toString()
|
||||
|
||||
@FromJson
|
||||
fun fromJson(s: String) = UUID.fromString(s)
|
||||
fun fromJson(s: String): UUID = UUID.fromString(s)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user