[Java-retrofit] Fix for #4750 String comparison with equals (#4751)

* [Java-Feign] Fixed String comparison using equals instead of == operator

* [Java-Feign] Updated ApiClient with ./bin/java-petstore-feign.sh

* [Java-retrofit] Fix for #4750 String comparison with equals
This commit is contained in:
Jan 2017-02-08 14:54:56 +01:00 committed by wing328
parent d91135ec8f
commit 0d14496bd6
4 changed files with 8 additions and 8 deletions

View File

@ -54,7 +54,7 @@ public class ApiClient {
this(); this();
for(String authName : authNames) { {{#hasAuthMethods}} for(String authName : authNames) { {{#hasAuthMethods}}
Interceptor auth; Interceptor auth;
{{#authMethods}}if (authName == "{{name}}") { {{#isBasic}} {{#authMethods}}if ("{{name}}".equals(authName)) { {{#isBasic}}
auth = new HttpBasicAuth();{{/isBasic}}{{#isApiKey}} auth = new HttpBasicAuth();{{/isBasic}}{{#isApiKey}}
auth = new ApiKeyAuth({{#isKeyInHeader}}"header"{{/isKeyInHeader}}{{^isKeyInHeader}}"query"{{/isKeyInHeader}}, "{{keyParamName}}");{{/isApiKey}}{{#isOAuth}} auth = new ApiKeyAuth({{#isKeyInHeader}}"header"{{/isKeyInHeader}}{{^isKeyInHeader}}"query"{{/isKeyInHeader}}, "{{keyParamName}}");{{/isApiKey}}{{#isOAuth}}
auth = new OAuth(OAuthFlow.{{flow}}, "{{authorizationUrl}}", "{{tokenUrl}}", "{{#scopes}}{{scope}}{{#hasMore}}, {{/hasMore}}{{/scopes}}");{{/isOAuth}} auth = new OAuth(OAuthFlow.{{flow}}, "{{authorizationUrl}}", "{{tokenUrl}}", "{{#scopes}}{{scope}}{{#hasMore}}, {{/hasMore}}{{/scopes}}");{{/isOAuth}}

View File

@ -60,7 +60,7 @@ public class ApiClient {
this(); this();
for(String authName : authNames) { {{#hasAuthMethods}} for(String authName : authNames) { {{#hasAuthMethods}}
Interceptor auth; Interceptor auth;
{{#authMethods}}if (authName == "{{name}}") { {{#isBasic}} {{#authMethods}}if ("{{name}}".equals(authName)) { {{#isBasic}}
auth = new HttpBasicAuth();{{/isBasic}}{{#isApiKey}} auth = new HttpBasicAuth();{{/isBasic}}{{#isApiKey}}
auth = new ApiKeyAuth({{#isKeyInHeader}}"header"{{/isKeyInHeader}}{{^isKeyInHeader}}"query"{{/isKeyInHeader}}, "{{keyParamName}}");{{/isApiKey}}{{#isOAuth}} auth = new ApiKeyAuth({{#isKeyInHeader}}"header"{{/isKeyInHeader}}{{^isKeyInHeader}}"query"{{/isKeyInHeader}}, "{{keyParamName}}");{{/isApiKey}}{{#isOAuth}}
auth = new OAuth(OAuthFlow.{{flow}}, "{{authorizationUrl}}", "{{tokenUrl}}", "{{#scopes}}{{scope}}{{#hasMore}}, {{/hasMore}}{{/scopes}}");{{/isOAuth}} auth = new OAuth(OAuthFlow.{{flow}}, "{{authorizationUrl}}", "{{tokenUrl}}", "{{#scopes}}{{scope}}{{#hasMore}}, {{/hasMore}}{{/scopes}}");{{/isOAuth}}

View File

@ -54,11 +54,11 @@ public class ApiClient {
this(); this();
for(String authName : authNames) { for(String authName : authNames) {
Interceptor auth; Interceptor auth;
if (authName == "api_key") { if ("api_key".equals(authName)) {
auth = new ApiKeyAuth("header", "api_key"); auth = new ApiKeyAuth("header", "api_key");
} else if (authName == "http_basic_test") { } else if ("http_basic_test".equals(authName)) {
auth = new HttpBasicAuth(); auth = new HttpBasicAuth();
} else if (authName == "petstore_auth") { } else if ("petstore_auth".equals(authName)) {
auth = new OAuth(OAuthFlow.implicit, "http://petstore.swagger.io/api/oauth/dialog", "", "write:pets, read:pets"); auth = new OAuth(OAuthFlow.implicit, "http://petstore.swagger.io/api/oauth/dialog", "", "write:pets, read:pets");
} else { } else {
throw new RuntimeException("auth name \"" + authName + "\" not found in available auth names"); throw new RuntimeException("auth name \"" + authName + "\" not found in available auth names");

View File

@ -53,11 +53,11 @@ public class ApiClient {
this(); this();
for(String authName : authNames) { for(String authName : authNames) {
Interceptor auth; Interceptor auth;
if (authName == "api_key") { if ("api_key".equals(authName)) {
auth = new ApiKeyAuth("header", "api_key"); auth = new ApiKeyAuth("header", "api_key");
} else if (authName == "http_basic_test") { } else if ("http_basic_test".equals(authName)) {
auth = new HttpBasicAuth(); auth = new HttpBasicAuth();
} else if (authName == "petstore_auth") { } else if ("petstore_auth".equals(authName)) {
auth = new OAuth(OAuthFlow.implicit, "http://petstore.swagger.io/api/oauth/dialog", "", "write:pets, read:pets"); auth = new OAuth(OAuthFlow.implicit, "http://petstore.swagger.io/api/oauth/dialog", "", "write:pets, read:pets");
} else { } else {
throw new RuntimeException("auth name \"" + authName + "\" not found in available auth names"); throw new RuntimeException("auth name \"" + authName + "\" not found in available auth names");