Skip to content
GitLab
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
  • Issues
  • #9448
Closed
Open
Issue created May 11, 2021 by Administrator@rootContributor

[Kotlin][Retrofit] Change OkHttpClient parameter to Call.Factory

Created by: shanselm-ergon

With OpenApi version 5 a new constructor parameter got added to pass an OkHttpClient to the ApiClient ([#6855]). We thought this is good enough for us, but now we run into some problems with this approach. The parameter should be changed to a Call.Factory instead.

  • Smaller interface
  • Only the Call.Factory is used (see retrofitBuilder.client(usedClient), this just sets the Call.Factory)
  • It is more like it was before version 5 of OpenApi (the exposed adapterBuilder had a callFactory method)
  • In our use case, we need to replace the underlying http-client during runtime. If we only have to pass the Call.Factory we can easily do this, but if we have to pass the client itself we can't achieve this properly.

Describe the solution you'd like

Change the parameter from OkHttpClient to Call.Factory. Each OkHttpClient is also a Call.Factory, so minimal effort to adopt this change.

Describe alternatives you've considered

With the knowledge that only the Call.Factory interface is used by the ApiClient we could also create our own version of a OkHttpClient and only overwrite the newCall(request) method. But this is based on internal knowledge, which should not be part of the ApiClient API.

I will create a pull request suggestion for this improvement.

Assignee
Assign to
Time tracking