mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-12-04 09:36:12 +00:00
[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:
@@ -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()) {
|
||||
|
||||
Reference in New Issue
Block a user