mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-07-02 21:50:55 +00:00
[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:
parent
df197e4a91
commit
7b7d7db0c7
@ -2,10 +2,13 @@
|
|||||||
|
|
||||||
package {{invokerPackage}}.auth;
|
package {{invokerPackage}}.auth;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* OAuth flows that are supported by this client
|
||||||
|
*/
|
||||||
{{>generatedAnnotation}}
|
{{>generatedAnnotation}}
|
||||||
public enum OAuthFlow {
|
public enum OAuthFlow {
|
||||||
accessCode, //called authorizationCode in OpenAPI 3.0
|
ACCESS_CODE, //called authorizationCode in OpenAPI 3.0
|
||||||
implicit,
|
IMPLICIT,
|
||||||
password,
|
PASSWORD,
|
||||||
application //called clientCredentials in OpenAPI 3.0
|
APPLICATION //called clientCredentials in OpenAPI 3.0
|
||||||
}
|
}
|
||||||
|
@ -91,7 +91,7 @@ public class ApiClient {
|
|||||||
auth = new ApiKeyAuth({{#isKeyInHeader}}"header"{{/isKeyInHeader}}{{#isKeyInQuery}}"query"{{/isKeyInQuery}}{{#isKeyInCookie}}"cookie"{{/isKeyInCookie}}, "{{keyParamName}}");
|
auth = new ApiKeyAuth({{#isKeyInHeader}}"header"{{/isKeyInHeader}}{{#isKeyInQuery}}"query"{{/isKeyInQuery}}{{#isKeyInCookie}}"cookie"{{/isKeyInCookie}}, "{{keyParamName}}");
|
||||||
{{/isApiKey}}
|
{{/isApiKey}}
|
||||||
{{#isOAuth}}
|
{{#isOAuth}}
|
||||||
auth = buildOauthRequestInterceptor(OAuthFlow.{{flow}}, "{{authorizationUrl}}", "{{tokenUrl}}", "{{#scopes}}{{scope}}{{^-last}}, {{/-last}}{{/scopes}}");
|
auth = buildOauthRequestInterceptor(OAuthFlow.{{#lambda.uppercase}}{{#lambda.snakecase}}{{flow}}{{/lambda.snakecase}}{{/lambda.uppercase}}, "{{authorizationUrl}}", "{{tokenUrl}}", "{{#scopes}}{{scope}}{{^-last}}, {{/-last}}{{/scopes}}");
|
||||||
{{/isOAuth}}
|
{{/isOAuth}}
|
||||||
} else {{/authMethods}}{
|
} else {{/authMethods}}{
|
||||||
throw new RuntimeException("auth name \"" + authName + "\" not found in available auth names");
|
throw new RuntimeException("auth name \"" + authName + "\" not found in available auth names");
|
||||||
@ -179,9 +179,9 @@ public class ApiClient {
|
|||||||
{{#hasOAuthMethods}}
|
{{#hasOAuthMethods}}
|
||||||
private RequestInterceptor buildOauthRequestInterceptor(OAuthFlow flow, String authorizationUrl, String tokenUrl, String scopes) {
|
private RequestInterceptor buildOauthRequestInterceptor(OAuthFlow flow, String authorizationUrl, String tokenUrl, String scopes) {
|
||||||
switch (flow) {
|
switch (flow) {
|
||||||
case password:
|
case PASSWORD:
|
||||||
return new OauthPasswordGrant(tokenUrl, scopes);
|
return new OauthPasswordGrant(tokenUrl, scopes);
|
||||||
case application:
|
case APPLICATION:
|
||||||
return new OauthClientCredentialsGrant(authorizationUrl, tokenUrl, scopes);
|
return new OauthClientCredentialsGrant(authorizationUrl, tokenUrl, scopes);
|
||||||
default:
|
default:
|
||||||
throw new RuntimeException("Oauth flow \"" + flow + "\" is not implemented");
|
throw new RuntimeException("Oauth flow \"" + flow + "\" is not implemented");
|
||||||
|
@ -21,7 +21,7 @@ public class OauthClientCredentialsGrant extends OAuth {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected OAuthFlow getFlow() {
|
protected OAuthFlow getFlow() {
|
||||||
return OAuthFlow.application;
|
return OAuthFlow.APPLICATION;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -24,7 +24,7 @@ public class OauthPasswordGrant extends OAuth {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected OAuthFlow getFlow() {
|
protected OAuthFlow getFlow() {
|
||||||
return OAuthFlow.password;
|
return OAuthFlow.PASSWORD;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -45,4 +45,4 @@ public class OauthPasswordGrant extends OAuth {
|
|||||||
.defaultScope(scopes)
|
.defaultScope(scopes)
|
||||||
.build(new DefaultApi20Impl(authorizationUrl, tokenUrl));
|
.build(new DefaultApi20Impl(authorizationUrl, tokenUrl));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -177,7 +177,7 @@ public class ApiClient {
|
|||||||
throw new IllegalArgumentException("OAuth2 token URL must be an absolute URL");
|
throw new IllegalArgumentException("OAuth2 token URL must be an absolute URL");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
RetryingOAuth retryingOAuth = new RetryingOAuth(tokenUrl, clientId, OAuthFlow.{{flow}}, clientSecret, parameters);
|
RetryingOAuth retryingOAuth = new RetryingOAuth(tokenUrl, clientId, OAuthFlow.{{#lambda.uppercase}}{{#lambda.snakecase}}{{flow}}{{/lambda.snakecase}}{{/lambda.uppercase}}, clientSecret, parameters);
|
||||||
authentications.put(
|
authentications.put(
|
||||||
"{{name}}",
|
"{{name}}",
|
||||||
retryingOAuth
|
retryingOAuth
|
||||||
|
@ -63,16 +63,16 @@ public class RetryingOAuth extends OAuth implements Interceptor {
|
|||||||
|
|
||||||
public void setFlow(OAuthFlow flow) {
|
public void setFlow(OAuthFlow flow) {
|
||||||
switch(flow) {
|
switch(flow) {
|
||||||
case accessCode:
|
case ACCESS_CODE:
|
||||||
tokenRequestBuilder.setGrantType(GrantType.AUTHORIZATION_CODE);
|
tokenRequestBuilder.setGrantType(GrantType.AUTHORIZATION_CODE);
|
||||||
break;
|
break;
|
||||||
case implicit:
|
case IMPLICIT:
|
||||||
tokenRequestBuilder.setGrantType(GrantType.IMPLICIT);
|
tokenRequestBuilder.setGrantType(GrantType.IMPLICIT);
|
||||||
break;
|
break;
|
||||||
case password:
|
case PASSWORD:
|
||||||
tokenRequestBuilder.setGrantType(GrantType.PASSWORD);
|
tokenRequestBuilder.setGrantType(GrantType.PASSWORD);
|
||||||
break;
|
break;
|
||||||
case application:
|
case APPLICATION:
|
||||||
tokenRequestBuilder.setGrantType(GrantType.CLIENT_CREDENTIALS);
|
tokenRequestBuilder.setGrantType(GrantType.CLIENT_CREDENTIALS);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -54,14 +54,14 @@ public class OAuth implements Interceptor {
|
|||||||
|
|
||||||
public void setFlow(OAuthFlow flow) {
|
public void setFlow(OAuthFlow flow) {
|
||||||
switch(flow) {
|
switch(flow) {
|
||||||
case accessCode:
|
case ACCESS_CODE:
|
||||||
case implicit:
|
case IMPLICIT:
|
||||||
tokenRequestBuilder.setGrantType(GrantType.AUTHORIZATION_CODE);
|
tokenRequestBuilder.setGrantType(GrantType.AUTHORIZATION_CODE);
|
||||||
break;
|
break;
|
||||||
case password:
|
case PASSWORD:
|
||||||
tokenRequestBuilder.setGrantType(GrantType.PASSWORD);
|
tokenRequestBuilder.setGrantType(GrantType.PASSWORD);
|
||||||
break;
|
break;
|
||||||
case application:
|
case APPLICATION:
|
||||||
tokenRequestBuilder.setGrantType(GrantType.CLIENT_CREDENTIALS);
|
tokenRequestBuilder.setGrantType(GrantType.CLIENT_CREDENTIALS);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -85,7 +85,7 @@ public class ApiClient {
|
|||||||
auth = new ApiKeyAuth({{#isKeyInHeader}}"header"{{/isKeyInHeader}}{{#isKeyInQuery}}"query"{{/isKeyInQuery}}{{#isKeyInCookie}}"cookie"{{/isKeyInCookie}}, "{{keyParamName}}");
|
auth = new ApiKeyAuth({{#isKeyInHeader}}"header"{{/isKeyInHeader}}{{#isKeyInQuery}}"query"{{/isKeyInQuery}}{{#isKeyInCookie}}"cookie"{{/isKeyInCookie}}, "{{keyParamName}}");
|
||||||
{{/isApiKey}}
|
{{/isApiKey}}
|
||||||
{{#isOAuth}}
|
{{#isOAuth}}
|
||||||
auth = new OAuth(OAuthFlow.{{flow}}, "{{authorizationUrl}}", "{{tokenUrl}}", "{{#scopes}}{{scope}}{{^-last}}, {{/-last}}{{/scopes}}");
|
auth = new OAuth(OAuthFlow.{{#lambda.uppercase}}{{#lambda.snakecase}}{{flow}}{{/lambda.snakecase}}{{/lambda.uppercase}}, "{{authorizationUrl}}", "{{tokenUrl}}", "{{#scopes}}{{scope}}{{^-last}}, {{/-last}}{{/scopes}}");
|
||||||
{{/isOAuth}}
|
{{/isOAuth}}
|
||||||
} else {{/authMethods}}{
|
} else {{/authMethods}}{
|
||||||
throw new RuntimeException("auth name \"" + authName + "\" not found in available auth names");
|
throw new RuntimeException("auth name \"" + authName + "\" not found in available auth names");
|
||||||
|
@ -54,14 +54,14 @@ public class OAuth implements Interceptor {
|
|||||||
|
|
||||||
public void setFlow(OAuthFlow flow) {
|
public void setFlow(OAuthFlow flow) {
|
||||||
switch(flow) {
|
switch(flow) {
|
||||||
case accessCode:
|
case ACCESS_CODE:
|
||||||
case implicit:
|
case IMPLICIT:
|
||||||
tokenRequestBuilder.setGrantType(GrantType.AUTHORIZATION_CODE);
|
tokenRequestBuilder.setGrantType(GrantType.AUTHORIZATION_CODE);
|
||||||
break;
|
break;
|
||||||
case password:
|
case PASSWORD:
|
||||||
tokenRequestBuilder.setGrantType(GrantType.PASSWORD);
|
tokenRequestBuilder.setGrantType(GrantType.PASSWORD);
|
||||||
break;
|
break;
|
||||||
case application:
|
case APPLICATION:
|
||||||
tokenRequestBuilder.setGrantType(GrantType.CLIENT_CREDENTIALS);
|
tokenRequestBuilder.setGrantType(GrantType.CLIENT_CREDENTIALS);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -13,10 +13,13 @@
|
|||||||
|
|
||||||
package org.openapitools.client.auth;
|
package org.openapitools.client.auth;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* OAuth flows that are supported by this client
|
||||||
|
*/
|
||||||
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen")
|
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen")
|
||||||
public enum OAuthFlow {
|
public enum OAuthFlow {
|
||||||
accessCode, //called authorizationCode in OpenAPI 3.0
|
ACCESS_CODE, //called authorizationCode in OpenAPI 3.0
|
||||||
implicit,
|
IMPLICIT,
|
||||||
password,
|
PASSWORD,
|
||||||
application //called clientCredentials in OpenAPI 3.0
|
APPLICATION //called clientCredentials in OpenAPI 3.0
|
||||||
}
|
}
|
||||||
|
@ -67,7 +67,7 @@ public class ApiClient {
|
|||||||
} else if ("http_basic_test".equals(authName)) {
|
} else if ("http_basic_test".equals(authName)) {
|
||||||
auth = new HttpBasicAuth();
|
auth = new HttpBasicAuth();
|
||||||
} else if ("petstore_auth".equals(authName)) {
|
} 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 {
|
} else {
|
||||||
throw new RuntimeException("auth name \"" + authName + "\" not found in available auth names");
|
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) {
|
private RequestInterceptor buildOauthRequestInterceptor(OAuthFlow flow, String authorizationUrl, String tokenUrl, String scopes) {
|
||||||
switch (flow) {
|
switch (flow) {
|
||||||
case password:
|
case PASSWORD:
|
||||||
return new OauthPasswordGrant(tokenUrl, scopes);
|
return new OauthPasswordGrant(tokenUrl, scopes);
|
||||||
case application:
|
case APPLICATION:
|
||||||
return new OauthClientCredentialsGrant(authorizationUrl, tokenUrl, scopes);
|
return new OauthClientCredentialsGrant(authorizationUrl, tokenUrl, scopes);
|
||||||
default:
|
default:
|
||||||
throw new RuntimeException("Oauth flow \"" + flow + "\" is not implemented");
|
throw new RuntimeException("Oauth flow \"" + flow + "\" is not implemented");
|
||||||
|
@ -13,10 +13,13 @@
|
|||||||
|
|
||||||
package org.openapitools.client.auth;
|
package org.openapitools.client.auth;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* OAuth flows that are supported by this client
|
||||||
|
*/
|
||||||
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen")
|
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen")
|
||||||
public enum OAuthFlow {
|
public enum OAuthFlow {
|
||||||
accessCode, //called authorizationCode in OpenAPI 3.0
|
ACCESS_CODE, //called authorizationCode in OpenAPI 3.0
|
||||||
implicit,
|
IMPLICIT,
|
||||||
password,
|
PASSWORD,
|
||||||
application //called clientCredentials in OpenAPI 3.0
|
APPLICATION //called clientCredentials in OpenAPI 3.0
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@ public class OauthClientCredentialsGrant extends OAuth {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected OAuthFlow getFlow() {
|
protected OAuthFlow getFlow() {
|
||||||
return OAuthFlow.application;
|
return OAuthFlow.APPLICATION;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -24,7 +24,7 @@ public class OauthPasswordGrant extends OAuth {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected OAuthFlow getFlow() {
|
protected OAuthFlow getFlow() {
|
||||||
return OAuthFlow.password;
|
return OAuthFlow.PASSWORD;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -45,4 +45,4 @@ public class OauthPasswordGrant extends OAuth {
|
|||||||
.defaultScope(scopes)
|
.defaultScope(scopes)
|
||||||
.build(new DefaultApi20Impl(authorizationUrl, tokenUrl));
|
.build(new DefaultApi20Impl(authorizationUrl, tokenUrl));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -72,7 +72,7 @@ public class ApiClient {
|
|||||||
} else if ("http_signature_test".equals(authName)) {
|
} else if ("http_signature_test".equals(authName)) {
|
||||||
auth = new HttpBearerAuth("signature");
|
auth = new HttpBearerAuth("signature");
|
||||||
} else if ("petstore_auth".equals(authName)) {
|
} 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 {
|
} else {
|
||||||
throw new RuntimeException("auth name \"" + authName + "\" not found in available auth names");
|
throw new RuntimeException("auth name \"" + authName + "\" not found in available auth names");
|
||||||
}
|
}
|
||||||
@ -144,9 +144,9 @@ public class ApiClient {
|
|||||||
|
|
||||||
private RequestInterceptor buildOauthRequestInterceptor(OAuthFlow flow, String authorizationUrl, String tokenUrl, String scopes) {
|
private RequestInterceptor buildOauthRequestInterceptor(OAuthFlow flow, String authorizationUrl, String tokenUrl, String scopes) {
|
||||||
switch (flow) {
|
switch (flow) {
|
||||||
case password:
|
case PASSWORD:
|
||||||
return new OauthPasswordGrant(tokenUrl, scopes);
|
return new OauthPasswordGrant(tokenUrl, scopes);
|
||||||
case application:
|
case APPLICATION:
|
||||||
return new OauthClientCredentialsGrant(authorizationUrl, tokenUrl, scopes);
|
return new OauthClientCredentialsGrant(authorizationUrl, tokenUrl, scopes);
|
||||||
default:
|
default:
|
||||||
throw new RuntimeException("Oauth flow \"" + flow + "\" is not implemented");
|
throw new RuntimeException("Oauth flow \"" + flow + "\" is not implemented");
|
||||||
|
@ -13,10 +13,13 @@
|
|||||||
|
|
||||||
package org.openapitools.client.auth;
|
package org.openapitools.client.auth;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* OAuth flows that are supported by this client
|
||||||
|
*/
|
||||||
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen")
|
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen")
|
||||||
public enum OAuthFlow {
|
public enum OAuthFlow {
|
||||||
accessCode, //called authorizationCode in OpenAPI 3.0
|
ACCESS_CODE, //called authorizationCode in OpenAPI 3.0
|
||||||
implicit,
|
IMPLICIT,
|
||||||
password,
|
PASSWORD,
|
||||||
application //called clientCredentials in OpenAPI 3.0
|
APPLICATION //called clientCredentials in OpenAPI 3.0
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@ public class OauthClientCredentialsGrant extends OAuth {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected OAuthFlow getFlow() {
|
protected OAuthFlow getFlow() {
|
||||||
return OAuthFlow.application;
|
return OAuthFlow.APPLICATION;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -24,7 +24,7 @@ public class OauthPasswordGrant extends OAuth {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected OAuthFlow getFlow() {
|
protected OAuthFlow getFlow() {
|
||||||
return OAuthFlow.password;
|
return OAuthFlow.PASSWORD;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -45,4 +45,4 @@ public class OauthPasswordGrant extends OAuth {
|
|||||||
.defaultScope(scopes)
|
.defaultScope(scopes)
|
||||||
.build(new DefaultApi20Impl(authorizationUrl, tokenUrl));
|
.build(new DefaultApi20Impl(authorizationUrl, tokenUrl));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,10 +13,13 @@
|
|||||||
|
|
||||||
package org.openapitools.client.auth;
|
package org.openapitools.client.auth;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* OAuth flows that are supported by this client
|
||||||
|
*/
|
||||||
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen")
|
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen")
|
||||||
public enum OAuthFlow {
|
public enum OAuthFlow {
|
||||||
accessCode, //called authorizationCode in OpenAPI 3.0
|
ACCESS_CODE, //called authorizationCode in OpenAPI 3.0
|
||||||
implicit,
|
IMPLICIT,
|
||||||
password,
|
PASSWORD,
|
||||||
application //called clientCredentials in OpenAPI 3.0
|
APPLICATION //called clientCredentials in OpenAPI 3.0
|
||||||
}
|
}
|
||||||
|
@ -164,7 +164,7 @@ public class ApiClient {
|
|||||||
throw new IllegalArgumentException("OAuth2 token URL must be an absolute URL");
|
throw new IllegalArgumentException("OAuth2 token URL must be an absolute URL");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
RetryingOAuth retryingOAuth = new RetryingOAuth(tokenUrl, clientId, OAuthFlow.implicit, clientSecret, parameters);
|
RetryingOAuth retryingOAuth = new RetryingOAuth(tokenUrl, clientId, OAuthFlow.IMPLICIT, clientSecret, parameters);
|
||||||
authentications.put(
|
authentications.put(
|
||||||
"petstore_auth",
|
"petstore_auth",
|
||||||
retryingOAuth
|
retryingOAuth
|
||||||
|
@ -13,10 +13,13 @@
|
|||||||
|
|
||||||
package org.openapitools.client.auth;
|
package org.openapitools.client.auth;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* OAuth flows that are supported by this client
|
||||||
|
*/
|
||||||
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen")
|
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen")
|
||||||
public enum OAuthFlow {
|
public enum OAuthFlow {
|
||||||
accessCode, //called authorizationCode in OpenAPI 3.0
|
ACCESS_CODE, //called authorizationCode in OpenAPI 3.0
|
||||||
implicit,
|
IMPLICIT,
|
||||||
password,
|
PASSWORD,
|
||||||
application //called clientCredentials in OpenAPI 3.0
|
APPLICATION //called clientCredentials in OpenAPI 3.0
|
||||||
}
|
}
|
||||||
|
@ -62,16 +62,16 @@ public class RetryingOAuth extends OAuth implements Interceptor {
|
|||||||
|
|
||||||
public void setFlow(OAuthFlow flow) {
|
public void setFlow(OAuthFlow flow) {
|
||||||
switch(flow) {
|
switch(flow) {
|
||||||
case accessCode:
|
case ACCESS_CODE:
|
||||||
tokenRequestBuilder.setGrantType(GrantType.AUTHORIZATION_CODE);
|
tokenRequestBuilder.setGrantType(GrantType.AUTHORIZATION_CODE);
|
||||||
break;
|
break;
|
||||||
case implicit:
|
case IMPLICIT:
|
||||||
tokenRequestBuilder.setGrantType(GrantType.IMPLICIT);
|
tokenRequestBuilder.setGrantType(GrantType.IMPLICIT);
|
||||||
break;
|
break;
|
||||||
case password:
|
case PASSWORD:
|
||||||
tokenRequestBuilder.setGrantType(GrantType.PASSWORD);
|
tokenRequestBuilder.setGrantType(GrantType.PASSWORD);
|
||||||
break;
|
break;
|
||||||
case application:
|
case APPLICATION:
|
||||||
tokenRequestBuilder.setGrantType(GrantType.CLIENT_CREDENTIALS);
|
tokenRequestBuilder.setGrantType(GrantType.CLIENT_CREDENTIALS);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -156,7 +156,7 @@ public class ApiClient {
|
|||||||
throw new IllegalArgumentException("OAuth2 token URL must be an absolute URL");
|
throw new IllegalArgumentException("OAuth2 token URL must be an absolute URL");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
RetryingOAuth retryingOAuth = new RetryingOAuth(tokenUrl, clientId, OAuthFlow.implicit, clientSecret, parameters);
|
RetryingOAuth retryingOAuth = new RetryingOAuth(tokenUrl, clientId, OAuthFlow.IMPLICIT, clientSecret, parameters);
|
||||||
authentications.put(
|
authentications.put(
|
||||||
"petstore_auth",
|
"petstore_auth",
|
||||||
retryingOAuth
|
retryingOAuth
|
||||||
|
@ -13,10 +13,13 @@
|
|||||||
|
|
||||||
package org.openapitools.client.auth;
|
package org.openapitools.client.auth;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* OAuth flows that are supported by this client
|
||||||
|
*/
|
||||||
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen")
|
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen")
|
||||||
public enum OAuthFlow {
|
public enum OAuthFlow {
|
||||||
accessCode, //called authorizationCode in OpenAPI 3.0
|
ACCESS_CODE, //called authorizationCode in OpenAPI 3.0
|
||||||
implicit,
|
IMPLICIT,
|
||||||
password,
|
PASSWORD,
|
||||||
application //called clientCredentials in OpenAPI 3.0
|
APPLICATION //called clientCredentials in OpenAPI 3.0
|
||||||
}
|
}
|
||||||
|
@ -62,16 +62,16 @@ public class RetryingOAuth extends OAuth implements Interceptor {
|
|||||||
|
|
||||||
public void setFlow(OAuthFlow flow) {
|
public void setFlow(OAuthFlow flow) {
|
||||||
switch(flow) {
|
switch(flow) {
|
||||||
case accessCode:
|
case ACCESS_CODE:
|
||||||
tokenRequestBuilder.setGrantType(GrantType.AUTHORIZATION_CODE);
|
tokenRequestBuilder.setGrantType(GrantType.AUTHORIZATION_CODE);
|
||||||
break;
|
break;
|
||||||
case implicit:
|
case IMPLICIT:
|
||||||
tokenRequestBuilder.setGrantType(GrantType.IMPLICIT);
|
tokenRequestBuilder.setGrantType(GrantType.IMPLICIT);
|
||||||
break;
|
break;
|
||||||
case password:
|
case PASSWORD:
|
||||||
tokenRequestBuilder.setGrantType(GrantType.PASSWORD);
|
tokenRequestBuilder.setGrantType(GrantType.PASSWORD);
|
||||||
break;
|
break;
|
||||||
case application:
|
case APPLICATION:
|
||||||
tokenRequestBuilder.setGrantType(GrantType.CLIENT_CREDENTIALS);
|
tokenRequestBuilder.setGrantType(GrantType.CLIENT_CREDENTIALS);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -156,7 +156,7 @@ public class ApiClient {
|
|||||||
throw new IllegalArgumentException("OAuth2 token URL must be an absolute URL");
|
throw new IllegalArgumentException("OAuth2 token URL must be an absolute URL");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
RetryingOAuth retryingOAuth = new RetryingOAuth(tokenUrl, clientId, OAuthFlow.implicit, clientSecret, parameters);
|
RetryingOAuth retryingOAuth = new RetryingOAuth(tokenUrl, clientId, OAuthFlow.IMPLICIT, clientSecret, parameters);
|
||||||
authentications.put(
|
authentications.put(
|
||||||
"petstore_auth",
|
"petstore_auth",
|
||||||
retryingOAuth
|
retryingOAuth
|
||||||
|
@ -13,10 +13,13 @@
|
|||||||
|
|
||||||
package org.openapitools.client.auth;
|
package org.openapitools.client.auth;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* OAuth flows that are supported by this client
|
||||||
|
*/
|
||||||
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen")
|
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen")
|
||||||
public enum OAuthFlow {
|
public enum OAuthFlow {
|
||||||
accessCode, //called authorizationCode in OpenAPI 3.0
|
ACCESS_CODE, //called authorizationCode in OpenAPI 3.0
|
||||||
implicit,
|
IMPLICIT,
|
||||||
password,
|
PASSWORD,
|
||||||
application //called clientCredentials in OpenAPI 3.0
|
APPLICATION //called clientCredentials in OpenAPI 3.0
|
||||||
}
|
}
|
||||||
|
@ -62,16 +62,16 @@ public class RetryingOAuth extends OAuth implements Interceptor {
|
|||||||
|
|
||||||
public void setFlow(OAuthFlow flow) {
|
public void setFlow(OAuthFlow flow) {
|
||||||
switch(flow) {
|
switch(flow) {
|
||||||
case accessCode:
|
case ACCESS_CODE:
|
||||||
tokenRequestBuilder.setGrantType(GrantType.AUTHORIZATION_CODE);
|
tokenRequestBuilder.setGrantType(GrantType.AUTHORIZATION_CODE);
|
||||||
break;
|
break;
|
||||||
case implicit:
|
case IMPLICIT:
|
||||||
tokenRequestBuilder.setGrantType(GrantType.IMPLICIT);
|
tokenRequestBuilder.setGrantType(GrantType.IMPLICIT);
|
||||||
break;
|
break;
|
||||||
case password:
|
case PASSWORD:
|
||||||
tokenRequestBuilder.setGrantType(GrantType.PASSWORD);
|
tokenRequestBuilder.setGrantType(GrantType.PASSWORD);
|
||||||
break;
|
break;
|
||||||
case application:
|
case APPLICATION:
|
||||||
tokenRequestBuilder.setGrantType(GrantType.CLIENT_CREDENTIALS);
|
tokenRequestBuilder.setGrantType(GrantType.CLIENT_CREDENTIALS);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -33,7 +33,7 @@ public class RetryingOAuthTest {
|
|||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
oauth = new RetryingOAuth("_clientId", "_clientSecret", OAuthFlow.accessCode,
|
oauth = new RetryingOAuth("_clientId", "_clientSecret", OAuthFlow.ACCESS_CODE,
|
||||||
"https://token.example.com", Collections.<String, String>emptyMap());
|
"https://token.example.com", Collections.<String, String>emptyMap());
|
||||||
oauth.setAccessToken("expired-access-token");
|
oauth.setAccessToken("expired-access-token");
|
||||||
FieldUtils.writeField(oauth, "oAuthClient", mockOAuthClient(), true);
|
FieldUtils.writeField(oauth, "oAuthClient", mockOAuthClient(), true);
|
||||||
|
@ -13,10 +13,13 @@
|
|||||||
|
|
||||||
package org.openapitools.client.auth;
|
package org.openapitools.client.auth;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* OAuth flows that are supported by this client
|
||||||
|
*/
|
||||||
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen")
|
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen")
|
||||||
public enum OAuthFlow {
|
public enum OAuthFlow {
|
||||||
accessCode, //called authorizationCode in OpenAPI 3.0
|
ACCESS_CODE, //called authorizationCode in OpenAPI 3.0
|
||||||
implicit,
|
IMPLICIT,
|
||||||
password,
|
PASSWORD,
|
||||||
application //called clientCredentials in OpenAPI 3.0
|
APPLICATION //called clientCredentials in OpenAPI 3.0
|
||||||
}
|
}
|
||||||
|
@ -65,7 +65,7 @@ public class ApiClient {
|
|||||||
|
|
||||||
} else if ("petstore_auth".equals(authName)) {
|
} else if ("petstore_auth".equals(authName)) {
|
||||||
|
|
||||||
auth = new OAuth(OAuthFlow.implicit, "http://petstore.swagger.io/api/oauth/dialog", "", "write:pets, read:pets");
|
auth = new OAuth(OAuthFlow.IMPLICIT, "http://petstore.swagger.io/api/oauth/dialog", "", "write:pets, read:pets");
|
||||||
} else {
|
} else {
|
||||||
throw new RuntimeException("auth name \"" + authName + "\" not found in available auth names");
|
throw new RuntimeException("auth name \"" + authName + "\" not found in available auth names");
|
||||||
}
|
}
|
||||||
|
@ -54,14 +54,14 @@ public class OAuth implements Interceptor {
|
|||||||
|
|
||||||
public void setFlow(OAuthFlow flow) {
|
public void setFlow(OAuthFlow flow) {
|
||||||
switch(flow) {
|
switch(flow) {
|
||||||
case accessCode:
|
case ACCESS_CODE:
|
||||||
case implicit:
|
case IMPLICIT:
|
||||||
tokenRequestBuilder.setGrantType(GrantType.AUTHORIZATION_CODE);
|
tokenRequestBuilder.setGrantType(GrantType.AUTHORIZATION_CODE);
|
||||||
break;
|
break;
|
||||||
case password:
|
case PASSWORD:
|
||||||
tokenRequestBuilder.setGrantType(GrantType.PASSWORD);
|
tokenRequestBuilder.setGrantType(GrantType.PASSWORD);
|
||||||
break;
|
break;
|
||||||
case application:
|
case APPLICATION:
|
||||||
tokenRequestBuilder.setGrantType(GrantType.CLIENT_CREDENTIALS);
|
tokenRequestBuilder.setGrantType(GrantType.CLIENT_CREDENTIALS);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -13,10 +13,13 @@
|
|||||||
|
|
||||||
package org.openapitools.client.auth;
|
package org.openapitools.client.auth;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* OAuth flows that are supported by this client
|
||||||
|
*/
|
||||||
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen")
|
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen")
|
||||||
public enum OAuthFlow {
|
public enum OAuthFlow {
|
||||||
accessCode, //called authorizationCode in OpenAPI 3.0
|
ACCESS_CODE, //called authorizationCode in OpenAPI 3.0
|
||||||
implicit,
|
IMPLICIT,
|
||||||
password,
|
PASSWORD,
|
||||||
application //called clientCredentials in OpenAPI 3.0
|
APPLICATION //called clientCredentials in OpenAPI 3.0
|
||||||
}
|
}
|
||||||
|
@ -66,7 +66,7 @@ public class ApiClient {
|
|||||||
|
|
||||||
} else if ("petstore_auth".equals(authName)) {
|
} else if ("petstore_auth".equals(authName)) {
|
||||||
|
|
||||||
auth = new OAuth(OAuthFlow.implicit, "http://petstore.swagger.io/api/oauth/dialog", "", "write:pets, read:pets");
|
auth = new OAuth(OAuthFlow.IMPLICIT, "http://petstore.swagger.io/api/oauth/dialog", "", "write:pets, read:pets");
|
||||||
} else {
|
} else {
|
||||||
throw new RuntimeException("auth name \"" + authName + "\" not found in available auth names");
|
throw new RuntimeException("auth name \"" + authName + "\" not found in available auth names");
|
||||||
}
|
}
|
||||||
|
@ -54,14 +54,14 @@ public class OAuth implements Interceptor {
|
|||||||
|
|
||||||
public void setFlow(OAuthFlow flow) {
|
public void setFlow(OAuthFlow flow) {
|
||||||
switch(flow) {
|
switch(flow) {
|
||||||
case accessCode:
|
case ACCESS_CODE:
|
||||||
case implicit:
|
case IMPLICIT:
|
||||||
tokenRequestBuilder.setGrantType(GrantType.AUTHORIZATION_CODE);
|
tokenRequestBuilder.setGrantType(GrantType.AUTHORIZATION_CODE);
|
||||||
break;
|
break;
|
||||||
case password:
|
case PASSWORD:
|
||||||
tokenRequestBuilder.setGrantType(GrantType.PASSWORD);
|
tokenRequestBuilder.setGrantType(GrantType.PASSWORD);
|
||||||
break;
|
break;
|
||||||
case application:
|
case APPLICATION:
|
||||||
tokenRequestBuilder.setGrantType(GrantType.CLIENT_CREDENTIALS);
|
tokenRequestBuilder.setGrantType(GrantType.CLIENT_CREDENTIALS);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -13,10 +13,13 @@
|
|||||||
|
|
||||||
package org.openapitools.client.auth;
|
package org.openapitools.client.auth;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* OAuth flows that are supported by this client
|
||||||
|
*/
|
||||||
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen")
|
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen")
|
||||||
public enum OAuthFlow {
|
public enum OAuthFlow {
|
||||||
accessCode, //called authorizationCode in OpenAPI 3.0
|
ACCESS_CODE, //called authorizationCode in OpenAPI 3.0
|
||||||
implicit,
|
IMPLICIT,
|
||||||
password,
|
PASSWORD,
|
||||||
application //called clientCredentials in OpenAPI 3.0
|
APPLICATION //called clientCredentials in OpenAPI 3.0
|
||||||
}
|
}
|
||||||
|
@ -66,7 +66,7 @@ public class ApiClient {
|
|||||||
|
|
||||||
} else if ("petstore_auth".equals(authName)) {
|
} else if ("petstore_auth".equals(authName)) {
|
||||||
|
|
||||||
auth = new OAuth(OAuthFlow.implicit, "http://petstore.swagger.io/api/oauth/dialog", "", "write:pets, read:pets");
|
auth = new OAuth(OAuthFlow.IMPLICIT, "http://petstore.swagger.io/api/oauth/dialog", "", "write:pets, read:pets");
|
||||||
} else {
|
} else {
|
||||||
throw new RuntimeException("auth name \"" + authName + "\" not found in available auth names");
|
throw new RuntimeException("auth name \"" + authName + "\" not found in available auth names");
|
||||||
}
|
}
|
||||||
|
@ -54,14 +54,14 @@ public class OAuth implements Interceptor {
|
|||||||
|
|
||||||
public void setFlow(OAuthFlow flow) {
|
public void setFlow(OAuthFlow flow) {
|
||||||
switch(flow) {
|
switch(flow) {
|
||||||
case accessCode:
|
case ACCESS_CODE:
|
||||||
case implicit:
|
case IMPLICIT:
|
||||||
tokenRequestBuilder.setGrantType(GrantType.AUTHORIZATION_CODE);
|
tokenRequestBuilder.setGrantType(GrantType.AUTHORIZATION_CODE);
|
||||||
break;
|
break;
|
||||||
case password:
|
case PASSWORD:
|
||||||
tokenRequestBuilder.setGrantType(GrantType.PASSWORD);
|
tokenRequestBuilder.setGrantType(GrantType.PASSWORD);
|
||||||
break;
|
break;
|
||||||
case application:
|
case APPLICATION:
|
||||||
tokenRequestBuilder.setGrantType(GrantType.CLIENT_CREDENTIALS);
|
tokenRequestBuilder.setGrantType(GrantType.CLIENT_CREDENTIALS);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -13,10 +13,13 @@
|
|||||||
|
|
||||||
package org.openapitools.client.auth;
|
package org.openapitools.client.auth;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* OAuth flows that are supported by this client
|
||||||
|
*/
|
||||||
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen")
|
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen")
|
||||||
public enum OAuthFlow {
|
public enum OAuthFlow {
|
||||||
accessCode, //called authorizationCode in OpenAPI 3.0
|
ACCESS_CODE, //called authorizationCode in OpenAPI 3.0
|
||||||
implicit,
|
IMPLICIT,
|
||||||
password,
|
PASSWORD,
|
||||||
application //called clientCredentials in OpenAPI 3.0
|
APPLICATION //called clientCredentials in OpenAPI 3.0
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user