swagger-codegen contains a template-driven engine to generate documentation, API clients and server stubs in different languages by parsing your OpenAPI / Swagger definition.
Here is the code for the ApiClient.setDebugging method:
public ApiClient setDebugging(boolean debugging) {
if (debugging != this.debugging) {
if (debugging) {
loggingInterceptor = new HttpLoggingInterceptor();
loggingInterceptor.setLevel(Level.BODY);
httpClient.interceptors().add(loggingInterceptor);
} else {
httpClient.interceptors().remove(loggingInterceptor);
loggingInterceptor = null;
}
}
this.debugging = debugging;
return this;
}
Configuration.getDefaultClient() returns an ApiClient instance in which "debugging" is already set to true. When the "setDebugging" method is called, passing the boolean true, the method fails to add the LoggingInterceptors to the HTTP client and HTTP debugging is disabled.
Swagger-codegen version
I generated the Java client from the master branch, which I believe was 2.3.0 at the time. The same code for the setDebugging method is present in version 2.2.1, so this is not a regression (from that point at least).
For copyright reasons I cannot include the api.yaml file I was using.
Steps to reproduce
Generate the JAVA client jar for any api.yaml file.
Using the generated code, get an instance of the default API client using Configuration.getDefaultClient().
Call the "setDebugging" method on the client instance passing the boolean argument true.
Using the client instance, exercise any test code that involves HTTP traffic between the client and a server.
Note that the send-receive traffic is not included in the test output.
Related issues/PRs
Not that I could find.
Suggest a fix/enhancement
When the boolean "true" is passed to the setDebugging method, interrogate the HTTP client to determine whether LogginInterceptors have already been added or not. If not, then add them.
Description
Here is the code for the ApiClient.setDebugging method:
public ApiClient setDebugging(boolean debugging) { if (debugging != this.debugging) { if (debugging) { loggingInterceptor = new HttpLoggingInterceptor(); loggingInterceptor.setLevel(Level.BODY); httpClient.interceptors().add(loggingInterceptor); } else { httpClient.interceptors().remove(loggingInterceptor); loggingInterceptor = null; } } this.debugging = debugging; return this; }
Configuration.getDefaultClient() returns an ApiClient instance in which "debugging" is already set to true. When the "setDebugging" method is called, passing the boolean true, the method fails to add the LoggingInterceptors to the HTTP client and HTTP debugging is disabled.
Swagger-codegen version
I generated the Java client from the master branch, which I believe was 2.3.0 at the time. The same code for the setDebugging method is present in version 2.2.1, so this is not a regression (from that point at least).
Command line used for generation
java -jar swagger-codegen-cli-2.3.0.jar generate -i api.yaml -l java -o SwarmApi
YAML file
For copyright reasons I cannot include the api.yaml file I was using.
Steps to reproduce
Related issues/PRs
Not that I could find.
Suggest a fix/enhancement
When the boolean "true" is passed to the setDebugging method, interrogate the HTTP client to determine whether LogginInterceptors have already been added or not. If not, then add them.