This commit is contained in:
wing328 2017-02-08 17:00:01 +08:00
commit d91135ec8f
3 changed files with 5 additions and 4 deletions

View File

@ -840,6 +840,7 @@ Here are some companies/projects using Swagger Codegen in production. To add you
- [Slamby](https://www.slamby.com/)
- [SmartRecruiters](https://www.smartrecruiters.com/)
- [snapCX](https://snapcx.io)
- [SPINEN](http://www.spinen.com)
- [SRC](https://www.src.si/)
- [StyleRecipe](http://stylerecipe.co.jp)
- [Svenska Spel AB](https://www.svenskaspel.se/)

View File

@ -47,7 +47,7 @@ public class ApiClient {
this();
for(String authName : authNames) { {{#hasAuthMethods}}
RequestInterceptor auth;
{{#authMethods}}if (authName == "{{name}}") { {{#isBasic}}
{{#authMethods}}if ("{{name}}".equals(authName)) { {{#isBasic}}
auth = new HttpBasicAuth();{{/isBasic}}{{#isApiKey}}
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}}

View File

@ -42,11 +42,11 @@ public class ApiClient {
this();
for(String authName : authNames) {
RequestInterceptor auth;
if (authName == "api_key") {
if ("api_key".equals(authName)) {
auth = new ApiKeyAuth("header", "api_key");
} else if (authName == "http_basic_test") {
} else if ("http_basic_test".equals(authName)) {
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");
} else {
throw new RuntimeException("auth name \"" + authName + "\" not found in available auth names");