Merge remote-tracking branch 'origin/5.3.x' into 6.0.x

This commit is contained in:
William Cheng
2021-07-12 17:11:35 +08:00
3874 changed files with 120282 additions and 21640 deletions

View File

@@ -31,6 +31,7 @@ src/main/kotlin/org/openapitools/client/infrastructure/LocalDateTimeAdapter.kt
src/main/kotlin/org/openapitools/client/infrastructure/OffsetDateTimeAdapter.kt
src/main/kotlin/org/openapitools/client/infrastructure/ResponseExt.kt
src/main/kotlin/org/openapitools/client/infrastructure/Serializer.kt
src/main/kotlin/org/openapitools/client/infrastructure/URIAdapter.kt
src/main/kotlin/org/openapitools/client/infrastructure/UUIDAdapter.kt
src/main/kotlin/org/openapitools/client/models/ApiResponse.kt
src/main/kotlin/org/openapitools/client/models/Category.kt

View File

@@ -1 +1,5 @@
6.0.0-SNAPSHOT
<<<<<<< HEAD
6.0.0-SNAPSHOT
=======
5.3.0-SNAPSHOT
>>>>>>> origin/5.3.x

View File

@@ -7,9 +7,9 @@ wrapper {
}
buildscript {
ext.kotlin_version = '1.4.30'
ext.retrofitVersion = '2.7.2'
ext.rxJava3Version = '3.0.10'
ext.kotlin_version = '1.5.10'
ext.retrofitVersion = '2.9.0'
ext.rxJava3Version = '3.0.12'
repositories {
maven { url "https://repo1.maven.org/maven2" }
@@ -30,15 +30,15 @@ test {
}
dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
compile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
compile "com.squareup.moshi:moshi-kotlin:1.11.0"
compile "org.apache.oltu.oauth2:org.apache.oltu.oauth2.client:1.0.0"
compile "com.squareup.okhttp3:logging-interceptor:4.9.0"
compile "io.reactivex.rxjava3:rxjava:$rxJava3Version"
compile "com.squareup.retrofit2:adapter-rxjava3:2.9.0"
compile "com.squareup.retrofit2:retrofit:$retrofitVersion"
compile "com.squareup.retrofit2:converter-moshi:$retrofitVersion"
compile "com.squareup.retrofit2:converter-scalars:$retrofitVersion"
testCompile "io.kotlintest:kotlintest-runner-junit5:3.4.2"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
implementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
implementation "com.squareup.moshi:moshi-kotlin:1.12.0"
implementation "org.apache.oltu.oauth2:org.apache.oltu.oauth2.client:1.0.2"
implementation "com.squareup.okhttp3:logging-interceptor:4.9.1"
implementation "io.reactivex.rxjava3:rxjava:$rxJava3Version"
implementation "com.squareup.retrofit2:adapter-rxjava3:2.9.0"
implementation "com.squareup.retrofit2:retrofit:$retrofitVersion"
implementation "com.squareup.retrofit2:converter-moshi:$retrofitVersion"
implementation "com.squareup.retrofit2:converter-scalars:$retrofitVersion"
testImplementation "io.kotlintest:kotlintest-runner-junit5:3.4.2"
}

View File

@@ -35,7 +35,7 @@ interface PetApi {
* @return [Call]<[Unit]>
*/
@DELETE("pet/{petId}")
fun deletePet(@Path("petId") petId: kotlin.Long, @Header("api_key") apiKey: kotlin.String): Completable
fun deletePet(@Path("petId") petId: kotlin.Long, @Header("api_key") apiKey: kotlin.String? = null): Completable
/**
* Finds Pets by status

View File

@@ -13,14 +13,13 @@ import okhttp3.OkHttpClient
import okhttp3.Request
import okhttp3.MediaType.Companion.toMediaTypeOrNull
import okhttp3.RequestBody
import okhttp3.RequestBody.Companion.toRequestBody
class OAuthOkHttpClient(
private var client: OkHttpClient
private var client: OkHttpClient = OkHttpClient()
) : HttpClient {
constructor() : this(OkHttpClient())
@Throws(OAuthSystemException::class, OAuthProblemException::class)
override fun <T : OAuthClientResponse?> execute(
request: OAuthClientRequest,
@@ -39,7 +38,7 @@ class OAuthOkHttpClient(
}
}
val body: RequestBody? = if (request.body != null) RequestBody.create(mediaType, request.body) else null
val body: RequestBody? = if (request.body != null) request.body.toRequestBody(mediaType) else null
requestBuilder.method(requestMethod, body)
try {
@@ -48,6 +47,7 @@ class OAuthOkHttpClient(
response.body?.string(),
response.body?.contentType()?.toString(),
response.code,
response.headers.toMultimap(),
responseClass)
} catch (e: IOException) {
throw OAuthSystemException(e)

View File

@@ -7,6 +7,7 @@ import org.openapitools.client.auth.OAuth
import org.openapitools.client.auth.OAuth.AccessTokenListener
import org.openapitools.client.auth.OAuthFlow
import okhttp3.Call
import okhttp3.Interceptor
import okhttp3.OkHttpClient
import retrofit2.Retrofit
@@ -22,7 +23,7 @@ class ApiClient(
private var baseUrl: String = defaultBasePath,
private val okHttpClientBuilder: OkHttpClient.Builder? = null,
private val serializerBuilder: Moshi.Builder = Serializer.moshiBuilder,
private val okHttpClient : OkHttpClient? = null,
private val callFactory : Call.Factory? = null,
private val converterFactory: Converter.Factory? = null,
) {
private val apiAuthorizations = mutableMapOf<String, Interceptor>()
@@ -183,8 +184,8 @@ class ApiClient(
}
fun <S> createService(serviceClass: Class<S>): S {
val usedClient = this.okHttpClient ?: clientBuilder.build()
return retrofitBuilder.client(usedClient).build().create(serviceClass)
val usedCallFactory = this.callFactory ?: clientBuilder.build()
return retrofitBuilder.callFactory(usedCallFactory).build().create(serviceClass)
}
private fun normalizeBaseUrl() {

View File

@@ -12,6 +12,7 @@ object Serializer {
.add(LocalDateAdapter())
.add(UUIDAdapter())
.add(ByteArrayAdapter())
.add(URIAdapter())
.add(KotlinJsonAdapterFactory())
.add(BigDecimalAdapter())
.add(BigIntegerAdapter())

View File

@@ -0,0 +1,13 @@
package org.openapitools.client.infrastructure
import com.squareup.moshi.FromJson
import com.squareup.moshi.ToJson
import java.net.URI
class URIAdapter {
@ToJson
fun toJson(uri: URI) = uri.toString()
@FromJson
fun fromJson(s: String): URI = URI.create(s)
}

View File

@@ -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)
}