swagger-api / swagger-api/swagger-codegen

Suggestion : Creating the global variable WebTarget target

Open
#12,353 0 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

Suggestion : In the generated ApiClient class, all attributes are not defined as global variables. I'm thinking of the local variable "WebTarget target" in the invokeAPI method.
To address observability problems it would be interesting to be able to recover it after treatment.

language : java (17)
library : jersey3

Swagger-codegen version

Check with maven

    <groupId>io.swagger.codegen.v3</groupId>
    <artifactId>swagger-codegen-maven-plugin</artifactId>
    <version>3.0.52</version>
Swagger declaration file content or url
Command line used for generation
Steps to reproduce
Related issues/PRs
Suggestion

Creating the global variable

    protected WebTarget target;
    
    public ApiClient() {

Declare the getter

    public WebTarget getWebTarget(){
        return this.target;
    }

Use variable global in the method invokeAPI

    public <T> T invokeAPI(String path, String method, List<Pair> queryParams, Object body, Map<String, String> headerParams, Map<String, Object> formParams, String accept, String contentType, String[] authNames, GenericType<T> returnType) throws ApiException {
        updateParamsForAuth(authNames, queryParams, headerParams);

        // Use variable global
        this.target = httpClient.target(this.basePath + path);

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

Search the Jersey 3 generation templates for the ApiClient class and its invokeAPI method, then inspect the generated Java client output. Done means the generated client exposes the WebTarget used for invocation while preserving the existing request 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
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.