forked from loafle/openapi-generator-original
Fix syntax error on authMethods in java retrofit client
This commit is contained in:
parent
8914a30935
commit
95113dbe22
@ -49,16 +49,17 @@ public class ApiClient {
|
||||
for(String authName : authNames) {
|
||||
if (apiAuthorizations.containsKey(authName)) {
|
||||
throw new RuntimeException("auth name \"" + authName + "\" already in api authorizations");
|
||||
}{{#authMethods}}
|
||||
}{{#hasAuthMethods}}
|
||||
Interceptor auth;
|
||||
if (authName == "{{name}}") { {{#isBasic}}
|
||||
{{#authMethods}}if (authName == "{{name}}") { {{#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}}
|
||||
} else {
|
||||
} else {{^hasMore}}{
|
||||
throw new RuntimeException("auth name \"" + authName + "\" not found in available auth names");
|
||||
}
|
||||
apiAuthorizations.put(authName, auth);{{/authMethods}}
|
||||
}{{/hasMore}}{{/authMethods}}
|
||||
apiAuthorizations.put(authName, auth);{{/hasAuthMethods}}{{^hasAuthMethods}}
|
||||
throw new RuntimeException("auth name \"" + authName + "\" not found in available auth names");{{/hasAuthMethods}}
|
||||
}
|
||||
addAuthsToOkClient(okClient);
|
||||
}
|
||||
|
@ -51,11 +51,10 @@ public class ApiClient {
|
||||
throw new RuntimeException("auth name \"" + authName + "\" already in api authorizations");
|
||||
}
|
||||
Interceptor auth;
|
||||
if (authName == "api_key") {
|
||||
auth = new ApiKeyAuth("header", "api_key");
|
||||
} else
|
||||
if (authName == "petstore_auth") {
|
||||
auth = new OAuth(OAuthFlow.implicit, "http://petstore.swagger.io/api/oauth/dialog", "", "write:pets, read:pets");
|
||||
} else if (authName == "api_key") {
|
||||
auth = new ApiKeyAuth("header", "api_key");
|
||||
} else {
|
||||
throw new RuntimeException("auth name \"" + authName + "\" not found in available auth names");
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user