From 88ae36eec06b2b246addb8437d41524352c4414f Mon Sep 17 00:00:00 2001 From: Jochen Reinhardt <46705439+JochenReinhardt@users.noreply.github.com> Date: Sat, 25 Jun 2022 04:21:14 +0200 Subject: [PATCH] #12656 fix HTML-escaped token and authorization URLs in Java based libraries (#12677) --- .../src/main/resources/Java/libraries/feign/ApiClient.mustache | 2 +- .../main/resources/Java/libraries/jersey2/ApiClient.mustache | 2 +- .../main/resources/Java/libraries/jersey3/ApiClient.mustache | 2 +- .../resources/Java/libraries/okhttp-gson/ApiClient.mustache | 2 +- .../main/resources/Java/libraries/retrofit/ApiClient.mustache | 2 +- .../main/resources/Java/libraries/retrofit2/ApiClient.mustache | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/feign/ApiClient.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/feign/ApiClient.mustache index 20b2cb3354f4..cc9599940f91 100644 --- a/modules/openapi-generator/src/main/resources/Java/libraries/feign/ApiClient.mustache +++ b/modules/openapi-generator/src/main/resources/Java/libraries/feign/ApiClient.mustache @@ -83,7 +83,7 @@ public class ApiClient { auth = new ApiKeyAuth({{#isKeyInHeader}}"header"{{/isKeyInHeader}}{{#isKeyInQuery}}"query"{{/isKeyInQuery}}{{#isKeyInCookie}}"cookie"{{/isKeyInCookie}}, "{{keyParamName}}"); {{/isApiKey}} {{#isOAuth}} - auth = buildOauthRequestInterceptor(OAuthFlow.{{#lambda.uppercase}}{{#lambda.snakecase}}{{flow}}{{/lambda.snakecase}}{{/lambda.uppercase}}, "{{authorizationUrl}}", "{{tokenUrl}}", "{{#scopes}}{{scope}}{{^-last}}, {{/-last}}{{/scopes}}"); + auth = buildOauthRequestInterceptor(OAuthFlow.{{#lambda.uppercase}}{{#lambda.snakecase}}{{flow}}{{/lambda.snakecase}}{{/lambda.uppercase}}, "{{{authorizationUrl}}}", "{{{tokenUrl}}}", "{{#scopes}}{{scope}}{{^-last}}, {{/-last}}{{/scopes}}"); {{/isOAuth}} } else {{/authMethods}}{ throw new RuntimeException("auth name \"" + authName + "\" not found in available auth names"); 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 0db332a10c04..bf9545f34f4d 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 @@ -227,7 +227,7 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} { if (auth instanceof OAuth) { authentications.put("{{name}}", auth); } else { - authentications.put("{{name}}", new OAuth(basePath, "{{tokenUrl}}")); + authentications.put("{{name}}", new OAuth(basePath, "{{{tokenUrl}}}")); } {{/isOAuth}} {{/authMethods}} diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/jersey3/ApiClient.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/jersey3/ApiClient.mustache index 2454aafa8973..baaa6037fab6 100644 --- a/modules/openapi-generator/src/main/resources/Java/libraries/jersey3/ApiClient.mustache +++ b/modules/openapi-generator/src/main/resources/Java/libraries/jersey3/ApiClient.mustache @@ -227,7 +227,7 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} { if (auth instanceof OAuth) { authentications.put("{{name}}", auth); } else { - authentications.put("{{name}}", new OAuth(basePath, "{{tokenUrl}}")); + authentications.put("{{name}}", new OAuth(basePath, "{{{tokenUrl}}}")); } {{/isOAuth}} {{/authMethods}} diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/ApiClient.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/ApiClient.mustache index 0bddc657e0d3..73a5749fba7c 100644 --- a/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/ApiClient.mustache +++ b/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/ApiClient.mustache @@ -180,7 +180,7 @@ public class ApiClient { } {{#hasOAuthMethods}} - String tokenUrl = "{{tokenUrl}}"; + String tokenUrl = "{{{tokenUrl}}}"; if (!"".equals(tokenUrl) && !URI.create(tokenUrl).isAbsolute()) { URI uri = URI.create(getBasePath()); tokenUrl = uri.getScheme() + ":" + diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/retrofit/ApiClient.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/retrofit/ApiClient.mustache index ad3057e9c3dd..465762a36bab 100644 --- a/modules/openapi-generator/src/main/resources/Java/libraries/retrofit/ApiClient.mustache +++ b/modules/openapi-generator/src/main/resources/Java/libraries/retrofit/ApiClient.mustache @@ -73,7 +73,7 @@ public class ApiClient { auth = new ApiKeyAuth({{#isKeyInHeader}}"header"{{/isKeyInHeader}}{{#isKeyInQuery}}"query"{{/isKeyInQuery}}{{#isKeyInCookie}}"cookie"{{/isKeyInCookie}}, "{{keyParamName}}"); {{/isApiKey}} {{#isOAuth}} - auth = new OAuth(OAuthFlow.{{flow}}, "{{authorizationUrl}}", "{{tokenUrl}}", "{{#scopes}}{{scope}}{{^-last}}, {{/-last}}{{/scopes}}"); + auth = new OAuth(OAuthFlow.{{flow}}, "{{{authorizationUrl}}}", "{{{tokenUrl}}}", "{{#scopes}}{{scope}}{{^-last}}, {{/-last}}{{/scopes}}"); {{/isOAuth}} } else {{/authMethods}}{ throw new RuntimeException("auth name \"" + authName + "\" not found in available auth names"); diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/retrofit2/ApiClient.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/retrofit2/ApiClient.mustache index d94c3b3deeee..8e40fd194c83 100644 --- a/modules/openapi-generator/src/main/resources/Java/libraries/retrofit2/ApiClient.mustache +++ b/modules/openapi-generator/src/main/resources/Java/libraries/retrofit2/ApiClient.mustache @@ -77,7 +77,7 @@ public class ApiClient { auth = new ApiKeyAuth({{#isKeyInHeader}}"header"{{/isKeyInHeader}}{{#isKeyInQuery}}"query"{{/isKeyInQuery}}{{#isKeyInCookie}}"cookie"{{/isKeyInCookie}}, "{{keyParamName}}"); {{/isApiKey}} {{#isOAuth}} - auth = new OAuth(OAuthFlow.{{#lambda.uppercase}}{{#lambda.snakecase}}{{flow}}{{/lambda.snakecase}}{{/lambda.uppercase}}, "{{authorizationUrl}}", "{{tokenUrl}}", "{{#scopes}}{{scope}}{{^-last}}, {{/-last}}{{/scopes}}"); + auth = new OAuth(OAuthFlow.{{#lambda.uppercase}}{{#lambda.snakecase}}{{flow}}{{/lambda.snakecase}}{{/lambda.uppercase}}, "{{{authorizationUrl}}}", "{{{tokenUrl}}}", "{{#scopes}}{{scope}}{{^-last}}, {{/-last}}{{/scopes}}"); {{/isOAuth}} } else {{/authMethods}}{ throw new RuntimeException("auth name \"" + authName + "\" not found in available auth names");