mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-12-18 22:57:07 +00:00
Merge remote-tracking branch 'origin/5.2.x' into 6.0.x
This commit is contained in:
@@ -40,3 +40,9 @@ dependencies {
|
||||
compile "com.squareup.retrofit2:converter-scalars:$retrofitVersion"
|
||||
testCompile "io.kotlintest:kotlintest-runner-junit5:3.4.2"
|
||||
}
|
||||
|
||||
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach {
|
||||
kotlinOptions {
|
||||
freeCompilerArgs += "-Xopt-in=kotlinx.serialization.ExperimentalSerializationApi"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -104,7 +104,7 @@ interface PetApi {
|
||||
*/
|
||||
@FormUrlEncoded
|
||||
@POST("pet/{petId}")
|
||||
fun updatePetWithForm(@Path("petId") petId: kotlin.Long, @Field("name") name: kotlin.String, @Field("status") status: kotlin.String): Call<Unit>
|
||||
fun updatePetWithForm(@Path("petId") petId: kotlin.Long, @Field("name") name: kotlin.String? = null, @Field("status") status: kotlin.String? = null): Call<Unit>
|
||||
|
||||
/**
|
||||
* uploads an image
|
||||
@@ -119,6 +119,6 @@ interface PetApi {
|
||||
*/
|
||||
@Multipart
|
||||
@POST("pet/{petId}/uploadImage")
|
||||
fun uploadFile(@Path("petId") petId: kotlin.Long, @Part("additionalMetadata") additionalMetadata: kotlin.String, @Part file: MultipartBody.Part): Call<ApiResponse>
|
||||
fun uploadFile(@Path("petId") petId: kotlin.Long, @Part("additionalMetadata") additionalMetadata: kotlin.String? = null, @Part file: MultipartBody.Part? = null): Call<ApiResponse>
|
||||
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ import okhttp3.Interceptor
|
||||
import okhttp3.OkHttpClient
|
||||
import retrofit2.Retrofit
|
||||
import okhttp3.logging.HttpLoggingInterceptor
|
||||
import retrofit2.Converter
|
||||
import retrofit2.converter.scalars.ScalarsConverterFactory
|
||||
|
||||
import com.jakewharton.retrofit2.converter.kotlinx.serialization.asConverterFactory
|
||||
@@ -20,7 +21,8 @@ import okhttp3.MediaType.Companion.toMediaType
|
||||
class ApiClient(
|
||||
private var baseUrl: String = defaultBasePath,
|
||||
private val okHttpClientBuilder: OkHttpClient.Builder? = null,
|
||||
private val okHttpClient : OkHttpClient? = null
|
||||
private val okHttpClient : OkHttpClient? = null,
|
||||
private val converterFactory: Converter.Factory? = null,
|
||||
) {
|
||||
private val apiAuthorizations = mutableMapOf<String, Interceptor>()
|
||||
var logger: ((String) -> Unit)? = null
|
||||
@@ -30,6 +32,11 @@ class ApiClient(
|
||||
.baseUrl(baseUrl)
|
||||
.addConverterFactory(ScalarsConverterFactory.create())
|
||||
.addConverterFactory(jvmJson.asConverterFactory("application/json".toMediaType()))
|
||||
.apply {
|
||||
if (converterFactory != null) {
|
||||
addConverterFactory(converterFactory)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private val clientBuilder: OkHttpClient.Builder by lazy {
|
||||
|
||||
@@ -12,8 +12,6 @@ import java.math.BigDecimal
|
||||
@Serializer(forClass = BigDecimal::class)
|
||||
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())
|
||||
}
|
||||
@@ -12,7 +12,6 @@ import java.math.BigInteger
|
||||
@Serializer(forClass = BigInteger::class)
|
||||
object BigIntegerAdapter : KSerializer<BigInteger> {
|
||||
override val descriptor: SerialDescriptor = PrimitiveSerialDescriptor("BigInteger", PrimitiveKind.STRING)
|
||||
|
||||
override fun deserialize(decoder: Decoder): BigInteger {
|
||||
return BigInteger(decoder.decodeString())
|
||||
}
|
||||
|
||||
@@ -50,6 +50,7 @@ data class Order (
|
||||
* Order Status
|
||||
* Values: PLACED,APPROVED,DELIVERED
|
||||
*/
|
||||
@KSerializable
|
||||
enum class Status(val value: kotlin.String) {
|
||||
@SerialName(value = "placed") PLACED("placed"),
|
||||
@SerialName(value = "approved") APPROVED("approved"),
|
||||
|
||||
@@ -52,6 +52,7 @@ data class Pet (
|
||||
* pet status in the store
|
||||
* Values: AVAILABLE,PENDING,SOLD
|
||||
*/
|
||||
@KSerializable
|
||||
enum class Status(val value: kotlin.String) {
|
||||
@SerialName(value = "available") AVAILABLE("available"),
|
||||
@SerialName(value = "pending") PENDING("pending"),
|
||||
|
||||
Reference in New Issue
Block a user