swagger-api / swagger-api/swagger-codegen

[Kotlin] unable to get access to OkHttpClient to enable http logging.

Open
#7,602 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Mustache
Stars
17.8k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

Description

The Java swagger client allows one to configure HTTP logging via an Api Configuration. The Kotlin client does not seem to allow this. The OkHttpClient instance is private to the ApiClient class.

Swagger-codegen version

2.3.1

Swagger declaration file content or url

This change is not directly related to API models.

Command line used for generation

This change is not directly related to API models.

Steps to reproduce

Not a bug. This is a feature request.

Related issues/PRs
Suggest a fix/enhancement

I have tested an experimental change here: https://github.com/swagger-api/swagger-codegen/compare/master...kgilmer:kotlin-logger

This replaces the static instance of the http client with a function that the client passes in which the http client is created. This allows clients to specify any desired configuration. However, I am not sure this is the best approach and would like feedback.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading the Kotlin ApiClient class where the private OkHttpClient instance is defined, then review the linked kotlin-logger comparison to understand the proposed injection approach. The change is done when Kotlin clients can configure HTTP logging or otherwise provide the desired HTTP client, with the approach validated against the existing generated-client behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
kotlin
Domain
api, tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.