forked from loafle/openapi-generator-original
[JAVA][Webclient] Add constructor to allow custom WebClient to be passed into ApiClient (#882)
* add constructor to allow custom webclient to be passed into ApiClient
This commit is contained in:
parent
39e9206976
commit
37fd4264ac
@ -33,6 +33,7 @@ import org.springframework.web.reactive.function.BodyInserters;
|
|||||||
import org.springframework.web.reactive.function.client.ExchangeStrategies;
|
import org.springframework.web.reactive.function.client.ExchangeStrategies;
|
||||||
import reactor.core.publisher.Mono;
|
import reactor.core.publisher.Mono;
|
||||||
import reactor.core.publisher.Flux;
|
import reactor.core.publisher.Flux;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -87,20 +88,22 @@ public class ApiClient {
|
|||||||
|
|
||||||
public ApiClient() {
|
public ApiClient() {
|
||||||
this.dateFormat = createDefaultDateFormat();
|
this.dateFormat = createDefaultDateFormat();
|
||||||
this.webClient = buildWebClient(new ObjectMapper(), this.dateFormat);
|
this.webClient = buildWebClient(new ObjectMapper(), dateFormat);
|
||||||
|
this.init();
|
||||||
init();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ApiClient(ObjectMapper mapper, DateFormat format) {
|
public ApiClient(ObjectMapper mapper, DateFormat format) {
|
||||||
this(buildWebClient(mapper.copy(), format), format);
|
this(buildWebClient(mapper.copy(), format), format);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ApiClient(WebClient webClient, ObjectMapper mapper, DateFormat format) {
|
||||||
|
this(Optional.ofNullable(webClient).orElseGet(() ->buildWebClient(mapper.copy(), format)), format);
|
||||||
|
}
|
||||||
|
|
||||||
private ApiClient(WebClient webClient, DateFormat format) {
|
private ApiClient(WebClient webClient, DateFormat format) {
|
||||||
this.webClient = webClient;
|
this.webClient = webClient;
|
||||||
this.dateFormat = format;
|
this.dateFormat = format;
|
||||||
|
this.init();
|
||||||
init();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public DateFormat createDefaultDateFormat() {
|
public DateFormat createDefaultDateFormat() {
|
||||||
|
@ -33,6 +33,7 @@ import org.springframework.web.reactive.function.BodyInserters;
|
|||||||
import org.springframework.web.reactive.function.client.ExchangeStrategies;
|
import org.springframework.web.reactive.function.client.ExchangeStrategies;
|
||||||
import reactor.core.publisher.Mono;
|
import reactor.core.publisher.Mono;
|
||||||
import reactor.core.publisher.Flux;
|
import reactor.core.publisher.Flux;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -87,20 +88,22 @@ public class ApiClient {
|
|||||||
|
|
||||||
public ApiClient() {
|
public ApiClient() {
|
||||||
this.dateFormat = createDefaultDateFormat();
|
this.dateFormat = createDefaultDateFormat();
|
||||||
this.webClient = buildWebClient(new ObjectMapper(), this.dateFormat);
|
this.webClient = buildWebClient(new ObjectMapper(), dateFormat);
|
||||||
|
this.init();
|
||||||
init();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ApiClient(ObjectMapper mapper, DateFormat format) {
|
public ApiClient(ObjectMapper mapper, DateFormat format) {
|
||||||
this(buildWebClient(mapper.copy(), format), format);
|
this(buildWebClient(mapper.copy(), format), format);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ApiClient(WebClient webClient, ObjectMapper mapper, DateFormat format) {
|
||||||
|
this(Optional.ofNullable(webClient).orElseGet(() ->buildWebClient(mapper.copy(), format)), format);
|
||||||
|
}
|
||||||
|
|
||||||
private ApiClient(WebClient webClient, DateFormat format) {
|
private ApiClient(WebClient webClient, DateFormat format) {
|
||||||
this.webClient = webClient;
|
this.webClient = webClient;
|
||||||
this.dateFormat = format;
|
this.dateFormat = format;
|
||||||
|
this.init();
|
||||||
init();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public DateFormat createDefaultDateFormat() {
|
public DateFormat createDefaultDateFormat() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user