swagger-codegen icon indicating copy to clipboard operation
swagger-codegen copied to clipboard

Suggestion : Creating the global variable WebTarget target

Open Clement44Ges opened this issue 1 year ago • 0 comments

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);

Clement44Ges avatar Mar 08 '24 11:03 Clement44Ges