[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

@@ -83,9 +83,9 @@ import org.openapitools.client.auth.HttpBearerAuth;
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.14.0-SNAPSHOT")
public class ApiClient extends JavaTimeFormatter {
private Map<String, String> defaultHeaderMap = new HashMap<String, String>();
private Map<String, String> defaultCookieMap = new HashMap<String, String>();
private String basePath = "http://localhost:3000";
protected Map<String, String> defaultHeaderMap = new HashMap<String, String>();
protected Map<String, String> defaultCookieMap = new HashMap<String, String>();
protected String basePath = "http://localhost:3000";
protected List<ServerConfiguration> servers = new ArrayList<ServerConfiguration>(Arrays.asList(
new ServerConfiguration(
"http://localhost:3000",
@@ -95,22 +95,22 @@ public class ApiClient extends JavaTimeFormatter {
));
protected Integer serverIndex = 0;
protected Map<String, String> serverVariables = null;
private boolean debugging = false;
private int connectionTimeout = 0;
protected boolean debugging = false;
protected int connectionTimeout = 0;
private CloseableHttpClient httpClient;
private ObjectMapper objectMapper;
protected CloseableHttpClient httpClient;
protected ObjectMapper objectMapper;
protected String tempFolderPath = null;
private Map<String, Authentication> authentications;
protected Map<String, Authentication> authentications;
private Map<Long, Integer> lastStatusCodeByThread = new ConcurrentHashMap<>();
private Map<Long, Map<String, List<String>>> lastResponseHeadersByThread = new ConcurrentHashMap<>();
protected Map<Long, Integer> lastStatusCodeByThread = new ConcurrentHashMap<>();
protected Map<Long, Map<String, List<String>>> lastResponseHeadersByThread = new ConcurrentHashMap<>();
private DateFormat dateFormat;
protected DateFormat dateFormat;
// Methods that can have a request body
private static List<String> bodyMethods = Arrays.asList("POST", "PUT", "DELETE", "PATCH");
protected static List<String> bodyMethods = Arrays.asList("POST", "PUT", "DELETE", "PATCH");
public ApiClient(CloseableHttpClient httpClient) {
objectMapper = new ObjectMapper();
@@ -675,7 +675,7 @@ public class ApiClient extends JavaTimeFormatter {
/**
* Parse content type object from header value
*/
private ContentType getContentType(String headerValue) throws ApiException {
protected ContentType getContentType(String headerValue) throws ApiException {
try {
return ContentType.parse(headerValue);
} catch (UnsupportedCharsetException e) {
@@ -686,7 +686,7 @@ public class ApiClient extends JavaTimeFormatter {
/**
* Get content type of a response or null if one was not provided
*/
private String getResponseMimeType(HttpResponse response) throws ApiException {
protected String getResponseMimeType(HttpResponse response) throws ApiException {
Header contentTypeHeader = response.getFirstHeader("Content-Type");
if (contentTypeHeader != null) {
return getContentType(contentTypeHeader.getValue()).getMimeType();
@@ -795,7 +795,7 @@ public class ApiClient extends JavaTimeFormatter {
}
}
private File downloadFileFromResponse(CloseableHttpResponse response) throws IOException {
protected File downloadFileFromResponse(CloseableHttpResponse response) throws IOException {
Header contentDispositionHeader = response.getFirstHeader("Content-Disposition");
String contentDisposition = contentDispositionHeader == null ? null : contentDispositionHeader.getValue();
File file = prepareDownloadFile(contentDisposition);
@@ -866,7 +866,7 @@ public class ApiClient extends JavaTimeFormatter {
* @param urlQueryDeepObject URL query string of the deep object parameters
* @return The full URL
*/
private String buildUrl(String path, List<Pair> queryParams, List<Pair> collectionQueryParams, String urlQueryDeepObject) {
protected String buildUrl(String path, List<Pair> queryParams, List<Pair> collectionQueryParams, String urlQueryDeepObject) {
String baseURL = getBaseURL();
final StringBuilder url = new StringBuilder();
@@ -1045,7 +1045,7 @@ public class ApiClient extends JavaTimeFormatter {
* @param headerParams Header parameters
* @param cookieParams Cookie parameters
*/
private void updateParamsForAuth(String[] authNames, List<Pair> queryParams, Map<String, String> headerParams, Map<String, String> cookieParams) {
protected void updateParamsForAuth(String[] authNames, List<Pair> queryParams, Map<String, String> headerParams, Map<String, String> cookieParams) {
for (String authName : authNames) {
Authentication auth = authentications.get(authName);
if (auth == null) throw new RuntimeException("Authentication undefined: " + authName);