Make all Java ApiClients in templates extendable

This commit is contained in:
AB 2025-05-09 13:44:23 +02:00
parent d6c4634269
commit 59952db1d7
No known key found for this signature in database
GPG Key ID: D5BCEF380182CD94
20 changed files with 222 additions and 222 deletions

View File

@ -65,9 +65,9 @@ import {{invokerPackage}}.auth.OAuth;
{{>generatedAnnotation}}
public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
private Map<String, String> defaultHeaderMap = new HashMap<String, String>();
private Map<String, String> defaultCookieMap = new HashMap<String, String>();
private String basePath = "{{{basePath}}}";
protected Map<String, String> defaultHeaderMap = new HashMap<String, String>();
protected Map<String, String> defaultCookieMap = new HashMap<String, String>();
protected String basePath = "{{{basePath}}}";
protected List<ServerConfiguration> servers = new ArrayList<ServerConfiguration>({{#servers}}{{#-first}}Arrays.asList(
{{/-first}} new ServerConfiguration(
"{{{url}}}",
@ -95,18 +95,18 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
){{/-last}}{{/servers}});
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 Client httpClient;
private ObjectMapper objectMapper;
protected Client httpClient;
protected ObjectMapper objectMapper;
private Map<String, Authentication> authentications;
protected Map<String, Authentication> authentications;
private int statusCode;
private Map<String, List<String>> responseHeaders;
protected int statusCode;
protected Map<String, List<String>> responseHeaders;
private DateFormat dateFormat;
protected DateFormat dateFormat;
public ApiClient() {
objectMapper = new ObjectMapper();
@ -688,7 +688,7 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
* @param collectionQueryParams The collection query parameters
* @return The full URL
*/
private String buildUrl(String path, List<Pair> queryParams, List<Pair> collectionQueryParams) {
protected String buildUrl(String path, List<Pair> queryParams, List<Pair> collectionQueryParams) {
String baseURL;
if (serverIndex != null) {
if (serverIndex < 0 || serverIndex >= servers.size()) {
@ -741,7 +741,7 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
return url.toString();
}
private ClientResponse getAPIResponse(String path, String method, List<Pair> queryParams, List<Pair> collectionQueryParams, Object body, Map<String, String> headerParams, Map<String, String> cookieParams, Map<String, Object> formParams, String accept, String contentType, String[] authNames) throws ApiException {
protected ClientResponse getAPIResponse(String path, String method, List<Pair> queryParams, List<Pair> collectionQueryParams, Object body, Map<String, String> headerParams, Map<String, String> cookieParams, Map<String, Object> formParams, String accept, String contentType, String[] authNames) throws ApiException {
if (body != null && !formParams.isEmpty()) {
throw new ApiException(500, "Cannot have body and form params");
}
@ -854,7 +854,7 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
* @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);
@ -867,7 +867,7 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
* @param formParams Form parameters
* @return HTTP form encoded parameters
*/
private String getXWWWFormUrlencodedParams(Map<String, Object> formParams) {
protected String getXWWWFormUrlencodedParams(Map<String, Object> formParams) {
StringBuilder formParamBuilder = new StringBuilder();
for (Entry<String, Object> param : formParams.entrySet()) {

View File

@ -87,9 +87,9 @@ import {{invokerPackage}}.auth.OAuth;
{{>generatedAnnotation}}
public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
private Map<String, String> defaultHeaderMap = new HashMap<String, String>();
private Map<String, String> defaultCookieMap = new HashMap<String, String>();
private String basePath = "{{{basePath}}}";
protected Map<String, String> defaultHeaderMap = new HashMap<String, String>();
protected Map<String, String> defaultCookieMap = new HashMap<String, String>();
protected String basePath = "{{{basePath}}}";
protected List<ServerConfiguration> servers = new ArrayList<ServerConfiguration>({{#servers}}{{#-first}}Arrays.asList(
{{/-first}} new ServerConfiguration(
"{{{url}}}",
@ -117,22 +117,22 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
){{/-last}}{{/servers}});
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();
@ -757,7 +757,7 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
/**
* 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) {
@ -768,7 +768,7 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
/**
* 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();
@ -877,7 +877,7 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
}
}
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);
@ -948,7 +948,7 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
* @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();
@ -1127,7 +1127,7 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
* @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);

View File

@ -54,16 +54,16 @@ import feign.Retryer;
{{>generatedAnnotation}}
public class ApiClient {
private static final Logger log = Logger.getLogger(ApiClient.class.getName());
protected static final Logger log = Logger.getLogger(ApiClient.class.getName());
public interface Api {}
{{#jackson}}
protected ObjectMapper objectMapper;
{{/jackson}}
private String basePath = "{{{basePath}}}";
private Map<String, RequestInterceptor> apiAuthorizations;
private Feign.Builder feignBuilder;
protected String basePath = "{{{basePath}}}";
protected Map<String, RequestInterceptor> apiAuthorizations;
protected Feign.Builder feignBuilder;
public ApiClient() {
apiAuthorizations = new LinkedHashMap<String, RequestInterceptor>();
@ -167,7 +167,7 @@ public class ApiClient {
}
{{#jackson}}
private ObjectMapper createObjectMapper() {
protected ObjectMapper createObjectMapper() {
ObjectMapper objectMapper = new ObjectMapper();
objectMapper.enable(SerializationFeature.WRITE_ENUMS_USING_TO_STRING);
objectMapper.enable(DeserializationFeature.READ_ENUMS_USING_TO_STRING);
@ -194,7 +194,7 @@ public class ApiClient {
{{/jackson}}
{{#hasOAuthMethods}}
private RequestInterceptor buildOauthRequestInterceptor(OAuthFlow flow, String authorizationUrl, String tokenUrl, String scopes) {
protected RequestInterceptor buildOauthRequestInterceptor(OAuthFlow flow, String authorizationUrl, String tokenUrl, String scopes) {
switch (flow) {
case PASSWORD:
return new OauthPasswordGrant(tokenUrl, scopes);
@ -375,7 +375,7 @@ public class ApiClient {
feignBuilder.requestInterceptor(authorization);
}
private <T extends RequestInterceptor> T getAuthorization(Class<T> type) {
protected <T extends RequestInterceptor> T getAuthorization(Class<T> type) {
return (T) apiAuthorizations.values()
.stream()
.filter(requestInterceptor -> type.isAssignableFrom(requestInterceptor.getClass()))

View File

@ -25,14 +25,14 @@ import java.io.OutputStream;
{{>generatedAnnotation}}
public class ApiClient {
private final String basePath;
private final HttpRequestFactory httpRequestFactory;
private final ObjectMapper objectMapper;
protected final String basePath;
protected final HttpRequestFactory httpRequestFactory;
protected final ObjectMapper objectMapper;
private static final String defaultBasePath = "{{basePath}}";
protected static final String defaultBasePath = "{{basePath}}";
// A reasonable default object mapper. Client can pass in a chosen ObjectMapper anyway, this is just for reasonable defaults.
private static ObjectMapper createDefaultObjectMapper() {
protected static ObjectMapper createDefaultObjectMapper() {
ObjectMapper objectMapper = new ObjectMapper()
{{#failOnUnknownProperties}}
.enable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES)
@ -84,7 +84,7 @@ public class ApiClient {
public class JacksonJsonHttpContent extends AbstractHttpContent {
/* A POJO that can be serialized with a com.fasterxml Jackson ObjectMapper */
private final Object data;
protected final Object data;
public JacksonJsonHttpContent(Object data) {
super(Json.MEDIA_TYPE);

View File

@ -85,13 +85,13 @@ import {{invokerPackage}}.auth.OAuth;
*/
{{>generatedAnnotation}}
public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
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 = "{{{basePath}}}";
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<>({{#servers}}{{#-first}}Arrays.asList(
{{/-first}} new ServerConfiguration(
@ -175,7 +175,7 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
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;
@ -373,14 +373,14 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
return this;
}
private void updateBasePath() {
protected void updateBasePath() {
if (serverIndex != null) {
setBasePath(servers.get(serverIndex).URL(serverVariables));
}
}
{{#hasOAuthMethods}}
private void setOauthBasePath(String basePath) {
protected void setOauthBasePath(String basePath) {
for(Authentication auth : authentications.values()) {
if (auth instanceof OAuth) {
((OAuth) auth).setBasePath(basePath);
@ -1029,7 +1029,7 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
* @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)
@ -1350,7 +1350,7 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
}
}
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);
@ -1412,7 +1412,7 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
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);

View File

@ -85,13 +85,13 @@ import {{invokerPackage}}.auth.OAuth;
*/
{{>generatedAnnotation}}
public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
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 = "{{{basePath}}}";
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<>({{#servers}}{{#-first}}Arrays.asList(
{{/-first}} new ServerConfiguration(
@ -175,7 +175,7 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
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;
@ -373,14 +373,14 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
return this;
}
private void updateBasePath() {
protected void updateBasePath() {
if (serverIndex != null) {
setBasePath(servers.get(serverIndex).URL(serverVariables));
}
}
{{#hasOAuthMethods}}
private void setOauthBasePath(String basePath) {
protected void setOauthBasePath(String basePath) {
for(Authentication auth : authentications.values()) {
if (auth instanceof OAuth) {
((OAuth) auth).setBasePath(basePath);
@ -1029,7 +1029,7 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
* @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)
@ -1350,7 +1350,7 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
}
}
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);
@ -1412,7 +1412,7 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
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);

View File

@ -45,17 +45,17 @@ import static java.nio.charset.StandardCharsets.UTF_8;
{{>generatedAnnotation}}
public class ApiClient {
private HttpClient.Builder builder;
private ObjectMapper mapper;
private String scheme;
private String host;
private int port;
private String basePath;
private Consumer<HttpRequest.Builder> interceptor;
private Consumer<HttpResponse<InputStream>> responseInterceptor;
private Consumer<HttpResponse<String>> asyncResponseInterceptor;
private Duration readTimeout;
private Duration connectTimeout;
protected HttpClient.Builder builder;
protected ObjectMapper mapper;
protected String scheme;
protected String host;
protected int port;
protected String basePath;
protected Consumer<HttpRequest.Builder> interceptor;
protected Consumer<HttpResponse<InputStream>> responseInterceptor;
protected Consumer<HttpResponse<String>> asyncResponseInterceptor;
protected Duration readTimeout;
protected Duration connectTimeout;
public static String valueToString(Object value) {
if (value == null) {
@ -200,7 +200,7 @@ public class ApiClient {
return mapper;
}
private String getDefaultBaseUri() {
protected String getDefaultBaseUri() {
return "{{{basePath}}}";
}

View File

@ -77,7 +77,7 @@ import {{invokerPackage}}.auth.AWS4Auth;
*/
public class ApiClient {
private String basePath = "{{{basePath}}}";
protected String basePath = "{{{basePath}}}";
protected List<ServerConfiguration> servers = new ArrayList<ServerConfiguration>({{#servers}}{{#-first}}Arrays.asList(
{{/-first}} new ServerConfiguration(
"{{{url}}}",
@ -105,29 +105,29 @@ public class ApiClient {
){{/-last}}{{/servers}});
protected Integer serverIndex = 0;
protected Map<String, String> serverVariables = null;
private boolean debugging = false;
private Map<String, String> defaultHeaderMap = new HashMap<String, String>();
private Map<String, String> defaultCookieMap = new HashMap<String, String>();
private String tempFolderPath = null;
protected boolean debugging = false;
protected Map<String, String> defaultHeaderMap = new HashMap<String, String>();
protected Map<String, String> defaultCookieMap = new HashMap<String, String>();
protected String tempFolderPath = null;
private Map<String, Authentication> authentications;
protected Map<String, Authentication> authentications;
private DateFormat dateFormat;
private DateFormat datetimeFormat;
private boolean lenientDatetimeFormat;
private int dateLength;
protected DateFormat dateFormat;
protected DateFormat datetimeFormat;
protected boolean lenientDatetimeFormat;
protected int dateLength;
private InputStream sslCaCert;
private boolean verifyingSsl;
private KeyManager[] keyManagers;
protected InputStream sslCaCert;
protected boolean verifyingSsl;
protected KeyManager[] keyManagers;
private OkHttpClient httpClient;
private JSON json;
protected OkHttpClient httpClient;
protected JSON json;
private HttpLoggingInterceptor loggingInterceptor;
protected HttpLoggingInterceptor loggingInterceptor;
{{#dynamicOperations}}
private Map<String, ApiOperation> operationLookupMap = new HashMap<>();
protected Map<String, ApiOperation> operationLookupMap = new HashMap<>();
{{/dynamicOperations}}
/**
@ -243,11 +243,11 @@ public class ApiClient {
{{/-first}}
{{/oauthMethods}}
{{/hasOAuthMethods}}
private void initHttpClient() {
protected void initHttpClient() {
initHttpClient(Collections.<Interceptor>emptyList());
}
private void initHttpClient(List<Interceptor> interceptors) {
protected void initHttpClient(List<Interceptor> interceptors) {
OkHttpClient.Builder builder = new OkHttpClient.Builder();
builder.addNetworkInterceptor(getProgressInterceptor());
for (Interceptor interceptor: interceptors) {
@ -261,7 +261,7 @@ public class ApiClient {
httpClient = builder.build();
}
private void init() {
protected void init() {
verifyingSsl = true;
json = new JSON();
@ -1715,7 +1715,7 @@ public class ApiClient {
* @param key The key of the Header element
* @param file The file to add to the Header
*/
private void addPartToMultiPartBuilder(MultipartBody.Builder mpBuilder, String key, File file) {
protected void addPartToMultiPartBuilder(MultipartBody.Builder mpBuilder, String key, File file) {
Headers partHeaders = Headers.of("Content-Disposition", "form-data; name=\"" + key + "\"; filename=\"" + file.getName() + "\"");
MediaType mediaType = MediaType.parse(guessContentTypeFromFile(file));
mpBuilder.addPart(partHeaders, RequestBody.create(file, mediaType));
@ -1728,7 +1728,7 @@ public class ApiClient {
* @param key The key of the Header element
* @param obj The complex object to add to the Header
*/
private void addPartToMultiPartBuilder(MultipartBody.Builder mpBuilder, String key, Object obj) {
protected void addPartToMultiPartBuilder(MultipartBody.Builder mpBuilder, String key, Object obj) {
RequestBody requestBody;
if (obj instanceof String) {
requestBody = RequestBody.create((String) obj, MediaType.parse("text/plain"));
@ -1750,7 +1750,7 @@ public class ApiClient {
* Get network interceptor to add it to the httpClient to track download progress for
* async requests.
*/
private Interceptor getProgressInterceptor() {
protected Interceptor getProgressInterceptor() {
return new Interceptor() {
@Override
public Response intercept(Interceptor.Chain chain) throws IOException {
@ -1771,7 +1771,7 @@ public class ApiClient {
* Apply SSL related settings to httpClient according to the current values of
* verifyingSsl and sslCaCert.
*/
private void applySslSettings() {
protected void applySslSettings() {
try {
TrustManager[] trustManagers;
HostnameVerifier hostnameVerifier;
@ -1833,7 +1833,7 @@ public class ApiClient {
}
}
private KeyStore newEmptyKeyStore(char[] password) throws GeneralSecurityException {
protected KeyStore newEmptyKeyStore(char[] password) throws GeneralSecurityException {
try {
KeyStore keyStore = KeyStore.getInstance(KeyStore.getDefaultType());
keyStore.load(null, password);
@ -1861,7 +1861,7 @@ public class ApiClient {
return this;
}
private void addOperationLookupEntry(String path, String method, Operation operation) {
protected void addOperationLookupEntry(String path, String method, Operation operation) {
if ( operation != null && operation.getOperationId() != null) {
operationLookupMap.put(
operation.getOperationId(),
@ -1921,7 +1921,7 @@ public class ApiClient {
* @return The string representation of the HTTP request body
* @throws {{invokerPackage}}.ApiException If fail to serialize the request body object into a string
*/
private String requestBodyToString(RequestBody requestBody) throws ApiException {
protected String requestBodyToString(RequestBody requestBody) throws ApiException {
if (requestBody != null) {
try {
final Buffer buffer = new Buffer();

View File

@ -19,9 +19,9 @@ public class ApiClient {
public static final String BASE_URI = "{{.}}";
{{/basePath}}
private final Config config;
protected final Config config;
private ApiClient(Config config) {
protected ApiClient(Config config) {
this.config = config;
}
@ -38,7 +38,7 @@ public class ApiClient {
{{/apiInfo}}
public static class Config {
private Supplier<RequestSpecBuilder> reqSpecSupplier = () -> new RequestSpecBuilder()
protected Supplier<RequestSpecBuilder> reqSpecSupplier = () -> new RequestSpecBuilder()
{{#basePath}}.setBaseUri(BASE_URI){{/basePath}}
.setConfig(config().objectMapperConfig(objectMapperConfig().defaultObjectMapper({{#gson}}gson(){{/gson}}{{#jackson}}jackson(){{/jackson}})));

View File

@ -74,26 +74,26 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
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 = "{{basePath}}";
protected String basePath = "{{basePath}}";
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() {
@ -118,7 +118,7 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
this.init();
}
private ApiClient(RestClient restClient, DateFormat format) {
protected ApiClient(RestClient restClient, DateFormat format) {
this(restClient, createDefaultObjectMapper(format), format);
}
@ -626,7 +626,7 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
* @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)) {
@ -652,7 +652,7 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
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) {
@ -728,7 +728,7 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
* @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()) {

View File

@ -56,21 +56,21 @@ import {{invokerPackage}}.auth.OAuth;
{{>generatedAnnotation}}
public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
private Map<String, String> defaultHeaderMap = new HashMap<String, String>();
private Map<String, String> defaultCookieMap = new HashMap<String, String>();
private String basePath = "{{{basePath}}}";
private boolean debugging = false;
protected Map<String, String> defaultHeaderMap = new HashMap<String, String>();
protected Map<String, String> defaultCookieMap = new HashMap<String, String>();
protected String basePath = "{{{basePath}}}";
protected boolean debugging = false;
private Client httpClient;
private JSON json;
private String tempFolderPath = null;
protected Client httpClient;
protected JSON json;
protected String tempFolderPath = null;
private Map<String, Authentication> authentications;
protected Map<String, Authentication> authentications;
private int statusCode;
private Map<String, List<String>> responseHeaders;
protected int statusCode;
protected Map<String, List<String>> responseHeaders;
private DateFormat dateFormat;
protected DateFormat dateFormat;
public ApiClient() {
json = new JSON();
@ -707,7 +707,7 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
}
}
private Response invoke(Invocation.Builder invocationBuilder, String method, Entity<?> entity) throws ApiException {
protected Response invoke(Invocation.Builder invocationBuilder, String method, Entity<?> entity) throws ApiException {
Response response = null;
if ("GET".equals(method)) {
@ -736,7 +736,7 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
/**
* Build the Client used to make HTTP requests.
*/
private Client buildHttpClient(boolean debugging) {
protected Client buildHttpClient(boolean debugging) {
final ClientConfiguration clientConfig = new ClientConfiguration(ResteasyProviderFactory.getInstance());
clientConfig.register(json);
if(debugging){
@ -744,7 +744,7 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
}
return ClientBuilder.newClient(clientConfig);
}
private Map<String, List<String>> buildResponseHeaders(Response response) {
protected Map<String, List<String>> buildResponseHeaders(Response response) {
Map<String, List<String>> responseHeaders = new HashMap<String, List<String>>();
for (Entry<String, List<Object>> entry: response.getHeaders().entrySet()) {
List<Object> values = entry.getValue();
@ -762,7 +762,7 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
*
* @param authNames The authentications to apply
*/
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);

View File

@ -93,33 +93,33 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
public enum CollectionFormat {
CSV(","), TSV("\t"), SSV(" "), PIPES("|"), MULTI(null);
private final String separator;
protected final String separator;
private CollectionFormat(String separator) {
protected CollectionFormat(String separator) {
this.separator = separator;
}
private String collectionToString(Collection<?> collection) {
protected String collectionToString(Collection<?> collection) {
return StringUtils.collectionToDelimitedString(collection, separator);
}
}
private boolean debugging = false;
protected boolean debugging = false;
private HttpHeaders defaultHeaders = new HttpHeaders();
private MultiValueMap<String, String> defaultCookies = new LinkedMultiValueMap<String, String>();
protected HttpHeaders defaultHeaders = new HttpHeaders();
protected MultiValueMap<String, String> defaultCookies = new LinkedMultiValueMap<String, String>();
private int maxAttemptsForRetry = {{maxAttemptsForRetry}};
protected int maxAttemptsForRetry = {{maxAttemptsForRetry}};
private long waitTimeMillis = {{waitTimeMillis}};
protected long waitTimeMillis = {{waitTimeMillis}};
private String basePath = "{{basePath}}";
protected String basePath = "{{basePath}}";
private RestTemplate restTemplate;
protected RestTemplate restTemplate;
private Map<String, Authentication> authentications;
protected Map<String, Authentication> authentications;
private DateFormat dateFormat;
protected DateFormat dateFormat;
public ApiClient() {
this.restTemplate = buildRestTemplate();
@ -852,7 +852,7 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
* @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()) {
@ -906,8 +906,8 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
}
}
private class ApiClientHttpRequestInterceptor implements ClientHttpRequestInterceptor {
private final Log log = LogFactory.getLog(ApiClientHttpRequestInterceptor.class);
protected class ApiClientHttpRequestInterceptor implements ClientHttpRequestInterceptor {
protected final Log log = LogFactory.getLog(ApiClientHttpRequestInterceptor.class);
@Override
public ClientHttpResponse intercept(HttpRequest request, byte[] body, ClientHttpRequestExecution execution) throws IOException {
@ -917,21 +917,21 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
return response;
}
private void logRequest(HttpRequest request, byte[] body) throws UnsupportedEncodingException {
protected void logRequest(HttpRequest request, byte[] body) throws UnsupportedEncodingException {
log.info("URI: " + request.getURI());
log.info("HTTP Method: " + request.getMethod());
log.info("HTTP Headers: " + headersToString(request.getHeaders()));
log.info("Request Body: " + new String(body, StandardCharsets.UTF_8));
}
private void logResponse(ClientHttpResponse response) throws IOException {
protected void logResponse(ClientHttpResponse response) throws IOException {
log.info("HTTP Status Code: " + response.getStatusCode().value());
log.info("Status Text: " + response.getStatusText());
log.info("HTTP Headers: " + headersToString(response.getHeaders()));
log.info("Response Body: " + bodyToString(response.getBody()));
}
private String headersToString(HttpHeaders headers) {
protected String headersToString(HttpHeaders headers) {
if(headers == null || headers.isEmpty()) {
return "";
}
@ -948,7 +948,7 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
return builder.toString();
}
private String bodyToString(InputStream body) throws IOException {
protected String bodyToString(InputStream body) throws IOException {
StringBuilder builder = new StringBuilder();
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(body, StandardCharsets.UTF_8));
String line = bufferedReader.readLine();

View File

@ -55,11 +55,11 @@ import java.util.HashMap;
public class ApiClient {
private Map<String, Interceptor> apiAuthorizations;
private OkHttpClient.Builder okBuilder;
private Retrofit.Builder adapterBuilder;
private JSON json;
private OkHttpClient okHttpClient;
protected Map<String, Interceptor> apiAuthorizations;
protected OkHttpClient.Builder okBuilder;
protected Retrofit.Builder adapterBuilder;
protected JSON json;
protected OkHttpClient okHttpClient;
public ApiClient() {
apiAuthorizations = new LinkedHashMap<String, Interceptor>();
@ -426,8 +426,8 @@ public class ApiClient {
* expected type is String, then just return the body string.
*/
class GsonResponseBodyConverterToString<T> implements Converter<ResponseBody, T> {
private final Gson gson;
private final Type type;
protected final Gson gson;
protected final Type type;
GsonResponseBodyConverterToString(Gson gson, Type type) {
this.gson = gson;
@ -447,14 +447,14 @@ class GsonResponseBodyConverterToString<T> implements Converter<ResponseBody, T>
class GsonCustomConverterFactory extends Converter.Factory
{
private final Gson gson;
private final GsonConverterFactory gsonConverterFactory;
protected final Gson gson;
protected final GsonConverterFactory gsonConverterFactory;
public static GsonCustomConverterFactory create(Gson gson) {
return new GsonCustomConverterFactory(gson);
}
private GsonCustomConverterFactory(Gson gson) {
protected GsonCustomConverterFactory(Gson gson) {
if (gson == null)
throw new NullPointerException("gson == null");
this.gson = gson;

View File

@ -31,13 +31,13 @@ import {{invokerPackage}}.auth.Authentication;
public class ApiClient {
/** Underlying HTTP-client */
private WSClient wsClient;
protected WSClient wsClient;
/** Supported auths */
private Map<String, Authentication> authentications;
protected Map<String, Authentication> authentications;
/** API base path */
private String basePath = "{{{basePath}}}";
protected String basePath = "{{{basePath}}}";
public ApiClient(WSClient wsClient) {
this();

View File

@ -31,13 +31,13 @@ import {{invokerPackage}}.auth.Authentication;
public class ApiClient {
/** Underlying HTTP-client */
private WSClient wsClient;
protected WSClient wsClient;
/** Supported auths */
private Map<String, Authentication> authentications;
protected Map<String, Authentication> authentications;
/** API base path */
private String basePath = "{{{basePath}}}";
protected String basePath = "{{{basePath}}}";
public ApiClient(WSClient wsClient) {
this();

View File

@ -37,22 +37,22 @@ import {{invokerPackage}}.auth.Authentication;
public class ApiClient {
/** Underlying HTTP-client */
private WSClient wsClient;
protected WSClient wsClient;
/** Creates HTTP call instances */
private Play26CallFactory callFactory;
protected Play26CallFactory callFactory;
/** Create {@link java.util.concurrent.CompletionStage} instances from HTTP calls */
private Play26CallAdapterFactory callAdapterFactory;
protected Play26CallAdapterFactory callAdapterFactory;
/** Supported auths */
private Map<String, Authentication> authentications;
protected Map<String, Authentication> authentications;
/** API base path */
private String basePath = "{{{basePath}}}";
protected String basePath = "{{{basePath}}}";
/** Default ObjectMapper */
private ObjectMapper defaultMapper;
protected ObjectMapper defaultMapper;
public ApiClient(WSClient wsClient) {
this();

View File

@ -49,21 +49,21 @@ import static java.util.stream.Collectors.toMap;
{{>generatedAnnotation}}
public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
private static final Pattern CONTENT_DISPOSITION_PATTERN = Pattern.compile("filename=['\"]?([^'\"\\s]+)['\"]?");
private static final OpenOptions FILE_DOWNLOAD_OPTIONS = new OpenOptions().setCreate(true).setTruncateExisting(true);
protected static final Pattern CONTENT_DISPOSITION_PATTERN = Pattern.compile("filename=['\"]?([^'\"\\s]+)['\"]?");
protected static final OpenOptions FILE_DOWNLOAD_OPTIONS = new OpenOptions().setCreate(true).setTruncateExisting(true);
private final Vertx vertx;
private final JsonObject config;
private final String identifier;
protected final Vertx vertx;
protected final JsonObject config;
protected final String identifier;
private MultiMap defaultHeaders = MultiMap.caseInsensitiveMultiMap();
private MultiMap defaultCookies = MultiMap.caseInsensitiveMultiMap();
private Map<String, Authentication> authentications;
private String basePath = "{{{basePath}}}";
private DateFormat dateFormat;
private ObjectMapper objectMapper;
private String downloadsDir = "";
private int timeout = -1;
protected MultiMap defaultHeaders = MultiMap.caseInsensitiveMultiMap();
protected MultiMap defaultCookies = MultiMap.caseInsensitiveMultiMap();
protected Map<String, Authentication> authentications;
protected String basePath = "{{{basePath}}}";
protected DateFormat dateFormat;
protected ObjectMapper objectMapper;
protected String downloadsDir = "";
protected int timeout = -1;
public ApiClient(Vertx vertx, JsonObject config) {
Objects.requireNonNull(vertx, "Vertx must not be null");
@ -385,7 +385,7 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
* @param mime MIME
* @return True if the MIME type is JSON
*/
private boolean isJsonMime(String mime) {
protected boolean isJsonMime(String mime) {
String jsonMime = "(?i)^(application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(;.*)?$";
return mime != null && (mime.matches(jsonMime) || mime.equalsIgnoreCase("application/json-patch+json"));
}
@ -523,7 +523,7 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
}
}
private String buildCookieHeader(MultiMap cookies) {
protected String buildCookieHeader(MultiMap cookies) {
final StringBuilder cookieValue = new StringBuilder();
String delimiter = "";
for (final Map.Entry<String, String> entry : cookies.entries()) {
@ -680,7 +680,7 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
public static class AuthInfo {
private final Map<String, Authentication> authentications = new LinkedHashMap<>();{{#authMethods}}{{#isBasic}}{{#isBasicBasic}}
protected final Map<String, Authentication> authentications = new LinkedHashMap<>();{{#authMethods}}{{#isBasic}}{{#isBasicBasic}}
public void add{{#lambda.pascalcase}}{{name}}{{/lambda.pascalcase}}Authentication(String username, String password) {
HttpBasicAuth auth = new HttpBasicAuth();

View File

@ -89,28 +89,28 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
public enum CollectionFormat {
CSV(","), TSV("\t"), SSV(" "), PIPES("|"), MULTI(null);
private final String separator;
private CollectionFormat(String separator) {
protected final String separator;
protected CollectionFormat(String separator) {
this.separator = separator;
}
private String collectionToString(Collection<?> collection) {
protected String collectionToString(Collection<?> collection) {
return StringUtils.collectionToDelimitedString(collection, separator);
}
}
private static final String URI_TEMPLATE_ATTRIBUTE = WebClient.class.getName() + ".uriTemplate";
protected static final String URI_TEMPLATE_ATTRIBUTE = WebClient.class.getName() + ".uriTemplate";
private HttpHeaders defaultHeaders = new HttpHeaders();
private MultiValueMap<String, String> defaultCookies = new LinkedMultiValueMap<String, String>();
protected HttpHeaders defaultHeaders = new HttpHeaders();
protected MultiValueMap<String, String> defaultCookies = new LinkedMultiValueMap<String, String>();
private String basePath = "{{basePath}}";
protected String basePath = "{{basePath}}";
private final WebClient webClient;
private final DateFormat dateFormat;
private final ObjectMapper objectMapper;
protected final WebClient webClient;
protected final DateFormat dateFormat;
protected final ObjectMapper objectMapper;
private Map<String, Authentication> authentications;
protected Map<String, Authentication> authentications;
public ApiClient() {
@ -135,7 +135,7 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
this(Optional.ofNullable(webClient).orElseGet(() -> buildWebClient(mapper.copy())), format);
}
private ApiClient(WebClient webClient, DateFormat format) {
protected ApiClient(WebClient webClient, DateFormat format) {
this.webClient = webClient;
this.dateFormat = format;
this.objectMapper = createDefaultObjectMapper(format);
@ -634,7 +634,7 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
* @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)) {
@ -660,7 +660,7 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
return queryBuilder.toString();
}
private WebClient.RequestBodySpec prepareRequest(String path, HttpMethod method, Map<String, Object> pathParams,
protected WebClient.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) {

View File

@ -76,9 +76,9 @@ import {{invokerPackage}}.auth.OAuth;
{{>generatedAnnotation}}
public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
private Map<String, String> defaultHeaderMap = new HashMap<String, String>();
private Map<String, String> defaultCookieMap = new HashMap<String, String>();
private String basePath = "{{{basePath}}}";
protected Map<String, String> defaultHeaderMap = new HashMap<String, String>();
protected Map<String, String> defaultCookieMap = new HashMap<String, String>();
protected String basePath = "{{{basePath}}}";
protected List<ServerConfiguration> servers = new ArrayList<ServerConfiguration>({{#servers}}{{#-first}}Arrays.asList(
{{/-first}} new ServerConfiguration(
"{{{url}}}",
@ -106,18 +106,18 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
){{/-last}}{{/servers}});
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 Client httpClient;
private ObjectMapper objectMapper;
protected Client httpClient;
protected ObjectMapper objectMapper;
private Map<String, Authentication> authentications;
protected Map<String, Authentication> authentications;
private int statusCode;
private Map<String, List<String>> responseHeaders;
protected int statusCode;
protected Map<String, List<String>> responseHeaders;
private DateFormat dateFormat;
protected DateFormat dateFormat;
public ApiClient() {
objectMapper = new ObjectMapper();
@ -706,7 +706,7 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
* @param collectionQueryParams The collection query parameters
* @return The full URL
*/
private String buildUrl(String path, List<Pair> queryParams, List<Pair> collectionQueryParams) {
protected String buildUrl(String path, List<Pair> queryParams, List<Pair> collectionQueryParams) {
String baseURL;
if (serverIndex != null) {
if (serverIndex < 0 || serverIndex >= servers.size()) {
@ -759,7 +759,7 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
return url.toString();
}
private ClientResponse getAPIResponse(String path, String method, List<Pair> queryParams, List<Pair> collectionQueryParams, Object body, Map<String, String> headerParams, Map<String, String> cookieParams, Map<String, Object> formParams, String accept, String contentType, String[] authNames) throws ApiException {
protected ClientResponse getAPIResponse(String path, String method, List<Pair> queryParams, List<Pair> collectionQueryParams, Object body, Map<String, String> headerParams, Map<String, String> cookieParams, Map<String, Object> formParams, String accept, String contentType, String[] authNames) throws ApiException {
if (body != null && !formParams.isEmpty()) {
throw new ApiException(500, "Cannot have body and form params");
}
@ -872,7 +872,7 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
* @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);
@ -885,7 +885,7 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
* @param formParams Form parameters
* @return HTTP form encoded parameters
*/
private String getXWWWFormUrlencodedParams(Map<String, Object> formParams) {
protected String getXWWWFormUrlencodedParams(Map<String, Object> formParams) {
StringBuilder formParamBuilder = new StringBuilder();
for (Entry<String, Object> param : formParams.entrySet()) {

View File

@ -85,7 +85,7 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
protected Map<String, String> defaultCookieMap = new HashMap<String, String>();
protected String basePath = "{{{basePath}}}";
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<ServerConfiguration>({{#servers}}{{#-first}}Arrays.asList(
{{/-first}} new ServerConfiguration(
@ -158,7 +158,7 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
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,14 +311,14 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
return this;
}
private void updateBasePath() {
protected void updateBasePath() {
if (serverIndex != null) {
setBasePath(servers.get(serverIndex).URL(serverVariables));
}
}
{{#hasOAuthMethods}}
private void setOauthBasePath(String basePath) {
protected void setOauthBasePath(String basePath) {
for(Authentication auth : authentications.values()) {
if (auth instanceof OAuth) {
((OAuth) auth).setBasePath(basePath);
@ -1200,7 +1200,7 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
}
}
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);