From 41e97e6d2bd817c39e0ce6593acea8b9b290ddd6 Mon Sep 17 00:00:00 2001 From: "Sebastien Rosset (serosset)" Date: Tue, 12 May 2020 18:57:25 -0700 Subject: [PATCH 1/3] Mustache template should use invokerPackage tag to generate import --- .../Java/libraries/jersey2/AbstractOpenApiSchema.mustache | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/jersey2/AbstractOpenApiSchema.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/jersey2/AbstractOpenApiSchema.mustache index cdba3be84552..c924650e6c0a 100644 --- a/modules/openapi-generator/src/main/resources/Java/libraries/jersey2/AbstractOpenApiSchema.mustache +++ b/modules/openapi-generator/src/main/resources/Java/libraries/jersey2/AbstractOpenApiSchema.mustache @@ -2,7 +2,7 @@ package {{invokerPackage}}.model; -import org.openapitools.client.ApiException; +import {{invokerPackage}}.ApiException; import java.lang.reflect.Type; import java.util.Map; import javax.ws.rs.core.GenericType; From f48c34fe441c91c3be5185aa0d96a536a2e4213f Mon Sep 17 00:00:00 2001 From: "Sebastien Rosset (serosset)" Date: Wed, 27 May 2020 09:25:08 -0700 Subject: [PATCH 2/3] fix runtime exception when HttpSignatureAuth is not set --- .../Java/libraries/jersey2/ApiClient.mustache | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/jersey2/ApiClient.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/jersey2/ApiClient.mustache index 362aee07d75d..8d12c42630d1 100644 --- a/modules/openapi-generator/src/main/resources/Java/libraries/jersey2/ApiClient.mustache +++ b/modules/openapi-generator/src/main/resources/Java/libraries/jersey2/ApiClient.mustache @@ -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); } From 33c192a6e5863f7c4b151ceba0aaba750242e8f4 Mon Sep 17 00:00:00 2001 From: "Sebastien Rosset (serosset)" Date: Wed, 27 May 2020 09:30:32 -0700 Subject: [PATCH 3/3] fix runtime exception when HttpSignatureAuth is not set --- .../main/java/org/openapitools/client/ApiClient.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/samples/client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client/ApiClient.java b/samples/client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client/ApiClient.java index a6405acc7842..a4ebc69f5678 100644 --- a/samples/client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client/ApiClient.java +++ b/samples/client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client/ApiClient.java @@ -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); @@ -1183,7 +1193,7 @@ protected void updateParamsForAuth(String[] authNames, List 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); }