Skip to content

Commit 9ac9802

Browse files
committed
Fix syntax issue when no auth methods defined
When no authentication methods are defined, the generated code does not compile due to where the authMethods closing tag is located. Moved the closing tag further down and opening tag further up so that the generated code is correct both when authentication are and aren't present.
1 parent a2fda60 commit 9ac9802

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

modules/swagger-codegen/src/main/resources/Java/libraries/retrofit/ApiClient.mustache

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,16 +49,16 @@ public class ApiClient {
4949
for(String authName : authNames) {
5050
if (apiAuthorizations.containsKey(authName)) {
5151
throw new RuntimeException("auth name \"" + authName + "\" already in api authorizations");
52-
}
53-
Interceptor auth;{{#authMethods}}
52+
}{{#authMethods}}
53+
Interceptor auth;
5454
if (authName == "{{name}}") { {{#isBasic}}
5555
auth = new HttpBasicAuth();{{/isBasic}}{{#isApiKey}}
5656
auth = new ApiKeyAuth({{#isKeyInHeader}}"header"{{/isKeyInHeader}}{{^isKeyInHeader}}"query"{{/isKeyInHeader}}, "{{keyParamName}}");{{/isApiKey}}{{#isOAuth}}
5757
auth = new OAuth(OAuthFlow.{{flow}}, "{{authorizationUrl}}", "{{tokenUrl}}", "{{#scopes}}{{^-first}}, {{/-first}}{{this}}{{/scopes}}");{{/isOAuth}}
58-
} else {{/authMethods}}{
58+
} else {
5959
throw new RuntimeException("auth name \"" + authName + "\" not found in available auth names");
6060
}
61-
apiAuthorizations.put(authName, auth);
61+
apiAuthorizations.put(authName, auth);{{/authMethods}}
6262
}
6363
addAuthsToOkClient(okClient);
6464
}

0 commit comments

Comments
 (0)