[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

@@ -62,26 +62,26 @@ public class ApiClient extends JavaTimeFormatter {
public enum CollectionFormat {
CSV(","), TSV("\t"), SSV(" "), PIPES("|"), MULTI(null);
private final String separator;
protected final String separator;
CollectionFormat(String separator) {
this.separator = separator;
}
private String collectionToString(Collection<?> collection) {
protected String collectionToString(Collection<?> collection) {
return StringUtils.collectionToDelimitedString(collection, separator);
}
}
private final HttpHeaders defaultHeaders = new HttpHeaders();
private final MultiValueMap<String, String> defaultCookies = new LinkedMultiValueMap<>();
protected final HttpHeaders defaultHeaders = new HttpHeaders();
protected final MultiValueMap<String, String> defaultCookies = new LinkedMultiValueMap<>();
private String basePath = "http://localhost:3000";
protected String basePath = "http://localhost:3000";
private final RestClient restClient;
private final DateFormat dateFormat;
private final ObjectMapper objectMapper;
protected final RestClient restClient;
protected final DateFormat dateFormat;
protected final ObjectMapper objectMapper;
private Map<String, Authentication> authentications;
protected Map<String, Authentication> authentications;
public ApiClient() {
@@ -103,7 +103,7 @@ public class ApiClient extends JavaTimeFormatter {
this.init();
}
private ApiClient(RestClient restClient, DateFormat format) {
protected ApiClient(RestClient restClient, DateFormat format) {
this(restClient, createDefaultObjectMapper(format), format);
}
@@ -580,7 +580,7 @@ public class ApiClient extends JavaTimeFormatter {
* @param uriParams The path parameters
* return templatized query string
*/
private String generateQueryUri(MultiValueMap<String, String> queryParams, Map<String, Object> uriParams) {
protected String generateQueryUri(MultiValueMap<String, String> queryParams, Map<String, Object> uriParams) {
StringBuilder queryBuilder = new StringBuilder();
queryParams.forEach((name, values) -> {
if (CollectionUtils.isEmpty(values)) {
@@ -606,7 +606,7 @@ public class ApiClient extends JavaTimeFormatter {
return queryBuilder.toString();
}
private RestClient.RequestBodySpec prepareRequest(String path, HttpMethod method, Map<String, Object> pathParams,
protected RestClient.RequestBodySpec prepareRequest(String path, HttpMethod method, Map<String, Object> pathParams,
MultiValueMap<String, String> queryParams, Object body, HttpHeaders headerParams,
MultiValueMap<String, String> cookieParams, MultiValueMap<String, Object> formParams, List<MediaType> accept,
MediaType contentType, String[] authNames) {
@@ -682,7 +682,7 @@ public class ApiClient extends JavaTimeFormatter {
* @param cookies map all cookies
* @return header string for cookies.
*/
private String buildCookieHeader(MultiValueMap<String, String> cookies) {
protected String buildCookieHeader(MultiValueMap<String, String> cookies) {
final StringBuilder cookieValue = new StringBuilder();
String delimiter = "";
for (final Map.Entry<String, List<String>> entry : cookies.entrySet()) {