[Java] Make Java ApiClient extendable (#21251)

* Make all Java ApiClients in templates extendable

* Make all Java ApiClients in samples extendable

* Fix compilation of enum constructor

* Fix compilation of enum constructor in templates
This commit is contained in:
Alex B
2025-05-11 14:47:40 +00:00
committed by GitHub
parent be17698320
commit 57bf6925bb
89 changed files with 1243 additions and 1243 deletions

View File

@@ -85,13 +85,13 @@ import org.openapitools.client.auth.ApiKeyAuth;
*/
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.14.0-SNAPSHOT")
public class ApiClient extends JavaTimeFormatter {
private static final Pattern JSON_MIME_PATTERN = Pattern.compile("(?i)^(application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(;.*)?$");
protected static final Pattern JSON_MIME_PATTERN = Pattern.compile("(?i)^(application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(;.*)?$");
protected Map<String, String> defaultHeaderMap = new HashMap<>();
protected Map<String, String> defaultCookieMap = new HashMap<>();
protected String basePath = "http://petstore.swagger.io:80/v2";
protected String userAgent;
private static final Logger log = Logger.getLogger(ApiClient.class.getName());
protected static final Logger log = Logger.getLogger(ApiClient.class.getName());
protected List<ServerConfiguration> servers = new ArrayList<>(Arrays.asList(
new ServerConfiguration(
@@ -140,7 +140,7 @@ public class ApiClient extends JavaTimeFormatter {
protected boolean debugging = false;
protected ClientConfig clientConfig;
protected int connectionTimeout = 0;
private int readTimeout = 0;
protected int readTimeout = 0;
protected Client httpClient;
protected JSON json;
@@ -311,7 +311,7 @@ public class ApiClient extends JavaTimeFormatter {
return this;
}
private void updateBasePath() {
protected void updateBasePath() {
if (serverIndex != null) {
setBasePath(servers.get(serverIndex).URL(serverVariables));
}
@@ -857,7 +857,7 @@ public class ApiClient extends JavaTimeFormatter {
* @param key Key of the object
* @param multiPart MultiPart to add the form param to
*/
private void addParamToMultipart(Object value, String key, MultiPart multiPart) {
protected void addParamToMultipart(Object value, String key, MultiPart multiPart) {
if (value instanceof File) {
File file = (File) value;
FormDataContentDisposition contentDisp = FormDataContentDisposition.name(key)
@@ -1155,7 +1155,7 @@ public class ApiClient extends JavaTimeFormatter {
}
}
private Response sendRequest(String method, Invocation.Builder invocationBuilder, Entity<?> entity) {
protected Response sendRequest(String method, Invocation.Builder invocationBuilder, Entity<?> entity) {
Response response;
if ("POST".equals(method)) {
response = invocationBuilder.post(entity);
@@ -1217,7 +1217,7 @@ public class ApiClient extends JavaTimeFormatter {
return clientConfig;
}
private void applyDebugSetting(ClientConfig clientConfig) {
protected void applyDebugSetting(ClientConfig clientConfig) {
if (debugging) {
clientConfig.register(new LoggingFeature(java.util.logging.Logger.getLogger(LoggingFeature.DEFAULT_LOGGER_NAME), java.util.logging.Level.INFO, LoggingFeature.Verbosity.PAYLOAD_ANY, 1024*50 /* Log payloads up to 50K */));
clientConfig.property(LoggingFeature.LOGGING_FEATURE_VERBOSITY, LoggingFeature.Verbosity.PAYLOAD_ANY);