OpenAPITools / OpenAPITools/openapi-generator

[REQ] [Java] [okhttp-gson] Allow overriding tokenUrl in ApiClient constructor

Open
#22,167 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Enhancement: Feature
Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

Is your feature request related to a problem? Please describe.

I have an openapi spec with a security section like:

  securitySchemes:
    mySecurityScheme:
      type: oauth2
      flows:
        clientCredentials:
          tokenUrl: https://example.com/token

I want to override tokenUrl at runtime. Currently the generated ApiClient class does not have a constructor or setter to allow overriding this value.

Describe the solution you'd like

A new ApiClient constructor that allows specifying tokenUrl.

The closest existing constructor is:

public ApiClient(String basePath, String clientId, String clientSecret, Map<String, String> parameters)

We could have a new constructor with this signature:

public ApiClient(String basePath, String clientId, String clientSecret, String tokenUrl, Map<String, String> parameters)

(could possibly use URI instead of String for tokenUrl).

Describe alternatives you've considered

My current workaround is to extend ApiClient and create the new constructor in the subclass.

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 locating the generated Java okhttp-gson ApiClient and its existing constructor with basePath, clientId, clientSecret, and parameters. Add the requested constructor path so tokenUrl can be supplied at runtime, then verify that generated clients accept the value while preserving the existing constructor behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
api
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.