Skip to content

Fix syntax error on authMethods in java retrofit client #1444

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Oct 27, 2015
Merged

Fix syntax error on authMethods in java retrofit client #1444

merged 3 commits into from
Oct 27, 2015

Conversation

xhh
Copy link
Contributor

@xhh xhh commented Oct 27, 2015

For example, the following Petstore code generated with the latest master does not compile:

for(String authName : authNames) {
    if (apiAuthorizations.containsKey(authName)) {
        throw new RuntimeException("auth name \"" + authName + "\" already in api authorizations");
    }
    Interceptor auth;
    if (authName == "petstore_auth") { 
        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");
    }
    apiAuthorizations.put(authName, auth);
    Interceptor auth;
    if (authName == "api_key") { 
        auth = new ApiKeyAuth("header", "api_key");
    } else {
        throw new RuntimeException("auth name \"" + authName + "\" not found in available auth names");
    }
    apiAuthorizations.put(authName, auth);
}

This PR changes it to:

for(String authName : authNames) {
    if (apiAuthorizations.containsKey(authName)) {
        throw new RuntimeException("auth name \"" + authName + "\" already in api authorizations");
    }
    Interceptor auth;
    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");
    }
    apiAuthorizations.put(authName, auth);
}

@xhh xhh closed this Oct 27, 2015
@xhh xhh reopened this Oct 27, 2015
wing328 added a commit that referenced this pull request Oct 27, 2015
Fix syntax error on authMethods in java retrofit client
@wing328 wing328 merged commit cf59b5d into swagger-api:master Oct 27, 2015
@wing328 wing328 added this to the v2.1.5 milestone Oct 27, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants