forked from loafle/openapi-generator-original
[java][apache-httpclient] update httpclient dependency to the latest 5.x (#14673)
* #14672 - adding generator with apache http client 5 * #14672 - adding generator with apache http client 5 * #14672 - adding generator with apache http client 5 * #14672 - adding generator with apache http client 5
This commit is contained in:
parent
85a7d69b5f
commit
d7edbad8d6
@ -77,8 +77,8 @@ If you find OpenAPI Generator useful for work, please consider asking your compa
|
|||||||
OpenAPI Generator allows generation of API client libraries (SDK generation), server stubs, documentation and configuration automatically given an [OpenAPI Spec](https://github.com/OAI/OpenAPI-Specification) (both 2.0 and 3.0 are supported). Currently, the following languages/frameworks are supported:
|
OpenAPI Generator allows generation of API client libraries (SDK generation), server stubs, documentation and configuration automatically given an [OpenAPI Spec](https://github.com/OAI/OpenAPI-Specification) (both 2.0 and 3.0 are supported). Currently, the following languages/frameworks are supported:
|
||||||
|
|
||||||
| | Languages/Frameworks |
|
| | Languages/Frameworks |
|
||||||
| -------------------------------- |----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
| -------------------------------- |-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||||
| **API clients** | **ActionScript**, **Ada**, **Apex**, **Bash**, **C**, **C#** (.net 2.0, 3.5 or later, .NET Standard 1.3 - 2.1, .NET Core 3.1, .NET 5.0. Libraries: RestSharp, GenericHost, HttpClient), **C++** (Arduino, cpp-restsdk, Qt5, Tizen, Unreal Engine 4), **Clojure**, **Crystal**, **Dart**, **Elixir**, **Elm**, **Eiffel**, **Erlang**, **Go**, **Groovy**, **Haskell** (http-client, Servant), **Java** (Apache HttpClient, Jersey1.x, Jersey2.x, OkHttp, Retrofit1.x, Retrofit2.x, Feign, RestTemplate, RESTEasy, Vertx, Google API Client Library for Java, Rest-assured, Spring 5 Web Client, MicroProfile Rest Client, Helidon), **Jetbrains HTTP Client**, **Julia**, **k6**, **Kotlin**, **Lua**, **Nim**, **Node.js/JavaScript** (ES5, ES6, AngularJS with Google Closure Compiler annotations, Flow types, Apollo GraphQL DataStore), **Objective-C**, **OCaml**, **Perl**, **PHP**, **PowerShell**, **Python**, **R**, **Ruby**, **Rust** (hyper, reqwest, rust-server), **Scala** (akka, http4s, scalaz, sttp, swagger-async-httpclient), **Swift** (2.x, 3.x, 4.x, 5.x), **Typescript** (AngularJS, Angular (2.x - 13.x), Aurelia, Axios, Fetch, Inversify, jQuery, Nestjs, Node, redux-query, Rxjs) |
|
| **API clients** | **ActionScript**, **Ada**, **Apex**, **Bash**, **C**, **C#** (.net 2.0, 3.5 or later, .NET Standard 1.3 - 2.1, .NET Core 3.1, .NET 5.0. Libraries: RestSharp, GenericHost, HttpClient), **C++** (Arduino, cpp-restsdk, Qt5, Tizen, Unreal Engine 4), **Clojure**, **Crystal**, **Dart**, **Elixir**, **Elm**, **Eiffel**, **Erlang**, **Go**, **Groovy**, **Haskell** (http-client, Servant), **Java** (Apache HttpClient 4.x, Apache HttpClient 5.x, Jersey1.x, Jersey2.x, OkHttp, Retrofit1.x, Retrofit2.x, Feign, RestTemplate, RESTEasy, Vertx, Google API Client Library for Java, Rest-assured, Spring 5 Web Client, MicroProfile Rest Client, Helidon), **Jetbrains HTTP Client**, **Julia**, **k6**, **Kotlin**, **Lua**, **Nim**, **Node.js/JavaScript** (ES5, ES6, AngularJS with Google Closure Compiler annotations, Flow types, Apollo GraphQL DataStore), **Objective-C**, **OCaml**, **Perl**, **PHP**, **PowerShell**, **Python**, **R**, **Ruby**, **Rust** (hyper, reqwest, rust-server), **Scala** (akka, http4s, scalaz, sttp, swagger-async-httpclient), **Swift** (2.x, 3.x, 4.x, 5.x), **Typescript** (AngularJS, Angular (2.x - 13.x), Aurelia, Axios, Fetch, Inversify, jQuery, Nestjs, Node, redux-query, Rxjs) |
|
||||||
| **Server stubs** | **Ada**, **C#** (ASP.NET Core, Azure Functions), **C++** (Pistache, Restbed, Qt5 QHTTPEngine), **Erlang**, **F#** (Giraffe), **Go** (net/http, Gin, Echo), **Haskell** (Servant, Yesod), **Java** (MSF4J, Spring, Undertow, JAX-RS: CDI, CXF, Inflector, Jersey, RestEasy, Play Framework, [PKMST](https://github.com/ProKarma-Inc/pkmst-getting-started-examples), [Vert.x](https://vertx.io/), [Apache Camel](https://camel.apache.org/), [Helidon](https://helidon.io/)), **Julia**, **Kotlin** (Spring Boot, Ktor, Vertx), **PHP** (Laravel, Lumen, [Mezzio (fka Zend Expressive)](https://github.com/mezzio/mezzio), Slim, Silex, [Symfony](https://symfony.com/)), **Python** (FastAPI, Flask), **NodeJS**, **Ruby** (Sinatra, Rails5), **Rust** ([rust-server](https://openapi-generator.tech/docs/generators/rust-server/)), **Scala** (Akka, [Finch](https://github.com/finagle/finch), [Lagom](https://github.com/lagom/lagom), [Play](https://www.playframework.com/), Scalatra) |
|
| **Server stubs** | **Ada**, **C#** (ASP.NET Core, Azure Functions), **C++** (Pistache, Restbed, Qt5 QHTTPEngine), **Erlang**, **F#** (Giraffe), **Go** (net/http, Gin, Echo), **Haskell** (Servant, Yesod), **Java** (MSF4J, Spring, Undertow, JAX-RS: CDI, CXF, Inflector, Jersey, RestEasy, Play Framework, [PKMST](https://github.com/ProKarma-Inc/pkmst-getting-started-examples), [Vert.x](https://vertx.io/), [Apache Camel](https://camel.apache.org/), [Helidon](https://helidon.io/)), **Julia**, **Kotlin** (Spring Boot, Ktor, Vertx), **PHP** (Laravel, Lumen, [Mezzio (fka Zend Expressive)](https://github.com/mezzio/mezzio), Slim, Silex, [Symfony](https://symfony.com/)), **Python** (FastAPI, Flask), **NodeJS**, **Ruby** (Sinatra, Rails5), **Rust** ([rust-server](https://openapi-generator.tech/docs/generators/rust-server/)), **Scala** (Akka, [Finch](https://github.com/finagle/finch), [Lagom](https://github.com/lagom/lagom), [Play](https://www.playframework.com/), Scalatra) |
|
||||||
| **API documentation generators** | **HTML**, **Confluence Wiki**, **Asciidoc**, **Markdown**, **PlantUML** |
|
| **API documentation generators** | **HTML**, **Confluence Wiki**, **Asciidoc**, **Markdown**, **PlantUML** |
|
||||||
| **Configuration files** | [**Apache2**](https://httpd.apache.org/) |
|
| **Configuration files** | [**Apache2**](https://httpd.apache.org/) |
|
||||||
@ -957,7 +957,7 @@ Here is a list of template creators:
|
|||||||
* Java (Google APIs Client Library): @charlescapps
|
* Java (Google APIs Client Library): @charlescapps
|
||||||
* Java (Rest-assured): @viclovsky
|
* Java (Rest-assured): @viclovsky
|
||||||
* Java (Java 11 Native HTTP client): @bbdouglas
|
* Java (Java 11 Native HTTP client): @bbdouglas
|
||||||
* Java (Apache HttpClient): @harrywhite4
|
* Java (Apache HttpClient 5.x): @harrywhite4 @andrevegas
|
||||||
* Java (Helidon): @spericas @tjquinno @tvallin
|
* Java (Helidon): @spericas @tjquinno @tvallin
|
||||||
* Javascript/NodeJS: @jfiala
|
* Javascript/NodeJS: @jfiala
|
||||||
* JavaScript (Apollo DataSource): @erithmetic
|
* JavaScript (Apollo DataSource): @erithmetic
|
||||||
|
@ -57,7 +57,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
|||||||
|implicitHeadersRegex|Skip header parameters that matches given regex in the generated API methods using @ApiImplicitParams annotation. Note: this parameter is ignored when implicitHeaders=true| |null|
|
|implicitHeadersRegex|Skip header parameters that matches given regex in the generated API methods using @ApiImplicitParams annotation. Note: this parameter is ignored when implicitHeaders=true| |null|
|
||||||
|invokerPackage|root package for generated code| |org.openapitools.client|
|
|invokerPackage|root package for generated code| |org.openapitools.client|
|
||||||
|legacyDiscriminatorBehavior|Set to false for generators with better support for discriminators. (Python, Java, Go, PowerShell, C#have this enabled by default).|<dl><dt>**true**</dt><dd>The mapping in the discriminator includes descendent schemas that allOf inherit from self and the discriminator mapping schemas in the OAS document.</dd><dt>**false**</dt><dd>The mapping in the discriminator includes any descendent schemas that allOf inherit from self, any oneOf schemas, any anyOf schemas, any x-discriminator-values, and the discriminator mapping schemas in the OAS document AND Codegen validates that oneOf and anyOf schemas contain the required discriminator and throws an error if the discriminator is missing.</dd></dl>|true|
|
|legacyDiscriminatorBehavior|Set to false for generators with better support for discriminators. (Python, Java, Go, PowerShell, C#have this enabled by default).|<dl><dt>**true**</dt><dd>The mapping in the discriminator includes descendent schemas that allOf inherit from self and the discriminator mapping schemas in the OAS document.</dd><dt>**false**</dt><dd>The mapping in the discriminator includes any descendent schemas that allOf inherit from self, any oneOf schemas, any anyOf schemas, any x-discriminator-values, and the discriminator mapping schemas in the OAS document AND Codegen validates that oneOf and anyOf schemas contain the required discriminator and throws an error if the discriminator is missing.</dd></dl>|true|
|
||||||
|library|library template (sub-template) to use|<dl><dt>**jersey1**</dt><dd>HTTP client: Jersey client 1.19.x. JSON processing: Jackson 2.9.x. Enable gzip request encoding using '-DuseGzipFeature=true'. IMPORTANT NOTE: jersey 1.x is no longer actively maintained so please upgrade to 'jersey3' or other HTTP libraries instead.</dd><dt>**jersey2**</dt><dd>HTTP client: Jersey client 2.25.1. JSON processing: Jackson 2.9.x</dd><dt>**jersey3**</dt><dd>HTTP client: Jersey client 3.x. JSON processing: Jackson 2.x</dd><dt>**feign**</dt><dd>HTTP client: OpenFeign 10.x. JSON processing: Jackson 2.9.x. or Gson 2.x</dd><dt>**okhttp-gson**</dt><dd>[DEFAULT] HTTP client: OkHttp 3.x. JSON processing: Gson 2.8.x. Enable Parcelable models on Android using '-DparcelableModel=true'. Enable gzip request encoding using '-DuseGzipFeature=true'.</dd><dt>**retrofit2**</dt><dd>HTTP client: OkHttp 3.x. JSON processing: Gson 2.x (Retrofit 2.3.0). Enable the RxJava adapter using '-DuseRxJava[2/3]=true'. (RxJava 1.x or 2.x or 3.x)</dd><dt>**resttemplate**</dt><dd>HTTP client: Spring RestTemplate 4.x. JSON processing: Jackson 2.9.x</dd><dt>**webclient**</dt><dd>HTTP client: Spring WebClient 5.x. JSON processing: Jackson 2.9.x</dd><dt>**resteasy**</dt><dd>HTTP client: Resteasy client 3.x. JSON processing: Jackson 2.9.x</dd><dt>**vertx**</dt><dd>HTTP client: VertX client 3.x. JSON processing: Jackson 2.9.x</dd><dt>**google-api-client**</dt><dd>HTTP client: Google API client 1.x. JSON processing: Jackson 2.9.x</dd><dt>**rest-assured**</dt><dd>HTTP client: rest-assured : 4.x. JSON processing: Gson 2.x or Jackson 2.10.x. Only for Java 8</dd><dt>**native**</dt><dd>HTTP client: Java native HttpClient. JSON processing: Jackson 2.9.x. Only for Java11+</dd><dt>**microprofile**</dt><dd>HTTP client: Microprofile client 1.x. JSON processing: JSON-B or Jackson 2.9.x</dd><dt>**apache-httpclient**</dt><dd>HTTP client: Apache httpclient 4.x</dd></dl>|okhttp-gson|
|
|library|library template (sub-template) to use|<dl><dt>**jersey1**</dt><dd>HTTP client: Jersey client 1.19.x. JSON processing: Jackson 2.9.x. Enable gzip request encoding using '-DuseGzipFeature=true'. IMPORTANT NOTE: jersey 1.x is no longer actively maintained so please upgrade to 'jersey3' or other HTTP libraries instead.</dd><dt>**jersey2**</dt><dd>HTTP client: Jersey client 2.25.1. JSON processing: Jackson 2.9.x</dd><dt>**jersey3**</dt><dd>HTTP client: Jersey client 3.x. JSON processing: Jackson 2.x</dd><dt>**feign**</dt><dd>HTTP client: OpenFeign 10.x. JSON processing: Jackson 2.9.x. or Gson 2.x</dd><dt>**okhttp-gson**</dt><dd>[DEFAULT] HTTP client: OkHttp 3.x. JSON processing: Gson 2.8.x. Enable Parcelable models on Android using '-DparcelableModel=true'. Enable gzip request encoding using '-DuseGzipFeature=true'.</dd><dt>**retrofit2**</dt><dd>HTTP client: OkHttp 3.x. JSON processing: Gson 2.x (Retrofit 2.3.0). Enable the RxJava adapter using '-DuseRxJava[2/3]=true'. (RxJava 1.x or 2.x or 3.x)</dd><dt>**resttemplate**</dt><dd>HTTP client: Spring RestTemplate 4.x. JSON processing: Jackson 2.9.x</dd><dt>**webclient**</dt><dd>HTTP client: Spring WebClient 5.x. JSON processing: Jackson 2.9.x</dd><dt>**resteasy**</dt><dd>HTTP client: Resteasy client 3.x. JSON processing: Jackson 2.9.x</dd><dt>**vertx**</dt><dd>HTTP client: VertX client 3.x. JSON processing: Jackson 2.9.x</dd><dt>**google-api-client**</dt><dd>HTTP client: Google API client 1.x. JSON processing: Jackson 2.9.x</dd><dt>**rest-assured**</dt><dd>HTTP client: rest-assured : 4.x. JSON processing: Gson 2.x or Jackson 2.10.x. Only for Java 8</dd><dt>**native**</dt><dd>HTTP client: Java native HttpClient. JSON processing: Jackson 2.9.x. Only for Java11+</dd><dt>**microprofile**</dt><dd>HTTP client: Microprofile client 1.x. JSON processing: JSON-B or Jackson 2.9.x</dd><dt>**apache-httpclient**</dt><dd>HTTP client: Apache httpclient 5.x</dd></dl>|okhttp-gson|
|
||||||
|licenseName|The name of the license| |Unlicense|
|
|licenseName|The name of the license| |Unlicense|
|
||||||
|licenseUrl|The URL of the license| |http://unlicense.org|
|
|licenseUrl|The URL of the license| |http://unlicense.org|
|
||||||
|microprofileFramework|Framework for microprofile. Possible values "kumuluzee"| |null|
|
|microprofileFramework|Framework for microprofile. Possible values "kumuluzee"| |null|
|
||||||
|
@ -228,7 +228,7 @@ public class JavaClientCodegen extends AbstractJavaCodegen
|
|||||||
supportedLibraries.put(REST_ASSURED, "HTTP client: rest-assured : 4.x. JSON processing: Gson 2.x or Jackson 2.10.x. Only for Java 8");
|
supportedLibraries.put(REST_ASSURED, "HTTP client: rest-assured : 4.x. JSON processing: Gson 2.x or Jackson 2.10.x. Only for Java 8");
|
||||||
supportedLibraries.put(NATIVE, "HTTP client: Java native HttpClient. JSON processing: Jackson 2.9.x. Only for Java11+");
|
supportedLibraries.put(NATIVE, "HTTP client: Java native HttpClient. JSON processing: Jackson 2.9.x. Only for Java11+");
|
||||||
supportedLibraries.put(MICROPROFILE, "HTTP client: Microprofile client 1.x. JSON processing: JSON-B or Jackson 2.9.x");
|
supportedLibraries.put(MICROPROFILE, "HTTP client: Microprofile client 1.x. JSON processing: JSON-B or Jackson 2.9.x");
|
||||||
supportedLibraries.put(APACHE, "HTTP client: Apache httpclient 4.x");
|
supportedLibraries.put(APACHE, "HTTP client: Apache httpclient 5.x");
|
||||||
|
|
||||||
CliOption libraryOption = new CliOption(CodegenConstants.LIBRARY, "library template (sub-template) to use");
|
CliOption libraryOption = new CliOption(CodegenConstants.LIBRARY, "library template (sub-template) to use");
|
||||||
libraryOption.setEnum(supportedLibraries);
|
libraryOption.setEnum(supportedLibraries);
|
||||||
|
@ -13,29 +13,28 @@ import com.fasterxml.jackson.core.type.TypeReference;
|
|||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
import com.fasterxml.jackson.databind.JavaType;
|
import com.fasterxml.jackson.databind.JavaType;
|
||||||
|
|
||||||
import org.apache.http.Header;
|
import org.apache.hc.client5.http.cookie.BasicCookieStore;
|
||||||
import org.apache.http.HttpEntity;
|
import org.apache.hc.client5.http.cookie.Cookie;
|
||||||
import org.apache.http.HttpResponse;
|
import org.apache.hc.client5.http.entity.UrlEncodedFormEntity;
|
||||||
import org.apache.http.HttpStatus;
|
import org.apache.hc.client5.http.entity.mime.MultipartEntityBuilder;
|
||||||
import org.apache.http.NameValuePair;
|
import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
|
||||||
import org.apache.http.ParseException;
|
import org.apache.hc.client5.http.impl.classic.CloseableHttpResponse;
|
||||||
import org.apache.http.client.config.RequestConfig;
|
import org.apache.hc.client5.http.impl.classic.HttpClients;
|
||||||
import org.apache.http.client.entity.UrlEncodedFormEntity;
|
import org.apache.hc.client5.http.impl.cookie.BasicClientCookie;
|
||||||
import org.apache.http.client.methods.CloseableHttpResponse;
|
import org.apache.hc.client5.http.protocol.HttpClientContext;
|
||||||
import org.apache.http.client.methods.RequestBuilder;
|
import org.apache.hc.core5.http.ContentType;
|
||||||
import org.apache.http.client.protocol.HttpClientContext;
|
import org.apache.hc.core5.http.Header;
|
||||||
import org.apache.http.entity.ByteArrayEntity;
|
import org.apache.hc.core5.http.HttpEntity;
|
||||||
import org.apache.http.entity.ContentType;
|
import org.apache.hc.core5.http.HttpResponse;
|
||||||
import org.apache.http.entity.FileEntity;
|
import org.apache.hc.core5.http.HttpStatus;
|
||||||
import org.apache.http.entity.StringEntity;
|
import org.apache.hc.core5.http.NameValuePair;
|
||||||
import org.apache.http.entity.mime.MultipartEntityBuilder;
|
import org.apache.hc.core5.http.ParseException;
|
||||||
import org.apache.http.impl.client.BasicCookieStore;
|
import org.apache.hc.core5.http.io.entity.ByteArrayEntity;
|
||||||
import org.apache.http.impl.client.CloseableHttpClient;
|
import org.apache.hc.core5.http.io.entity.EntityUtils;
|
||||||
import org.apache.http.impl.client.HttpClients;
|
import org.apache.hc.core5.http.io.entity.FileEntity;
|
||||||
import org.apache.http.impl.cookie.BasicClientCookie;
|
import org.apache.hc.core5.http.io.entity.StringEntity;
|
||||||
import org.apache.http.message.BasicNameValuePair;
|
import org.apache.hc.core5.http.io.support.ClassicRequestBuilder;
|
||||||
import org.apache.http.util.EntityUtils;
|
import org.apache.hc.core5.http.message.BasicNameValuePair;
|
||||||
import org.apache.http.cookie.Cookie;
|
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
@ -58,6 +57,7 @@ import java.io.InputStream;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.UnsupportedEncodingException;
|
import java.io.UnsupportedEncodingException;
|
||||||
import java.nio.charset.Charset;
|
import java.nio.charset.Charset;
|
||||||
|
import java.nio.charset.UnsupportedCharsetException;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.StandardCopyOption;
|
import java.nio.file.StandardCopyOption;
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
@ -735,7 +735,7 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
|
|||||||
private ContentType getContentType(String headerValue) throws ApiException {
|
private ContentType getContentType(String headerValue) throws ApiException {
|
||||||
try {
|
try {
|
||||||
return ContentType.parse(headerValue);
|
return ContentType.parse(headerValue);
|
||||||
} catch (ParseException e) {
|
} catch (UnsupportedCharsetException e) {
|
||||||
throw new ApiException("Could not parse content type " + headerValue);
|
throw new ApiException("Could not parse content type " + headerValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -816,7 +816,7 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
|
|||||||
* @throws IOException IO exception
|
* @throws IOException IO exception
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public <T> T deserialize(HttpResponse response, TypeReference<T> valueType) throws ApiException, IOException {
|
public <T> T deserialize(CloseableHttpResponse response, TypeReference<T> valueType) throws ApiException, IOException, ParseException {
|
||||||
if (valueType == null) {
|
if (valueType == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -846,14 +846,14 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
|
|||||||
} else {
|
} else {
|
||||||
throw new ApiException(
|
throw new ApiException(
|
||||||
"Deserialization for content type '" + mimeType + "' not supported for type '" + valueType + "'",
|
"Deserialization for content type '" + mimeType + "' not supported for type '" + valueType + "'",
|
||||||
response.getStatusLine().getStatusCode(),
|
response.getCode(),
|
||||||
responseHeaders,
|
responseHeaders,
|
||||||
EntityUtils.toString(entity)
|
EntityUtils.toString(entity)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private File downloadFileFromResponse(HttpResponse response) throws IOException {
|
private File downloadFileFromResponse(CloseableHttpResponse response) throws IOException {
|
||||||
Header contentDispositionHeader = response.getFirstHeader("Content-Disposition");
|
Header contentDispositionHeader = response.getFirstHeader("Content-Disposition");
|
||||||
String contentDisposition = contentDispositionHeader == null ? null : contentDispositionHeader.getValue();
|
String contentDisposition = contentDispositionHeader == null ? null : contentDispositionHeader.getValue();
|
||||||
File file = prepareDownloadFile(contentDisposition);
|
File file = prepareDownloadFile(contentDisposition);
|
||||||
@ -978,13 +978,13 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
|
|||||||
return cookie;
|
return cookie;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected <T> T processResponse(CloseableHttpResponse response, TypeReference<T> returnType) throws ApiException, IOException {
|
protected <T> T processResponse(CloseableHttpResponse response, TypeReference<T> returnType) throws ApiException, IOException, ParseException {
|
||||||
statusCode = response.getStatusLine().getStatusCode();
|
statusCode = response.getCode();
|
||||||
if (statusCode == HttpStatus.SC_NO_CONTENT) {
|
if (statusCode == HttpStatus.SC_NO_CONTENT) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
responseHeaders = transformResponseHeaders(response.getAllHeaders());
|
responseHeaders = transformResponseHeaders(response.getHeaders());
|
||||||
if (isSuccessfulStatus(statusCode)) {
|
if (isSuccessfulStatus(statusCode)) {
|
||||||
return this.deserialize(response, returnType);
|
return this.deserialize(response, returnType);
|
||||||
} else {
|
} else {
|
||||||
@ -1034,14 +1034,9 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
|
|||||||
updateParamsForAuth(authNames, queryParams, headerParams, cookieParams);
|
updateParamsForAuth(authNames, queryParams, headerParams, cookieParams);
|
||||||
final String url = buildUrl(path, queryParams, collectionQueryParams, urlQueryDeepObject);
|
final String url = buildUrl(path, queryParams, collectionQueryParams, urlQueryDeepObject);
|
||||||
|
|
||||||
RequestBuilder builder = RequestBuilder.create(method);
|
ClassicRequestBuilder builder = ClassicRequestBuilder.create(method);
|
||||||
builder.setUri(url);
|
builder.setUri(url);
|
||||||
|
|
||||||
RequestConfig config = RequestConfig.custom()
|
|
||||||
.setConnectionRequestTimeout(connectionTimeout)
|
|
||||||
.build();
|
|
||||||
builder.setConfig(config);
|
|
||||||
|
|
||||||
if (accept != null) {
|
if (accept != null) {
|
||||||
builder.addHeader("Accept", accept);
|
builder.addHeader("Accept", accept);
|
||||||
}
|
}
|
||||||
@ -1082,7 +1077,7 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
|
|||||||
|
|
||||||
try (CloseableHttpResponse response = httpClient.execute(builder.build(), context)) {
|
try (CloseableHttpResponse response = httpClient.execute(builder.build(), context)) {
|
||||||
return processResponse(response, returnType);
|
return processResponse(response, returnType);
|
||||||
} catch (IOException e) {
|
} catch (IOException | ParseException e) {
|
||||||
throw new ApiException(e);
|
throw new ApiException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -120,7 +120,7 @@ ext {
|
|||||||
jackson_databind_nullable_version = "0.2.4"
|
jackson_databind_nullable_version = "0.2.4"
|
||||||
{{/openApiNullable}}
|
{{/openApiNullable}}
|
||||||
jakarta_annotation_version = "1.3.5"
|
jakarta_annotation_version = "1.3.5"
|
||||||
httpclient_version = "4.5.13"
|
httpclient_version = "5.1.3"
|
||||||
jodatime_version = "2.9.9"
|
jodatime_version = "2.9.9"
|
||||||
junit_version = "4.13.2"
|
junit_version = "4.13.2"
|
||||||
}
|
}
|
||||||
@ -128,8 +128,7 @@ ext {
|
|||||||
dependencies {
|
dependencies {
|
||||||
implementation "io.swagger:swagger-annotations:$swagger_annotations_version"
|
implementation "io.swagger:swagger-annotations:$swagger_annotations_version"
|
||||||
implementation "com.google.code.findbugs:jsr305:3.0.2"
|
implementation "com.google.code.findbugs:jsr305:3.0.2"
|
||||||
implementation "org.apache.httpcomponents:httpclient:$httpclient_version"
|
implementation "org.apache.httpcomponents.client5:httpclient5:$httpclient_version"
|
||||||
implementation "org.apache.httpcomponents:httpmime:$httpclient_version"
|
|
||||||
implementation "com.fasterxml.jackson.core:jackson-core:$jackson_version"
|
implementation "com.fasterxml.jackson.core:jackson-core:$jackson_version"
|
||||||
implementation "com.fasterxml.jackson.core:jackson-annotations:$jackson_version"
|
implementation "com.fasterxml.jackson.core:jackson-annotations:$jackson_version"
|
||||||
implementation "com.fasterxml.jackson.core:jackson-databind:$jackson_databind_version"
|
implementation "com.fasterxml.jackson.core:jackson-databind:$jackson_databind_version"
|
||||||
|
@ -232,13 +232,8 @@
|
|||||||
|
|
||||||
<!-- HTTP client: apache client -->
|
<!-- HTTP client: apache client -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.httpcomponents</groupId>
|
<groupId>org.apache.httpcomponents.client5</groupId>
|
||||||
<artifactId>httpclient</artifactId>
|
<artifactId>httpclient5</artifactId>
|
||||||
<version>${httpclient-version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.apache.httpcomponents</groupId>
|
|
||||||
<artifactId>httpmime</artifactId>
|
|
||||||
<version>${httpclient-version}</version>
|
<version>${httpclient-version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
@ -337,7 +332,7 @@
|
|||||||
{{#swagger1AnnotationLibrary}}
|
{{#swagger1AnnotationLibrary}}
|
||||||
<swagger-annotations-version>1.6.6</swagger-annotations-version>
|
<swagger-annotations-version>1.6.6</swagger-annotations-version>
|
||||||
{{/swagger1AnnotationLibrary}}
|
{{/swagger1AnnotationLibrary}}
|
||||||
<httpclient-version>4.5.13</httpclient-version>
|
<httpclient-version>5.1.3</httpclient-version>
|
||||||
<jackson-version>2.14.1</jackson-version>
|
<jackson-version>2.14.1</jackson-version>
|
||||||
<jackson-databind-version>2.14.1</jackson-databind-version>
|
<jackson-databind-version>2.14.1</jackson-databind-version>
|
||||||
{{#openApiNullable}}
|
{{#openApiNullable}}
|
||||||
|
@ -118,7 +118,7 @@ ext {
|
|||||||
jackson_databind_version = "2.14.1"
|
jackson_databind_version = "2.14.1"
|
||||||
jackson_databind_nullable_version = "0.2.4"
|
jackson_databind_nullable_version = "0.2.4"
|
||||||
jakarta_annotation_version = "1.3.5"
|
jakarta_annotation_version = "1.3.5"
|
||||||
httpclient_version = "4.5.13"
|
httpclient_version = "5.1.3"
|
||||||
jodatime_version = "2.9.9"
|
jodatime_version = "2.9.9"
|
||||||
junit_version = "4.13.2"
|
junit_version = "4.13.2"
|
||||||
}
|
}
|
||||||
@ -126,8 +126,7 @@ ext {
|
|||||||
dependencies {
|
dependencies {
|
||||||
implementation "io.swagger:swagger-annotations:$swagger_annotations_version"
|
implementation "io.swagger:swagger-annotations:$swagger_annotations_version"
|
||||||
implementation "com.google.code.findbugs:jsr305:3.0.2"
|
implementation "com.google.code.findbugs:jsr305:3.0.2"
|
||||||
implementation "org.apache.httpcomponents:httpclient:$httpclient_version"
|
implementation "org.apache.httpcomponents.client5:httpclient5:$httpclient_version"
|
||||||
implementation "org.apache.httpcomponents:httpmime:$httpclient_version"
|
|
||||||
implementation "com.fasterxml.jackson.core:jackson-core:$jackson_version"
|
implementation "com.fasterxml.jackson.core:jackson-core:$jackson_version"
|
||||||
implementation "com.fasterxml.jackson.core:jackson-annotations:$jackson_version"
|
implementation "com.fasterxml.jackson.core:jackson-annotations:$jackson_version"
|
||||||
implementation "com.fasterxml.jackson.core:jackson-databind:$jackson_databind_version"
|
implementation "com.fasterxml.jackson.core:jackson-databind:$jackson_databind_version"
|
||||||
|
@ -218,13 +218,8 @@
|
|||||||
|
|
||||||
<!-- HTTP client: apache client -->
|
<!-- HTTP client: apache client -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.httpcomponents</groupId>
|
<groupId>org.apache.httpcomponents.client5</groupId>
|
||||||
<artifactId>httpclient</artifactId>
|
<artifactId>httpclient5</artifactId>
|
||||||
<version>${httpclient-version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.apache.httpcomponents</groupId>
|
|
||||||
<artifactId>httpmime</artifactId>
|
|
||||||
<version>${httpclient-version}</version>
|
<version>${httpclient-version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
@ -275,7 +270,7 @@
|
|||||||
</dependencies>
|
</dependencies>
|
||||||
<properties>
|
<properties>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<httpclient-version>4.5.13</httpclient-version>
|
<httpclient-version>5.1.3</httpclient-version>
|
||||||
<jackson-version>2.14.1</jackson-version>
|
<jackson-version>2.14.1</jackson-version>
|
||||||
<jackson-databind-version>2.14.1</jackson-databind-version>
|
<jackson-databind-version>2.14.1</jackson-databind-version>
|
||||||
<jackson-databind-nullable-version>0.2.4</jackson-databind-nullable-version>
|
<jackson-databind-nullable-version>0.2.4</jackson-databind-nullable-version>
|
||||||
|
@ -21,29 +21,28 @@ import com.fasterxml.jackson.core.type.TypeReference;
|
|||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
import com.fasterxml.jackson.databind.JavaType;
|
import com.fasterxml.jackson.databind.JavaType;
|
||||||
|
|
||||||
import org.apache.http.Header;
|
import org.apache.hc.client5.http.cookie.BasicCookieStore;
|
||||||
import org.apache.http.HttpEntity;
|
import org.apache.hc.client5.http.cookie.Cookie;
|
||||||
import org.apache.http.HttpResponse;
|
import org.apache.hc.client5.http.entity.UrlEncodedFormEntity;
|
||||||
import org.apache.http.HttpStatus;
|
import org.apache.hc.client5.http.entity.mime.MultipartEntityBuilder;
|
||||||
import org.apache.http.NameValuePair;
|
import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
|
||||||
import org.apache.http.ParseException;
|
import org.apache.hc.client5.http.impl.classic.CloseableHttpResponse;
|
||||||
import org.apache.http.client.config.RequestConfig;
|
import org.apache.hc.client5.http.impl.classic.HttpClients;
|
||||||
import org.apache.http.client.entity.UrlEncodedFormEntity;
|
import org.apache.hc.client5.http.impl.cookie.BasicClientCookie;
|
||||||
import org.apache.http.client.methods.CloseableHttpResponse;
|
import org.apache.hc.client5.http.protocol.HttpClientContext;
|
||||||
import org.apache.http.client.methods.RequestBuilder;
|
import org.apache.hc.core5.http.ContentType;
|
||||||
import org.apache.http.client.protocol.HttpClientContext;
|
import org.apache.hc.core5.http.Header;
|
||||||
import org.apache.http.entity.ByteArrayEntity;
|
import org.apache.hc.core5.http.HttpEntity;
|
||||||
import org.apache.http.entity.ContentType;
|
import org.apache.hc.core5.http.HttpResponse;
|
||||||
import org.apache.http.entity.FileEntity;
|
import org.apache.hc.core5.http.HttpStatus;
|
||||||
import org.apache.http.entity.StringEntity;
|
import org.apache.hc.core5.http.NameValuePair;
|
||||||
import org.apache.http.entity.mime.MultipartEntityBuilder;
|
import org.apache.hc.core5.http.ParseException;
|
||||||
import org.apache.http.impl.client.BasicCookieStore;
|
import org.apache.hc.core5.http.io.entity.ByteArrayEntity;
|
||||||
import org.apache.http.impl.client.CloseableHttpClient;
|
import org.apache.hc.core5.http.io.entity.EntityUtils;
|
||||||
import org.apache.http.impl.client.HttpClients;
|
import org.apache.hc.core5.http.io.entity.FileEntity;
|
||||||
import org.apache.http.impl.cookie.BasicClientCookie;
|
import org.apache.hc.core5.http.io.entity.StringEntity;
|
||||||
import org.apache.http.message.BasicNameValuePair;
|
import org.apache.hc.core5.http.io.support.ClassicRequestBuilder;
|
||||||
import org.apache.http.util.EntityUtils;
|
import org.apache.hc.core5.http.message.BasicNameValuePair;
|
||||||
import org.apache.http.cookie.Cookie;
|
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
@ -66,6 +65,7 @@ import java.io.InputStream;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.UnsupportedEncodingException;
|
import java.io.UnsupportedEncodingException;
|
||||||
import java.nio.charset.Charset;
|
import java.nio.charset.Charset;
|
||||||
|
import java.nio.charset.UnsupportedCharsetException;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.StandardCopyOption;
|
import java.nio.file.StandardCopyOption;
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
@ -608,7 +608,7 @@ public class ApiClient extends JavaTimeFormatter {
|
|||||||
private ContentType getContentType(String headerValue) throws ApiException {
|
private ContentType getContentType(String headerValue) throws ApiException {
|
||||||
try {
|
try {
|
||||||
return ContentType.parse(headerValue);
|
return ContentType.parse(headerValue);
|
||||||
} catch (ParseException e) {
|
} catch (UnsupportedCharsetException e) {
|
||||||
throw new ApiException("Could not parse content type " + headerValue);
|
throw new ApiException("Could not parse content type " + headerValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -689,7 +689,7 @@ public class ApiClient extends JavaTimeFormatter {
|
|||||||
* @throws IOException IO exception
|
* @throws IOException IO exception
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public <T> T deserialize(HttpResponse response, TypeReference<T> valueType) throws ApiException, IOException {
|
public <T> T deserialize(CloseableHttpResponse response, TypeReference<T> valueType) throws ApiException, IOException, ParseException {
|
||||||
if (valueType == null) {
|
if (valueType == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -719,14 +719,14 @@ public class ApiClient extends JavaTimeFormatter {
|
|||||||
} else {
|
} else {
|
||||||
throw new ApiException(
|
throw new ApiException(
|
||||||
"Deserialization for content type '" + mimeType + "' not supported for type '" + valueType + "'",
|
"Deserialization for content type '" + mimeType + "' not supported for type '" + valueType + "'",
|
||||||
response.getStatusLine().getStatusCode(),
|
response.getCode(),
|
||||||
responseHeaders,
|
responseHeaders,
|
||||||
EntityUtils.toString(entity)
|
EntityUtils.toString(entity)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private File downloadFileFromResponse(HttpResponse response) throws IOException {
|
private File downloadFileFromResponse(CloseableHttpResponse response) throws IOException {
|
||||||
Header contentDispositionHeader = response.getFirstHeader("Content-Disposition");
|
Header contentDispositionHeader = response.getFirstHeader("Content-Disposition");
|
||||||
String contentDisposition = contentDispositionHeader == null ? null : contentDispositionHeader.getValue();
|
String contentDisposition = contentDispositionHeader == null ? null : contentDispositionHeader.getValue();
|
||||||
File file = prepareDownloadFile(contentDisposition);
|
File file = prepareDownloadFile(contentDisposition);
|
||||||
@ -851,13 +851,13 @@ public class ApiClient extends JavaTimeFormatter {
|
|||||||
return cookie;
|
return cookie;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected <T> T processResponse(CloseableHttpResponse response, TypeReference<T> returnType) throws ApiException, IOException {
|
protected <T> T processResponse(CloseableHttpResponse response, TypeReference<T> returnType) throws ApiException, IOException, ParseException {
|
||||||
statusCode = response.getStatusLine().getStatusCode();
|
statusCode = response.getCode();
|
||||||
if (statusCode == HttpStatus.SC_NO_CONTENT) {
|
if (statusCode == HttpStatus.SC_NO_CONTENT) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
responseHeaders = transformResponseHeaders(response.getAllHeaders());
|
responseHeaders = transformResponseHeaders(response.getHeaders());
|
||||||
if (isSuccessfulStatus(statusCode)) {
|
if (isSuccessfulStatus(statusCode)) {
|
||||||
return this.deserialize(response, returnType);
|
return this.deserialize(response, returnType);
|
||||||
} else {
|
} else {
|
||||||
@ -907,14 +907,9 @@ public class ApiClient extends JavaTimeFormatter {
|
|||||||
updateParamsForAuth(authNames, queryParams, headerParams, cookieParams);
|
updateParamsForAuth(authNames, queryParams, headerParams, cookieParams);
|
||||||
final String url = buildUrl(path, queryParams, collectionQueryParams, urlQueryDeepObject);
|
final String url = buildUrl(path, queryParams, collectionQueryParams, urlQueryDeepObject);
|
||||||
|
|
||||||
RequestBuilder builder = RequestBuilder.create(method);
|
ClassicRequestBuilder builder = ClassicRequestBuilder.create(method);
|
||||||
builder.setUri(url);
|
builder.setUri(url);
|
||||||
|
|
||||||
RequestConfig config = RequestConfig.custom()
|
|
||||||
.setConnectionRequestTimeout(connectionTimeout)
|
|
||||||
.build();
|
|
||||||
builder.setConfig(config);
|
|
||||||
|
|
||||||
if (accept != null) {
|
if (accept != null) {
|
||||||
builder.addHeader("Accept", accept);
|
builder.addHeader("Accept", accept);
|
||||||
}
|
}
|
||||||
@ -955,7 +950,7 @@ public class ApiClient extends JavaTimeFormatter {
|
|||||||
|
|
||||||
try (CloseableHttpResponse response = httpClient.execute(builder.build(), context)) {
|
try (CloseableHttpResponse response = httpClient.execute(builder.build(), context)) {
|
||||||
return processResponse(response, returnType);
|
return processResponse(response, returnType);
|
||||||
} catch (IOException e) {
|
} catch (IOException | ParseException e) {
|
||||||
throw new ApiException(e);
|
throw new ApiException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -118,7 +118,7 @@ ext {
|
|||||||
jackson_databind_version = "2.14.1"
|
jackson_databind_version = "2.14.1"
|
||||||
jackson_databind_nullable_version = "0.2.4"
|
jackson_databind_nullable_version = "0.2.4"
|
||||||
jakarta_annotation_version = "1.3.5"
|
jakarta_annotation_version = "1.3.5"
|
||||||
httpclient_version = "4.5.13"
|
httpclient_version = "5.1.3"
|
||||||
jodatime_version = "2.9.9"
|
jodatime_version = "2.9.9"
|
||||||
junit_version = "4.13.2"
|
junit_version = "4.13.2"
|
||||||
}
|
}
|
||||||
@ -126,8 +126,7 @@ ext {
|
|||||||
dependencies {
|
dependencies {
|
||||||
implementation "io.swagger:swagger-annotations:$swagger_annotations_version"
|
implementation "io.swagger:swagger-annotations:$swagger_annotations_version"
|
||||||
implementation "com.google.code.findbugs:jsr305:3.0.2"
|
implementation "com.google.code.findbugs:jsr305:3.0.2"
|
||||||
implementation "org.apache.httpcomponents:httpclient:$httpclient_version"
|
implementation "org.apache.httpcomponents.client5:httpclient5:$httpclient_version"
|
||||||
implementation "org.apache.httpcomponents:httpmime:$httpclient_version"
|
|
||||||
implementation "com.fasterxml.jackson.core:jackson-core:$jackson_version"
|
implementation "com.fasterxml.jackson.core:jackson-core:$jackson_version"
|
||||||
implementation "com.fasterxml.jackson.core:jackson-annotations:$jackson_version"
|
implementation "com.fasterxml.jackson.core:jackson-annotations:$jackson_version"
|
||||||
implementation "com.fasterxml.jackson.core:jackson-databind:$jackson_databind_version"
|
implementation "com.fasterxml.jackson.core:jackson-databind:$jackson_databind_version"
|
||||||
|
@ -218,13 +218,8 @@
|
|||||||
|
|
||||||
<!-- HTTP client: apache client -->
|
<!-- HTTP client: apache client -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.httpcomponents</groupId>
|
<groupId>org.apache.httpcomponents.client5</groupId>
|
||||||
<artifactId>httpclient</artifactId>
|
<artifactId>httpclient5</artifactId>
|
||||||
<version>${httpclient-version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.apache.httpcomponents</groupId>
|
|
||||||
<artifactId>httpmime</artifactId>
|
|
||||||
<version>${httpclient-version}</version>
|
<version>${httpclient-version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
@ -275,7 +270,7 @@
|
|||||||
</dependencies>
|
</dependencies>
|
||||||
<properties>
|
<properties>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<httpclient-version>4.5.13</httpclient-version>
|
<httpclient-version>5.1.3</httpclient-version>
|
||||||
<jackson-version>2.14.1</jackson-version>
|
<jackson-version>2.14.1</jackson-version>
|
||||||
<jackson-databind-version>2.14.1</jackson-databind-version>
|
<jackson-databind-version>2.14.1</jackson-databind-version>
|
||||||
<jackson-databind-nullable-version>0.2.4</jackson-databind-nullable-version>
|
<jackson-databind-nullable-version>0.2.4</jackson-databind-nullable-version>
|
||||||
|
@ -21,29 +21,28 @@ import com.fasterxml.jackson.core.type.TypeReference;
|
|||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
import com.fasterxml.jackson.databind.JavaType;
|
import com.fasterxml.jackson.databind.JavaType;
|
||||||
|
|
||||||
import org.apache.http.Header;
|
import org.apache.hc.client5.http.cookie.BasicCookieStore;
|
||||||
import org.apache.http.HttpEntity;
|
import org.apache.hc.client5.http.cookie.Cookie;
|
||||||
import org.apache.http.HttpResponse;
|
import org.apache.hc.client5.http.entity.UrlEncodedFormEntity;
|
||||||
import org.apache.http.HttpStatus;
|
import org.apache.hc.client5.http.entity.mime.MultipartEntityBuilder;
|
||||||
import org.apache.http.NameValuePair;
|
import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
|
||||||
import org.apache.http.ParseException;
|
import org.apache.hc.client5.http.impl.classic.CloseableHttpResponse;
|
||||||
import org.apache.http.client.config.RequestConfig;
|
import org.apache.hc.client5.http.impl.classic.HttpClients;
|
||||||
import org.apache.http.client.entity.UrlEncodedFormEntity;
|
import org.apache.hc.client5.http.impl.cookie.BasicClientCookie;
|
||||||
import org.apache.http.client.methods.CloseableHttpResponse;
|
import org.apache.hc.client5.http.protocol.HttpClientContext;
|
||||||
import org.apache.http.client.methods.RequestBuilder;
|
import org.apache.hc.core5.http.ContentType;
|
||||||
import org.apache.http.client.protocol.HttpClientContext;
|
import org.apache.hc.core5.http.Header;
|
||||||
import org.apache.http.entity.ByteArrayEntity;
|
import org.apache.hc.core5.http.HttpEntity;
|
||||||
import org.apache.http.entity.ContentType;
|
import org.apache.hc.core5.http.HttpResponse;
|
||||||
import org.apache.http.entity.FileEntity;
|
import org.apache.hc.core5.http.HttpStatus;
|
||||||
import org.apache.http.entity.StringEntity;
|
import org.apache.hc.core5.http.NameValuePair;
|
||||||
import org.apache.http.entity.mime.MultipartEntityBuilder;
|
import org.apache.hc.core5.http.ParseException;
|
||||||
import org.apache.http.impl.client.BasicCookieStore;
|
import org.apache.hc.core5.http.io.entity.ByteArrayEntity;
|
||||||
import org.apache.http.impl.client.CloseableHttpClient;
|
import org.apache.hc.core5.http.io.entity.EntityUtils;
|
||||||
import org.apache.http.impl.client.HttpClients;
|
import org.apache.hc.core5.http.io.entity.FileEntity;
|
||||||
import org.apache.http.impl.cookie.BasicClientCookie;
|
import org.apache.hc.core5.http.io.entity.StringEntity;
|
||||||
import org.apache.http.message.BasicNameValuePair;
|
import org.apache.hc.core5.http.io.support.ClassicRequestBuilder;
|
||||||
import org.apache.http.util.EntityUtils;
|
import org.apache.hc.core5.http.message.BasicNameValuePair;
|
||||||
import org.apache.http.cookie.Cookie;
|
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
@ -66,6 +65,7 @@ import java.io.InputStream;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.UnsupportedEncodingException;
|
import java.io.UnsupportedEncodingException;
|
||||||
import java.nio.charset.Charset;
|
import java.nio.charset.Charset;
|
||||||
|
import java.nio.charset.UnsupportedCharsetException;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.StandardCopyOption;
|
import java.nio.file.StandardCopyOption;
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
@ -751,7 +751,7 @@ public class ApiClient extends JavaTimeFormatter {
|
|||||||
private ContentType getContentType(String headerValue) throws ApiException {
|
private ContentType getContentType(String headerValue) throws ApiException {
|
||||||
try {
|
try {
|
||||||
return ContentType.parse(headerValue);
|
return ContentType.parse(headerValue);
|
||||||
} catch (ParseException e) {
|
} catch (UnsupportedCharsetException e) {
|
||||||
throw new ApiException("Could not parse content type " + headerValue);
|
throw new ApiException("Could not parse content type " + headerValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -832,7 +832,7 @@ public class ApiClient extends JavaTimeFormatter {
|
|||||||
* @throws IOException IO exception
|
* @throws IOException IO exception
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public <T> T deserialize(HttpResponse response, TypeReference<T> valueType) throws ApiException, IOException {
|
public <T> T deserialize(CloseableHttpResponse response, TypeReference<T> valueType) throws ApiException, IOException, ParseException {
|
||||||
if (valueType == null) {
|
if (valueType == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -862,14 +862,14 @@ public class ApiClient extends JavaTimeFormatter {
|
|||||||
} else {
|
} else {
|
||||||
throw new ApiException(
|
throw new ApiException(
|
||||||
"Deserialization for content type '" + mimeType + "' not supported for type '" + valueType + "'",
|
"Deserialization for content type '" + mimeType + "' not supported for type '" + valueType + "'",
|
||||||
response.getStatusLine().getStatusCode(),
|
response.getCode(),
|
||||||
responseHeaders,
|
responseHeaders,
|
||||||
EntityUtils.toString(entity)
|
EntityUtils.toString(entity)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private File downloadFileFromResponse(HttpResponse response) throws IOException {
|
private File downloadFileFromResponse(CloseableHttpResponse response) throws IOException {
|
||||||
Header contentDispositionHeader = response.getFirstHeader("Content-Disposition");
|
Header contentDispositionHeader = response.getFirstHeader("Content-Disposition");
|
||||||
String contentDisposition = contentDispositionHeader == null ? null : contentDispositionHeader.getValue();
|
String contentDisposition = contentDispositionHeader == null ? null : contentDispositionHeader.getValue();
|
||||||
File file = prepareDownloadFile(contentDisposition);
|
File file = prepareDownloadFile(contentDisposition);
|
||||||
@ -994,13 +994,13 @@ public class ApiClient extends JavaTimeFormatter {
|
|||||||
return cookie;
|
return cookie;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected <T> T processResponse(CloseableHttpResponse response, TypeReference<T> returnType) throws ApiException, IOException {
|
protected <T> T processResponse(CloseableHttpResponse response, TypeReference<T> returnType) throws ApiException, IOException, ParseException {
|
||||||
statusCode = response.getStatusLine().getStatusCode();
|
statusCode = response.getCode();
|
||||||
if (statusCode == HttpStatus.SC_NO_CONTENT) {
|
if (statusCode == HttpStatus.SC_NO_CONTENT) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
responseHeaders = transformResponseHeaders(response.getAllHeaders());
|
responseHeaders = transformResponseHeaders(response.getHeaders());
|
||||||
if (isSuccessfulStatus(statusCode)) {
|
if (isSuccessfulStatus(statusCode)) {
|
||||||
return this.deserialize(response, returnType);
|
return this.deserialize(response, returnType);
|
||||||
} else {
|
} else {
|
||||||
@ -1050,14 +1050,9 @@ public class ApiClient extends JavaTimeFormatter {
|
|||||||
updateParamsForAuth(authNames, queryParams, headerParams, cookieParams);
|
updateParamsForAuth(authNames, queryParams, headerParams, cookieParams);
|
||||||
final String url = buildUrl(path, queryParams, collectionQueryParams, urlQueryDeepObject);
|
final String url = buildUrl(path, queryParams, collectionQueryParams, urlQueryDeepObject);
|
||||||
|
|
||||||
RequestBuilder builder = RequestBuilder.create(method);
|
ClassicRequestBuilder builder = ClassicRequestBuilder.create(method);
|
||||||
builder.setUri(url);
|
builder.setUri(url);
|
||||||
|
|
||||||
RequestConfig config = RequestConfig.custom()
|
|
||||||
.setConnectionRequestTimeout(connectionTimeout)
|
|
||||||
.build();
|
|
||||||
builder.setConfig(config);
|
|
||||||
|
|
||||||
if (accept != null) {
|
if (accept != null) {
|
||||||
builder.addHeader("Accept", accept);
|
builder.addHeader("Accept", accept);
|
||||||
}
|
}
|
||||||
@ -1098,7 +1093,7 @@ public class ApiClient extends JavaTimeFormatter {
|
|||||||
|
|
||||||
try (CloseableHttpResponse response = httpClient.execute(builder.build(), context)) {
|
try (CloseableHttpResponse response = httpClient.execute(builder.build(), context)) {
|
||||||
return processResponse(response, returnType);
|
return processResponse(response, returnType);
|
||||||
} catch (IOException e) {
|
} catch (IOException | ParseException e) {
|
||||||
throw new ApiException(e);
|
throw new ApiException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user