forked from loafle/openapi-generator-original
[Java] Make Java ApiClient extendable (#21251)
* Make all Java ApiClients in templates extendable * Make all Java ApiClients in samples extendable * Fix compilation of enum constructor * Fix compilation of enum constructor in templates
This commit is contained in:
@@ -46,14 +46,14 @@ import feign.Retryer;
|
||||
|
||||
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.14.0-SNAPSHOT")
|
||||
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 {}
|
||||
|
||||
protected ObjectMapper objectMapper;
|
||||
private String basePath = "http://petstore.swagger.io:80/v2";
|
||||
private Map<String, RequestInterceptor> apiAuthorizations;
|
||||
private Feign.Builder feignBuilder;
|
||||
protected String basePath = "http://petstore.swagger.io:80/v2";
|
||||
protected Map<String, RequestInterceptor> apiAuthorizations;
|
||||
protected Feign.Builder feignBuilder;
|
||||
|
||||
public ApiClient() {
|
||||
apiAuthorizations = new LinkedHashMap<String, RequestInterceptor>();
|
||||
@@ -135,7 +135,7 @@ public class ApiClient {
|
||||
return this;
|
||||
}
|
||||
|
||||
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);
|
||||
@@ -150,7 +150,7 @@ public class ApiClient {
|
||||
return objectMapper;
|
||||
}
|
||||
|
||||
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);
|
||||
@@ -326,7 +326,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()))
|
||||
|
||||
Reference in New Issue
Block a user