mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-12-06 01:16:16 +00:00
[Kotlin] Introduce support for Kotlin Explicit API Mode for Kotlin-Client generator (resolve #16506) (#19999)
* [Kotlin] Properly document nonPublicApi CLI option * [Kotlin] Respect parameter name of parent KSerializer to avoid miss-behavior * [Kotlin] Introduce support for Kotlin Explicit API Mode for Kotlin-Client generator (resolves #16506)
This commit is contained in:
@@ -2,7 +2,7 @@ package org.openapitools.client.infrastructure
|
||||
|
||||
typealias MultiValueMap = MutableMap<String,List<String>>
|
||||
|
||||
fun collectionDelimiter(collectionFormat: String) = when(collectionFormat) {
|
||||
fun collectionDelimiter(collectionFormat: String): String = when(collectionFormat) {
|
||||
"csv" -> ","
|
||||
"tsv" -> "\t"
|
||||
"pipe" -> "|"
|
||||
@@ -12,7 +12,7 @@ fun collectionDelimiter(collectionFormat: String) = when(collectionFormat) {
|
||||
|
||||
val defaultMultiValueConverter: (item: Any?) -> String = { item -> "$item" }
|
||||
|
||||
fun <T : Any?> toMultiValue(items: Array<T>, collectionFormat: String, map: (item: T) -> String = defaultMultiValueConverter)
|
||||
fun <T : Any?> toMultiValue(items: Array<T>, collectionFormat: String, map: (item: T) -> String = defaultMultiValueConverter): List<String>
|
||||
= toMultiValue(items.asIterable(), collectionFormat, map)
|
||||
|
||||
fun <T : Any?> toMultiValue(items: Iterable<T>, collectionFormat: String, map: (item: T) -> String = defaultMultiValueConverter): List<String> {
|
||||
|
||||
@@ -52,13 +52,13 @@ open class ApiClient(
|
||||
private val authentications: kotlin.collections.Map<String, Authentication>? = null
|
||||
|
||||
companion object {
|
||||
const val BASE_URL = "http://localhost"
|
||||
val JSON_DEFAULT = Json {
|
||||
const val BASE_URL: String = "http://localhost"
|
||||
val JSON_DEFAULT: Json = Json {
|
||||
ignoreUnknownKeys = true
|
||||
prettyPrint = true
|
||||
isLenient = true
|
||||
}
|
||||
protected val UNSAFE_HEADERS = listOf(HttpHeaders.ContentType)
|
||||
protected val UNSAFE_HEADERS: List<String> = listOf(HttpHeaders.ContentType)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -7,9 +7,9 @@ import kotlinx.serialization.encoding.*
|
||||
@Serializable(Base64ByteArray.Companion::class)
|
||||
class Base64ByteArray(val value: ByteArray) {
|
||||
companion object : KSerializer<Base64ByteArray> {
|
||||
override val descriptor = PrimitiveSerialDescriptor("Base64ByteArray", PrimitiveKind.STRING)
|
||||
override fun serialize(encoder: Encoder, obj: Base64ByteArray) = encoder.encodeString(obj.value.encodeBase64())
|
||||
override fun deserialize(decoder: Decoder) = Base64ByteArray(decoder.decodeString().decodeBase64Bytes())
|
||||
override val descriptor: SerialDescriptor = PrimitiveSerialDescriptor("Base64ByteArray", PrimitiveKind.STRING)
|
||||
override fun serialize(encoder: Encoder, value: Base64ByteArray): Unit = encoder.encodeString(value.value.encodeBase64())
|
||||
override fun deserialize(decoder: Decoder): Base64ByteArray = Base64ByteArray(decoder.decodeString().decodeBase64Bytes())
|
||||
}
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
|
||||
@@ -7,9 +7,9 @@ import kotlinx.serialization.encoding.*
|
||||
@Serializable(OctetByteArray.Companion::class)
|
||||
class OctetByteArray(val value: ByteArray) {
|
||||
companion object : KSerializer<OctetByteArray> {
|
||||
override val descriptor = PrimitiveSerialDescriptor("OctetByteArray", PrimitiveKind.STRING)
|
||||
override fun serialize(encoder: Encoder, obj: OctetByteArray) = encoder.encodeString(hex(obj.value))
|
||||
override fun deserialize(decoder: Decoder) = OctetByteArray(hex(decoder.decodeString()))
|
||||
override val descriptor: SerialDescriptor = PrimitiveSerialDescriptor("OctetByteArray", PrimitiveKind.STRING)
|
||||
override fun serialize(encoder: Encoder, value: OctetByteArray): Unit = encoder.encodeString(hex(value.value))
|
||||
override fun deserialize(decoder: Decoder): OctetByteArray = OctetByteArray(hex(decoder.decodeString()))
|
||||
}
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
|
||||
Reference in New Issue
Block a user