[Java][okhttp] rename enum (#10642)

* rename java enum with uppercase

* add tests for snake case lambda

* update file header

* update feign templates with new enum names

* update okhttp template wth lambda

* fix tests
This commit is contained in:
William Cheng
2021-10-23 10:15:30 +08:00
committed by GitHub
parent df197e4a91
commit 7b7d7db0c7
39 changed files with 147 additions and 111 deletions

View File

@@ -67,7 +67,7 @@ public class ApiClient {
} else if ("http_basic_test".equals(authName)) {
auth = new HttpBasicAuth();
} else if ("petstore_auth".equals(authName)) {
auth = buildOauthRequestInterceptor(OAuthFlow.implicit, "http://petstore.swagger.io/api/oauth/dialog", "", "write:pets, read:pets");
auth = buildOauthRequestInterceptor(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");
}
@@ -137,9 +137,9 @@ public class ApiClient {
private RequestInterceptor buildOauthRequestInterceptor(OAuthFlow flow, String authorizationUrl, String tokenUrl, String scopes) {
switch (flow) {
case password:
case PASSWORD:
return new OauthPasswordGrant(tokenUrl, scopes);
case application:
case APPLICATION:
return new OauthClientCredentialsGrant(authorizationUrl, tokenUrl, scopes);
default:
throw new RuntimeException("Oauth flow \"" + flow + "\" is not implemented");

View File

@@ -13,10 +13,13 @@
package org.openapitools.client.auth;
/**
* OAuth flows that are supported by this client
*/
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen")
public enum OAuthFlow {
accessCode, //called authorizationCode in OpenAPI 3.0
implicit,
password,
application //called clientCredentials in OpenAPI 3.0
ACCESS_CODE, //called authorizationCode in OpenAPI 3.0
IMPLICIT,
PASSWORD,
APPLICATION //called clientCredentials in OpenAPI 3.0
}

View File

@@ -21,7 +21,7 @@ public class OauthClientCredentialsGrant extends OAuth {
@Override
protected OAuthFlow getFlow() {
return OAuthFlow.application;
return OAuthFlow.APPLICATION;
}
/**

View File

@@ -24,7 +24,7 @@ public class OauthPasswordGrant extends OAuth {
@Override
protected OAuthFlow getFlow() {
return OAuthFlow.password;
return OAuthFlow.PASSWORD;
}
/**
@@ -45,4 +45,4 @@ public class OauthPasswordGrant extends OAuth {
.defaultScope(scopes)
.build(new DefaultApi20Impl(authorizationUrl, tokenUrl));
}
}
}