rename enum constants (#10631)

This commit is contained in:
William Cheng
2021-10-22 09:26:48 +08:00
committed by GitHub
parent e85c67edc7
commit 681578d1b5
8 changed files with 52 additions and 28 deletions

View File

@@ -26,7 +26,7 @@ public class OAuth implements Authentication {
private String tokenUrl; private String tokenUrl;
private String absoluteTokenUrl; private String absoluteTokenUrl;
private OAuthFlow flow = OAuthFlow.application; private OAuthFlow flow = OAuthFlow.APPLICATION;
private OAuth20Service service; private OAuth20Service service;
private DefaultApi20 authApi; private DefaultApi20 authApi;
private String scope; private String scope;
@@ -103,18 +103,18 @@ public class OAuth implements Authentication {
} }
try { try {
switch (flow) { switch (flow) {
case password: case PASSWORD:
if (username != null && password != null) { if (username != null && password != null) {
accessToken = service.getAccessTokenPasswordGrant(username, password, scope); accessToken = service.getAccessTokenPasswordGrant(username, password, scope);
} }
break; break;
case accessCode: case ACCESS_CODE:
if (code != null) { if (code != null) {
accessToken = service.getAccessToken(code); accessToken = service.getAccessToken(code);
code = null; code = null;
} }
break; break;
case application: case APPLICATION:
accessToken = service.getAccessTokenClientCredentialsGrant(scope); accessToken = service.getAccessTokenClientCredentialsGrant(scope);
break; break;
default: default:
@@ -159,14 +159,14 @@ public class OAuth implements Authentication {
} }
public OAuth usePasswordFlow(String username, String password) { public OAuth usePasswordFlow(String username, String password) {
this.flow = OAuthFlow.password; this.flow = OAuthFlow.PASSWORD;
this.username = username; this.username = username;
this.password = password; this.password = password;
return this; return this;
} }
public OAuth useAuthorizationCodeFlow(String code) { public OAuth useAuthorizationCodeFlow(String code) {
this.flow = OAuthFlow.accessCode; this.flow = OAuthFlow.ACCESS_CODE;
this.code = code; this.code = code;
return this; return this;
} }

View File

@@ -2,6 +2,12 @@
package {{invokerPackage}}.auth; package {{invokerPackage}}.auth;
/**
* OAuth flows that are supported by this client
*/
public enum OAuthFlow { public enum OAuthFlow {
accessCode, implicit, password, application ACCESS_CODE,
IMPLICIT,
PASSWORD,
APPLICATION
} }

View File

@@ -37,7 +37,7 @@ public class OAuth implements Authentication {
private String tokenUrl; private String tokenUrl;
private String absoluteTokenUrl; private String absoluteTokenUrl;
private OAuthFlow flow = OAuthFlow.application; private OAuthFlow flow = OAuthFlow.APPLICATION;
private OAuth20Service service; private OAuth20Service service;
private DefaultApi20 authApi; private DefaultApi20 authApi;
private String scope; private String scope;
@@ -114,18 +114,18 @@ public class OAuth implements Authentication {
} }
try { try {
switch (flow) { switch (flow) {
case password: case PASSWORD:
if (username != null && password != null) { if (username != null && password != null) {
accessToken = service.getAccessTokenPasswordGrant(username, password, scope); accessToken = service.getAccessTokenPasswordGrant(username, password, scope);
} }
break; break;
case accessCode: case ACCESS_CODE:
if (code != null) { if (code != null) {
accessToken = service.getAccessToken(code); accessToken = service.getAccessToken(code);
code = null; code = null;
} }
break; break;
case application: case APPLICATION:
accessToken = service.getAccessTokenClientCredentialsGrant(scope); accessToken = service.getAccessTokenClientCredentialsGrant(scope);
break; break;
default: default:
@@ -170,14 +170,14 @@ public class OAuth implements Authentication {
} }
public OAuth usePasswordFlow(String username, String password) { public OAuth usePasswordFlow(String username, String password) {
this.flow = OAuthFlow.password; this.flow = OAuthFlow.PASSWORD;
this.username = username; this.username = username;
this.password = password; this.password = password;
return this; return this;
} }
public OAuth useAuthorizationCodeFlow(String code) { public OAuth useAuthorizationCodeFlow(String code) {
this.flow = OAuthFlow.accessCode; this.flow = OAuthFlow.ACCESS_CODE;
this.code = code; this.code = code;
return this; return this;
} }

View File

@@ -13,6 +13,12 @@
package org.openapitools.client.auth; package org.openapitools.client.auth;
/**
* OAuth flows that are supported by this client
*/
public enum OAuthFlow { public enum OAuthFlow {
accessCode, implicit, password, application ACCESS_CODE,
IMPLICIT,
PASSWORD,
APPLICATION
} }

View File

@@ -37,7 +37,7 @@ public class OAuth implements Authentication {
private String tokenUrl; private String tokenUrl;
private String absoluteTokenUrl; private String absoluteTokenUrl;
private OAuthFlow flow = OAuthFlow.application; private OAuthFlow flow = OAuthFlow.APPLICATION;
private OAuth20Service service; private OAuth20Service service;
private DefaultApi20 authApi; private DefaultApi20 authApi;
private String scope; private String scope;
@@ -114,18 +114,18 @@ public class OAuth implements Authentication {
} }
try { try {
switch (flow) { switch (flow) {
case password: case PASSWORD:
if (username != null && password != null) { if (username != null && password != null) {
accessToken = service.getAccessTokenPasswordGrant(username, password, scope); accessToken = service.getAccessTokenPasswordGrant(username, password, scope);
} }
break; break;
case accessCode: case ACCESS_CODE:
if (code != null) { if (code != null) {
accessToken = service.getAccessToken(code); accessToken = service.getAccessToken(code);
code = null; code = null;
} }
break; break;
case application: case APPLICATION:
accessToken = service.getAccessTokenClientCredentialsGrant(scope); accessToken = service.getAccessTokenClientCredentialsGrant(scope);
break; break;
default: default:
@@ -170,14 +170,14 @@ public class OAuth implements Authentication {
} }
public OAuth usePasswordFlow(String username, String password) { public OAuth usePasswordFlow(String username, String password) {
this.flow = OAuthFlow.password; this.flow = OAuthFlow.PASSWORD;
this.username = username; this.username = username;
this.password = password; this.password = password;
return this; return this;
} }
public OAuth useAuthorizationCodeFlow(String code) { public OAuth useAuthorizationCodeFlow(String code) {
this.flow = OAuthFlow.accessCode; this.flow = OAuthFlow.ACCESS_CODE;
this.code = code; this.code = code;
return this; return this;
} }

View File

@@ -13,6 +13,12 @@
package org.openapitools.client.auth; package org.openapitools.client.auth;
/**
* OAuth flows that are supported by this client
*/
public enum OAuthFlow { public enum OAuthFlow {
accessCode, implicit, password, application ACCESS_CODE,
IMPLICIT,
PASSWORD,
APPLICATION
} }

View File

@@ -37,7 +37,7 @@ public class OAuth implements Authentication {
private String tokenUrl; private String tokenUrl;
private String absoluteTokenUrl; private String absoluteTokenUrl;
private OAuthFlow flow = OAuthFlow.application; private OAuthFlow flow = OAuthFlow.APPLICATION;
private OAuth20Service service; private OAuth20Service service;
private DefaultApi20 authApi; private DefaultApi20 authApi;
private String scope; private String scope;
@@ -114,18 +114,18 @@ public class OAuth implements Authentication {
} }
try { try {
switch (flow) { switch (flow) {
case password: case PASSWORD:
if (username != null && password != null) { if (username != null && password != null) {
accessToken = service.getAccessTokenPasswordGrant(username, password, scope); accessToken = service.getAccessTokenPasswordGrant(username, password, scope);
} }
break; break;
case accessCode: case ACCESS_CODE:
if (code != null) { if (code != null) {
accessToken = service.getAccessToken(code); accessToken = service.getAccessToken(code);
code = null; code = null;
} }
break; break;
case application: case APPLICATION:
accessToken = service.getAccessTokenClientCredentialsGrant(scope); accessToken = service.getAccessTokenClientCredentialsGrant(scope);
break; break;
default: default:
@@ -170,14 +170,14 @@ public class OAuth implements Authentication {
} }
public OAuth usePasswordFlow(String username, String password) { public OAuth usePasswordFlow(String username, String password) {
this.flow = OAuthFlow.password; this.flow = OAuthFlow.PASSWORD;
this.username = username; this.username = username;
this.password = password; this.password = password;
return this; return this;
} }
public OAuth useAuthorizationCodeFlow(String code) { public OAuth useAuthorizationCodeFlow(String code) {
this.flow = OAuthFlow.accessCode; this.flow = OAuthFlow.ACCESS_CODE;
this.code = code; this.code = code;
return this; return this;
} }

View File

@@ -13,6 +13,12 @@
package org.openapitools.client.auth; package org.openapitools.client.auth;
/**
* OAuth flows that are supported by this client
*/
public enum OAuthFlow { public enum OAuthFlow {
accessCode, implicit, password, application ACCESS_CODE,
IMPLICIT,
PASSWORD,
APPLICATION
} }