Skip to content

Commit

Permalink
[Java][jersey2] Fix RuntimeException when HTTP signature parameters a…
Browse files Browse the repository at this point in the history
…re 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
  • Loading branch information
sebastien-rosset authored May 28, 2020
1 parent 2712bbd commit b87c927
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,6 @@ public class ApiClient {
{{#isHttpSignature}}
if (auth instanceof HttpSignatureAuth) {
authentications.put("{{name}}", auth);
} else {
authentications.put("{{name}}", null);
}
{{/isHttpSignature}}
{{/isBasic}}
Expand Down Expand Up @@ -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}}
Expand Down Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,10 +167,20 @@ public ApiClient setHttpClient(Client httpClient) {
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);
Expand Down Expand Up @@ -1183,7 +1193,7 @@ protected void updateParamsForAuth(String[] authNames, List<Pair> queryParams, M
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);
}
Expand Down

0 comments on commit b87c927

Please sign in to comment.