Skip to content
GitLab
    • Explore Projects Groups Snippets
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Merge requests
  • !6999

[Kotlin] Make ApiClient in jvm-retrofit2 be able to use own OkHttpClient

  • Review changes

  • Download
  • Email patches
  • Plain diff
Merged Administrator requested to merge github/fork/tgerth/jvm-retrofit2-apiclient-kotlin into master 5 years ago
  • Overview 0
  • Commits 2
  • Pipelines 0
  • Changes 2

Created by: tgerth

PR checklist

  • Read the contribution guidelines.
  • If contributing template-only or documentation-only changes which will change sample output, build the project beforehand.
  • Run the shell script ./bin/generate-samples.sh bin/configs/kotlin-jvm-retrofit2*.
  • File the PR against the correct branch: master
  • Copy the technical committee to review the pull request if your PR is targeting a particular programming language.

similar to PR: #6699

Compare
  • master (base)

and
  • latest version
    a8ba5015
    2 commits, 2 years ago

2 files
+ 10
- 4

    Preferences

    File browser
    Compare changes
modules/…/…/…/…/…/‎…/…/infrastructure‎
ApiClient.‎kt.mustache‎ +5 -2
samples/…/…/…‎/…/…/…/…/…/…/…‎
ApiCli‎ent.kt‎ +5 -2
modules/openapi-generator/src/main/resources/kotlin-client/libraries/jvm-retrofit2/infrastructure/ApiClient.kt.mustache
+ 5
- 2
  • View file @ a8ba5015

  • Edit in single-file editor

  • Open in Web IDE


@@ -45,7 +45,8 @@ import retrofit2.converter.moshi.MoshiConverterFactory
{{#nonPublicApi}}internal {{/nonPublicApi}}class ApiClient(
private var baseUrl: String = defaultBasePath,
private val okHttpClientBuilder: OkHttpClient.Builder? = null,
private val serializerBuilder: {{#gson}}Gson{{/gson}}{{#moshi}}Moshi.{{/moshi}}Builder = Serializer.{{#gson}}gson{{/gson}}{{#moshi}}moshi{{/moshi}}Builder
private val serializerBuilder: {{#gson}}Gson{{/gson}}{{#moshi}}Moshi.{{/moshi}}Builder = Serializer.{{#gson}}gson{{/gson}}{{#moshi}}moshi{{/moshi}}Builder,
private val okHttpClient : OkHttpClient? = null
) {
private val apiAuthorizations = mutableMapOf<String, Interceptor>()
var logger: ((String) -> Unit)? = null
@@ -281,7 +282,9 @@ import retrofit2.converter.moshi.MoshiConverterFactory
}
fun <S> createService(serviceClass: Class<S>): S {
return retrofitBuilder.client(clientBuilder.build()).build().create(serviceClass)
var usedClient: OkHttpClient? = null
this.okHttpClient?.let { usedClient = it } ?: run {usedClient = clientBuilder.build()}
return retrofitBuilder.client(usedClient).build().create(serviceClass)
}
private fun normalizeBaseUrl() {
samples/client/petstore/kotlin-retrofit2/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt
+ 5
- 2
  • View file @ a8ba5015

  • Edit in single-file editor

  • Open in Web IDE


@@ -18,7 +18,8 @@ import retrofit2.converter.moshi.MoshiConverterFactory
class ApiClient(
private var baseUrl: String = defaultBasePath,
private val okHttpClientBuilder: OkHttpClient.Builder? = null,
private val serializerBuilder: Moshi.Builder = Serializer.moshiBuilder
private val serializerBuilder: Moshi.Builder = Serializer.moshiBuilder,
private val okHttpClient : OkHttpClient? = null
) {
private val apiAuthorizations = mutableMapOf<String, Interceptor>()
var logger: ((String) -> Unit)? = null
@@ -171,7 +172,9 @@ class ApiClient(
}
fun <S> createService(serviceClass: Class<S>): S {
return retrofitBuilder.client(clientBuilder.build()).build().create(serviceClass)
var usedClient: OkHttpClient? = null
this.okHttpClient?.let { usedClient = it } ?: run {usedClient = clientBuilder.build()}
return retrofitBuilder.client(usedClient).build().create(serviceClass)
}
private fun normalizeBaseUrl() {
0 Assignees
None
Assign to
0 Reviewers
None
Request review from
Labels
3
Client: Kotlin Client: Retrofit Enhancement: General
3
Client: Kotlin Client: Retrofit Enhancement: General
    Assign labels
  • Manage project labels

Milestone
5.0.0
5.0.0 (expired)
None
Time tracking
No estimate or time spent
Lock merge request
Unlocked
1
1 participant
Administrator
Reference: OpenAPITools/openapi-generator!6999
Source branch: github/fork/tgerth/jvm-retrofit2-apiclient-kotlin

Menu

Explore Projects Groups Snippets