[Java][jersey2] Fix RuntimeException when HTTP signature parameters are not configured (#6457)

* Mustache template should use invokerPackage tag to generate import

* fix runtime exception when HttpSignatureAuth is not set

* fix runtime exception when HttpSignatureAuth is not set
This commit is contained in:
Sebastien Rosset
2020-05-28 06:35:16 -07:00
committed by GitHub
parent 2712bbd7c1
commit b87c927fc2
2 changed files with 22 additions and 4 deletions

View File

@@ -200,8 +200,6 @@ public class ApiClient {
{{#isHttpSignature}}
if (auth instanceof HttpSignatureAuth) {
authentications.put("{{name}}", auth);
} else {
authentications.put("{{name}}", null);
}
{{/isHttpSignature}}
{{/isBasic}}
@@ -246,10 +244,20 @@ public class ApiClient {
return this;
}
/**
* Returns the base URL to the location where the OpenAPI document is being served.
*
* @return The base URL to the target host.
*/
public String getBasePath() {
return basePath;
}
/**
* Sets the base URL to the location where the OpenAPI document is being served.
*
* @param basePath The base URL to the target host.
*/
public ApiClient setBasePath(String basePath) {
this.basePath = basePath;
{{#hasOAuthMethods}}
@@ -1281,7 +1289,7 @@ public class ApiClient {
for (String authName : authNames) {
Authentication auth = authentications.get(authName);
if (auth == null) {
throw new RuntimeException("Authentication undefined: " + authName);
continue;
}
auth.applyToParams(queryParams, headerParams, cookieParams, payload, method, uri);
}

View File

@@ -167,10 +167,20 @@ public class ApiClient {
return this;
}
/**
* Returns the base URL to the location where the OpenAPI document is being served.
*
* @return The base URL to the target host.
*/
public String getBasePath() {
return basePath;
}
/**
* Sets the base URL to the location where the OpenAPI document is being served.
*
* @param basePath The base URL to the target host.
*/
public ApiClient setBasePath(String basePath) {
this.basePath = basePath;
setOauthBasePath(basePath);
@@ -1183,7 +1193,7 @@ public class ApiClient {
for (String authName : authNames) {
Authentication auth = authentications.get(authName);
if (auth == null) {
throw new RuntimeException("Authentication undefined: " + authName);
continue;
}
auth.applyToParams(queryParams, headerParams, cookieParams, payload, method, uri);
}