Skip to content

[kotlin][KTOR] remove unnecessary dependencies #13640

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ For more information, please visit [{{{infoUrl}}}]({{{infoUrl}}})
## Requires

{{#jvm}}
* Kotlin 1.4.30
* Gradle 6.8.3
* Kotlin 1.6.10
* Gradle 7.5
{{/jvm}}
{{#multiplatform}}
* Kotlin 1.5.10
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ wrapper {
buildscript {
ext.kotlin_version = '1.6.10'
{{#jvm-ktor}}
ext.ktor_version = '2.0.3'
ext.ktor_version = '2.1.2'
{{/jvm-ktor}}
{{#jvm-retrofit2}}
ext.retrofitVersion = '2.9.0'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import io.ktor.client.request.parameter
import io.ktor.client.request.request
import io.ktor.client.request.setBody
import io.ktor.client.statement.HttpResponse
import io.ktor.http.contentType
import io.ktor.http.HttpHeaders
import io.ktor.http.HttpMethod
import io.ktor.http.Parameters
Expand All @@ -34,11 +35,6 @@ import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule
import com.fasterxml.jackson.core.util.DefaultIndenter
import com.fasterxml.jackson.core.util.DefaultPrettyPrinter
{{/jackson}}
import org.openapitools.client.auth.ApiKeyAuth
import org.openapitools.client.auth.Authentication
import org.openapitools.client.auth.HttpBasicAuth
import org.openapitools.client.auth.HttpBearerAuth
import org.openapitools.client.auth.OAuth
import {{packageName}}.auth.*

{{#nonPublicApi}}internal {{/nonPublicApi}}open class ApiClient(
Expand Down Expand Up @@ -111,7 +107,7 @@ import {{packageName}}.auth.*
* @param username Username
*/
fun setUsername(username: String) {
val auth = authentications.values.firstOrNull { it is HttpBasicAuth } as HttpBasicAuth?
val auth = authentications?.values?.firstOrNull { it is HttpBasicAuth } as HttpBasicAuth?
?: throw Exception("No HTTP basic authentication configured")
auth.username = username
}
Expand All @@ -122,7 +118,7 @@ import {{packageName}}.auth.*
* @param password Password
*/
fun setPassword(password: String) {
val auth = authentications.values.firstOrNull { it is HttpBasicAuth } as HttpBasicAuth?
val auth = authentications?.values?.firstOrNull { it is HttpBasicAuth } as HttpBasicAuth?
?: throw Exception("No HTTP basic authentication configured")
auth.password = password
}
Expand All @@ -134,7 +130,7 @@ import {{packageName}}.auth.*
* @param paramName The name of the API key parameter, or null or set the first key.
*/
fun setApiKey(apiKey: String, paramName: String? = null) {
val auth = authentications.values.firstOrNull { it is ApiKeyAuth && (paramName == null || paramName == it.paramName)} as ApiKeyAuth?
val auth = authentications?.values?.firstOrNull { it is ApiKeyAuth && (paramName == null || paramName == it.paramName)} as ApiKeyAuth?
?: throw Exception("No API key authentication configured")
auth.apiKey = apiKey
}
Expand All @@ -146,7 +142,7 @@ import {{packageName}}.auth.*
* @param paramName The name of the API key parameter, or null or set the first key.
*/
fun setApiKeyPrefix(apiKeyPrefix: String, paramName: String? = null) {
val auth = authentications.values.firstOrNull { it is ApiKeyAuth && (paramName == null || paramName == it.paramName) } as ApiKeyAuth?
val auth = authentications?.values?.firstOrNull { it is ApiKeyAuth && (paramName == null || paramName == it.paramName) } as ApiKeyAuth?
?: throw Exception("No API key authentication configured")
auth.apiKeyPrefix = apiKeyPrefix
}
Expand All @@ -157,7 +153,7 @@ import {{packageName}}.auth.*
* @param accessToken Access token
*/
fun setAccessToken(accessToken: String) {
val auth = authentications.values.firstOrNull { it is OAuth } as OAuth?
val auth = authentications?.values?.firstOrNull { it is OAuth } as OAuth?
?: throw Exception("No OAuth2 authentication configured")
auth.accessToken = accessToken
}
Expand All @@ -168,7 +164,7 @@ import {{packageName}}.auth.*
* @param bearerToken The bearer token.
*/
fun setBearerToken(bearerToken: String) {
val auth = authentications.values.firstOrNull { it is HttpBearerAuth } as HttpBearerAuth?
val auth = authentications?.values?.firstOrNull { it is HttpBearerAuth } as HttpBearerAuth?
?: throw Exception("No Bearer authentication configured")
auth.bearerToken = bearerToken
}
Expand Down Expand Up @@ -199,8 +195,9 @@ import {{packageName}}.auth.*
}
this.method = requestConfig.method.httpMethod
headers.filter { header -> !UNSAFE_HEADERS.contains(header.key) }.forEach { header -> this.header(header.key, header.value) }
if (requestConfig.method in listOf(RequestMethod.PUT, RequestMethod.POST, RequestMethod.PATCH))
if (requestConfig.method in listOf(RequestMethod.PUT, RequestMethod.POST, RequestMethod.PATCH)) {
setBody(body)
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import io.ktor.client.HttpClient
import io.ktor.client.HttpClientConfig
import io.ktor.client.engine.HttpClientEngine
import io.ktor.client.plugins.contentnegotiation.ContentNegotiation
import io.ktor.serialization.kotlinx.json.*
import io.ktor.client.request.*
import io.ktor.client.request.forms.FormDataContent
import io.ktor.client.request.forms.MultiPartFormDataContent
import io.ktor.client.request.header
import io.ktor.client.request.parameter
import io.ktor.client.statement.HttpResponse
import io.ktor.serialization.kotlinx.json.json
import io.ktor.http.*
import io.ktor.http.content.PartData
import kotlin.Unit
Expand Down Expand Up @@ -153,9 +153,9 @@ import {{packageName}}.auth.*
}
this.method = requestConfig.method.httpMethod
headers.filter { header -> !UNSAFE_HEADERS.contains(header.key) }.forEach { header -> this.header(header.key, header.value) }
if (requestConfig.method in listOf(RequestMethod.PUT, RequestMethod.POST, RequestMethod.PATCH))
if (requestConfig.method in listOf(RequestMethod.PUT, RequestMethod.POST, RequestMethod.PATCH)) {
this.setBody(body)

}
}
}

Expand Down
4 changes: 2 additions & 2 deletions samples/client/petstore/kotlin-allOff-discriminator/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ For more information, please visit [https://example.org](https://example.org)

## Requires

* Kotlin 1.4.30
* Gradle 6.8.3
* Kotlin 1.6.10
* Gradle 7.5

## Build

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ This API client was generated by the [OpenAPI Generator](https://openapi-generat

## Requires

* Kotlin 1.4.30
* Gradle 6.8.3
* Kotlin 1.6.10
* Gradle 7.5

## Build

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ This API client was generated by the [OpenAPI Generator](https://openapi-generat

## Requires

* Kotlin 1.4.30
* Gradle 6.8.3
* Kotlin 1.6.10
* Gradle 7.5

## Build

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import io.ktor.client.HttpClient
import io.ktor.client.HttpClientConfig
import io.ktor.client.engine.HttpClientEngine
import io.ktor.client.plugins.contentnegotiation.ContentNegotiation
import io.ktor.serialization.kotlinx.json.*
import io.ktor.client.request.*
import io.ktor.client.request.forms.FormDataContent
import io.ktor.client.request.forms.MultiPartFormDataContent
import io.ktor.client.request.header
import io.ktor.client.request.parameter
import io.ktor.client.statement.HttpResponse
import io.ktor.serialization.kotlinx.json.json
import io.ktor.http.*
import io.ktor.http.content.PartData
import kotlin.Unit
Expand Down Expand Up @@ -142,9 +142,9 @@ open class ApiClient(
}
this.method = requestConfig.method.httpMethod
headers.filter { header -> !UNSAFE_HEADERS.contains(header.key) }.forEach { header -> this.header(header.key, header.value) }
if (requestConfig.method in listOf(RequestMethod.PUT, RequestMethod.POST, RequestMethod.PATCH))
if (requestConfig.method in listOf(RequestMethod.PUT, RequestMethod.POST, RequestMethod.PATCH)) {
this.setBody(body)

}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import io.ktor.client.HttpClient
import io.ktor.client.HttpClientConfig
import io.ktor.client.engine.HttpClientEngine
import io.ktor.client.plugins.contentnegotiation.ContentNegotiation
import io.ktor.serialization.kotlinx.json.*
import io.ktor.client.request.*
import io.ktor.client.request.forms.FormDataContent
import io.ktor.client.request.forms.MultiPartFormDataContent
import io.ktor.client.request.header
import io.ktor.client.request.parameter
import io.ktor.client.statement.HttpResponse
import io.ktor.serialization.kotlinx.json.json
import io.ktor.http.*
import io.ktor.http.content.PartData
import kotlin.Unit
Expand Down Expand Up @@ -142,9 +142,9 @@ open class ApiClient(
}
this.method = requestConfig.method.httpMethod
headers.filter { header -> !UNSAFE_HEADERS.contains(header.key) }.forEach { header -> this.header(header.key, header.value) }
if (requestConfig.method in listOf(RequestMethod.PUT, RequestMethod.POST, RequestMethod.PATCH))
if (requestConfig.method in listOf(RequestMethod.PUT, RequestMethod.POST, RequestMethod.PATCH)) {
this.setBody(body)

}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ This API client was generated by the [OpenAPI Generator](https://openapi-generat

## Requires

* Kotlin 1.4.30
* Gradle 6.8.3
* Kotlin 1.6.10
* Gradle 7.5

## Build

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ This API client was generated by the [OpenAPI Generator](https://openapi-generat

## Requires

* Kotlin 1.4.30
* Gradle 6.8.3
* Kotlin 1.6.10
* Gradle 7.5

## Build

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ This API client was generated by the [OpenAPI Generator](https://openapi-generat

## Requires

* Kotlin 1.4.30
* Gradle 6.8.3
* Kotlin 1.6.10
* Gradle 7.5

## Build

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ This API client was generated by the [OpenAPI Generator](https://openapi-generat

## Requires

* Kotlin 1.4.30
* Gradle 6.8.3
* Kotlin 1.6.10
* Gradle 7.5

## Build

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import io.ktor.client.HttpClient
import io.ktor.client.HttpClientConfig
import io.ktor.client.engine.HttpClientEngine
import io.ktor.client.plugins.contentnegotiation.ContentNegotiation
import io.ktor.serialization.kotlinx.json.*
import io.ktor.client.request.*
import io.ktor.client.request.forms.FormDataContent
import io.ktor.client.request.forms.MultiPartFormDataContent
import io.ktor.client.request.header
import io.ktor.client.request.parameter
import io.ktor.client.statement.HttpResponse
import io.ktor.serialization.kotlinx.json.json
import io.ktor.http.*
import io.ktor.http.content.PartData
import kotlin.Unit
Expand Down Expand Up @@ -142,9 +142,9 @@ open class ApiClient(
}
this.method = requestConfig.method.httpMethod
headers.filter { header -> !UNSAFE_HEADERS.contains(header.key) }.forEach { header -> this.header(header.key, header.value) }
if (requestConfig.method in listOf(RequestMethod.PUT, RequestMethod.POST, RequestMethod.PATCH))
if (requestConfig.method in listOf(RequestMethod.PUT, RequestMethod.POST, RequestMethod.PATCH)) {
this.setBody(body)

}
}
}

Expand Down
4 changes: 2 additions & 2 deletions samples/client/petstore/kotlin-enum-default-value/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ This API client was generated by the [OpenAPI Generator](https://openapi-generat

## Requires

* Kotlin 1.4.30
* Gradle 6.8.3
* Kotlin 1.6.10
* Gradle 7.5

## Build

Expand Down
4 changes: 2 additions & 2 deletions samples/client/petstore/kotlin-gson/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ This API client was generated by the [OpenAPI Generator](https://openapi-generat

## Requires

* Kotlin 1.4.30
* Gradle 6.8.3
* Kotlin 1.6.10
* Gradle 7.5

## Build

Expand Down
4 changes: 2 additions & 2 deletions samples/client/petstore/kotlin-jackson/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ This API client was generated by the [OpenAPI Generator](https://openapi-generat

## Requires

* Kotlin 1.4.30
* Gradle 6.8.3
* Kotlin 1.6.10
* Gradle 7.5

## Build

Expand Down
4 changes: 2 additions & 2 deletions samples/client/petstore/kotlin-json-request-string/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ This API client was generated by the [OpenAPI Generator](https://openapi-generat

## Requires

* Kotlin 1.4.30
* Gradle 6.8.3
* Kotlin 1.6.10
* Gradle 7.5

## Build

Expand Down
4 changes: 2 additions & 2 deletions samples/client/petstore/kotlin-jvm-ktor-gson/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ This API client was generated by the [OpenAPI Generator](https://openapi-generat

## Requires

* Kotlin 1.4.30
* Gradle 6.8.3
* Kotlin 1.6.10
* Gradle 7.5

## Build

Expand Down
2 changes: 1 addition & 1 deletion samples/client/petstore/kotlin-jvm-ktor-gson/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ wrapper {

buildscript {
ext.kotlin_version = '1.6.10'
ext.ktor_version = '2.0.3'
ext.ktor_version = '2.1.2'

repositories {
maven { url "https://repo1.maven.org/maven2" }
Expand Down
Loading