Merge 04677612c6d1c6b7aa845efab76e8c18fa7be503 into d6c46342693205f0dae441b45742d9c85d41cf33

This commit is contained in:
Loginov Ilia 2025-05-09 11:07:53 +05:30 committed by GitHub
commit e413a85773
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 29 additions and 34 deletions

View File

@ -117,7 +117,7 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
this.dateFormat = createDefaultDateFormat();
this.objectMapper = createDefaultObjectMapper(this.dateFormat);
this.webClient = buildWebClient(this.objectMapper);
this.init();
this.authentications = buildAuthentications();
}
{{#generateClientAsBean}}
@ -139,7 +139,7 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
this.webClient = webClient;
this.dateFormat = format;
this.objectMapper = createDefaultObjectMapper(format);
this.init();
this.authentications = buildAuthentications();
}
public static DateFormat createDefaultDateFormat() {
@ -163,15 +163,16 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
return mapper;
}
protected void init() {
protected static Map<String, Authentication> buildAuthentications() {{=<% %>=}}{<%={{ }}=%>{{#authMethods.0}}
// Setup authentications (key: authentication name, value: authentication).
authentications = new HashMap<String, Authentication>();{{#authMethods}}{{#isBasic}}{{#isBasicBasic}}
Map<String, Authentication> authentications = new HashMap<>();{{#authMethods}}{{#isBasic}}{{#isBasicBasic}}
authentications.put("{{name}}", new HttpBasicAuth());{{/isBasicBasic}}{{#isBasicBearer}}
authentications.put("{{name}}", new HttpBearerAuth("{{scheme}}"));{{/isBasicBearer}}{{/isBasic}}{{#isApiKey}}
authentications.put("{{name}}", new ApiKeyAuth({{#isKeyInHeader}}"header"{{/isKeyInHeader}}{{#isKeyInQuery}}"query"{{/isKeyInQuery}}{{#isKeyInCookie}}"cookie"{{/isKeyInCookie}}, "{{keyParamName}}"));{{/isApiKey}}{{#isOAuth}}
authentications.put("{{name}}", new OAuth());{{/isOAuth}}{{/authMethods}}
// Prevent the authentications from being modified.
authentications = Collections.unmodifiableMap(authentications);
return Collections.unmodifiableMap(authentications);{{/authMethods.0}}{{^authMethods.0}}
return Collections.emptyMap();{{/authMethods.0}}
}
/**

View File

@ -112,7 +112,7 @@ public class ApiClient extends JavaTimeFormatter {
this.dateFormat = createDefaultDateFormat();
this.objectMapper = createDefaultObjectMapper(this.dateFormat);
this.webClient = buildWebClient(this.objectMapper);
this.init();
this.authentications = buildAuthentications();
}
public ApiClient(WebClient webClient) {
@ -131,7 +131,7 @@ public class ApiClient extends JavaTimeFormatter {
this.webClient = webClient;
this.dateFormat = format;
this.objectMapper = createDefaultObjectMapper(format);
this.init();
this.authentications = buildAuthentications();
}
public static DateFormat createDefaultDateFormat() {
@ -153,11 +153,8 @@ public class ApiClient extends JavaTimeFormatter {
return mapper;
}
protected void init() {
// Setup authentications (key: authentication name, value: authentication).
authentications = new HashMap<String, Authentication>();
// Prevent the authentications from being modified.
authentications = Collections.unmodifiableMap(authentications);
protected static Map<String, Authentication> buildAuthentications() {
return Collections.emptyMap();
}
/**

View File

@ -113,7 +113,7 @@ public class ApiClient extends JavaTimeFormatter {
this.dateFormat = createDefaultDateFormat();
this.objectMapper = createDefaultObjectMapper(this.dateFormat);
this.webClient = buildWebClient(this.objectMapper);
this.init();
this.authentications = buildAuthentications();
}
public ApiClient(WebClient webClient) {
@ -132,7 +132,7 @@ public class ApiClient extends JavaTimeFormatter {
this.webClient = webClient;
this.dateFormat = format;
this.objectMapper = createDefaultObjectMapper(format);
this.init();
this.authentications = buildAuthentications();
}
public static DateFormat createDefaultDateFormat() {
@ -154,16 +154,16 @@ public class ApiClient extends JavaTimeFormatter {
return mapper;
}
protected void init() {
protected static Map<String, Authentication> buildAuthentications() {
// Setup authentications (key: authentication name, value: authentication).
authentications = new HashMap<String, Authentication>();
Map<String, Authentication> authentications = new HashMap<>();
authentications.put("petstore_auth", new OAuth());
authentications.put("api_key", new ApiKeyAuth("header", "api_key"));
authentications.put("api_key_query", new ApiKeyAuth("query", "api_key_query"));
authentications.put("http_basic_test", new HttpBasicAuth());
authentications.put("bearer_test", new HttpBearerAuth("bearer"));
// Prevent the authentications from being modified.
authentications = Collections.unmodifiableMap(authentications);
return Collections.unmodifiableMap(authentications);
}
/**

View File

@ -112,7 +112,7 @@ public class ApiClient extends JavaTimeFormatter {
this.dateFormat = createDefaultDateFormat();
this.objectMapper = createDefaultObjectMapper(this.dateFormat);
this.webClient = buildWebClient(this.objectMapper);
this.init();
this.authentications = buildAuthentications();
}
public ApiClient(WebClient webClient) {
@ -131,7 +131,7 @@ public class ApiClient extends JavaTimeFormatter {
this.webClient = webClient;
this.dateFormat = format;
this.objectMapper = createDefaultObjectMapper(format);
this.init();
this.authentications = buildAuthentications();
}
public static DateFormat createDefaultDateFormat() {
@ -153,11 +153,8 @@ public class ApiClient extends JavaTimeFormatter {
return mapper;
}
protected void init() {
// Setup authentications (key: authentication name, value: authentication).
authentications = new HashMap<String, Authentication>();
// Prevent the authentications from being modified.
authentications = Collections.unmodifiableMap(authentications);
protected static Map<String, Authentication> buildAuthentications() {
return Collections.emptyMap();
}
/**

View File

@ -113,7 +113,7 @@ public class ApiClient extends JavaTimeFormatter {
this.dateFormat = createDefaultDateFormat();
this.objectMapper = createDefaultObjectMapper(this.dateFormat);
this.webClient = buildWebClient(this.objectMapper);
this.init();
this.authentications = buildAuthentications();
}
public ApiClient(WebClient webClient) {
@ -132,7 +132,7 @@ public class ApiClient extends JavaTimeFormatter {
this.webClient = webClient;
this.dateFormat = format;
this.objectMapper = createDefaultObjectMapper(format);
this.init();
this.authentications = buildAuthentications();
}
public static DateFormat createDefaultDateFormat() {
@ -154,16 +154,16 @@ public class ApiClient extends JavaTimeFormatter {
return mapper;
}
protected void init() {
protected static Map<String, Authentication> buildAuthentications() {
// Setup authentications (key: authentication name, value: authentication).
authentications = new HashMap<String, Authentication>();
Map<String, Authentication> authentications = new HashMap<>();
authentications.put("petstore_auth", new OAuth());
authentications.put("api_key", new ApiKeyAuth("header", "api_key"));
authentications.put("api_key_query", new ApiKeyAuth("query", "api_key_query"));
authentications.put("http_basic_test", new HttpBasicAuth());
authentications.put("bearer_test", new HttpBearerAuth("bearer"));
// Prevent the authentications from being modified.
authentications = Collections.unmodifiableMap(authentications);
return Collections.unmodifiableMap(authentications);
}
/**

View File

@ -113,7 +113,7 @@ public class ApiClient extends JavaTimeFormatter {
this.dateFormat = createDefaultDateFormat();
this.objectMapper = createDefaultObjectMapper(this.dateFormat);
this.webClient = buildWebClient(this.objectMapper);
this.init();
this.authentications = buildAuthentications();
}
public ApiClient(WebClient webClient) {
@ -132,7 +132,7 @@ public class ApiClient extends JavaTimeFormatter {
this.webClient = webClient;
this.dateFormat = format;
this.objectMapper = createDefaultObjectMapper(format);
this.init();
this.authentications = buildAuthentications();
}
public static DateFormat createDefaultDateFormat() {
@ -154,16 +154,16 @@ public class ApiClient extends JavaTimeFormatter {
return mapper;
}
protected void init() {
protected static Map<String, Authentication> buildAuthentications() {
// Setup authentications (key: authentication name, value: authentication).
authentications = new HashMap<String, Authentication>();
Map<String, Authentication> authentications = new HashMap<>();
authentications.put("petstore_auth", new OAuth());
authentications.put("api_key", new ApiKeyAuth("header", "api_key"));
authentications.put("api_key_query", new ApiKeyAuth("query", "api_key_query"));
authentications.put("http_basic_test", new HttpBasicAuth());
authentications.put("bearer_test", new HttpBearerAuth("bearer"));
// Prevent the authentications from being modified.
authentications = Collections.unmodifiableMap(authentications);
return Collections.unmodifiableMap(authentications);
}
/**