forked from loafle/openapi-generator-original
Fix #13369: kotlin-client with okhttp doesn't escape path parameters with slashes correctly (#13370)
* Fix #13369 * Regenarate samples * Fix support for okhttp3
This commit is contained in:
@@ -22,6 +22,7 @@ package org.openapitools.client.apis
|
||||
|
||||
import java.io.IOException
|
||||
import okhttp3.OkHttpClient
|
||||
import okhttp3.HttpUrl
|
||||
|
||||
import org.openapitools.client.models.ModelWithEnumPropertyHavingDefault
|
||||
|
||||
@@ -116,4 +117,7 @@ class DefaultApi(basePath: kotlin.String = defaultBasePath, client: OkHttpClient
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
private fun encodeURIComponent(uriComponent: kotlin.String): kotlin.String =
|
||||
HttpUrl.Builder().scheme("http").host("localhost").addPathSegment(uriComponent).build().encodedPathSegments[0]
|
||||
}
|
||||
|
||||
@@ -145,7 +145,7 @@ open class ApiClient(val baseUrl: String, val client: OkHttpClient = defaultClie
|
||||
val httpUrl = baseUrl.toHttpUrlOrNull() ?: throw IllegalStateException("baseUrl is invalid.")
|
||||
|
||||
val url = httpUrl.newBuilder()
|
||||
.addPathSegments(requestConfig.path.trimStart('/'))
|
||||
.addEncodedPathSegments(requestConfig.path.trimStart('/'))
|
||||
.apply {
|
||||
requestConfig.query.forEach { query ->
|
||||
query.value.forEach { queryValue ->
|
||||
|
||||
Reference in New Issue
Block a user