[Java] [Kotlin] ignore unsupported schemes instead of throwing exception (#15817)

This commit is contained in:
Tiffany Marrel
2023-06-15 10:50:49 +02:00
committed by GitHub
parent 882b9a8c50
commit 0e212f53f2
17 changed files with 112 additions and 75 deletions

View File

@@ -57,7 +57,7 @@ public class ApiClient {
this();
for(String authName : authNames) {
log.log(Level.FINE, "Creating authentication {0}", authName);
RequestInterceptor auth;
RequestInterceptor auth = null;
if ("petstore_auth".equals(authName)) {
auth = buildOauthRequestInterceptor(OAuthFlow.IMPLICIT, "http://petstore.swagger.io/api/oauth/dialog", "", "write:pets, read:pets");
} else if ("api_key".equals(authName)) {
@@ -69,7 +69,9 @@ public class ApiClient {
} else {
throw new RuntimeException("auth name \"" + authName + "\" not found in available auth names");
}
addAuthorization(authName, auth);
if (auth != null) {
addAuthorization(authName, auth);
}
}
}

View File

@@ -58,7 +58,7 @@ public class ApiClient {
this();
for(String authName : authNames) {
log.log(Level.FINE, "Creating authentication {0}", authName);
RequestInterceptor auth;
RequestInterceptor auth = null;
if ("petstore_auth".equals(authName)) {
auth = buildOauthRequestInterceptor(OAuthFlow.IMPLICIT, "http://petstore.swagger.io/api/oauth/dialog", "", "write:pets, read:pets");
} else if ("api_key".equals(authName)) {
@@ -70,11 +70,12 @@ public class ApiClient {
} else if ("bearer_test".equals(authName)) {
auth = new HttpBearerAuth("bearer");
} else if ("http_signature_test".equals(authName)) {
throw new RuntimeException("auth name \"" + authName + "\" does not have a supported http scheme type");
} else {
throw new RuntimeException("auth name \"" + authName + "\" not found in available auth names");
}
addAuthorization(authName, auth);
if (auth != null) {
addAuthorization(authName, auth);
}
}
}

View File

@@ -52,25 +52,21 @@ public class ApiClient {
public ApiClient(String[] authNames) {
this();
for(String authName : authNames) {
Interceptor auth;
Interceptor auth = null;
if ("petstore_auth".equals(authName)) {
auth = new OAuth(OAuthFlow.IMPLICIT, "http://petstore.swagger.io/api/oauth/dialog", "", "write:pets, read:pets");
} else if ("api_key".equals(authName)) {
auth = new ApiKeyAuth("header", "api_key");
} else if ("api_key_query".equals(authName)) {
auth = new ApiKeyAuth("query", "api_key_query");
} else if ("http_basic_test".equals(authName)) {
auth = new HttpBasicAuth();
} else {
} else {
throw new RuntimeException("auth name \"" + authName + "\" not found in available auth names");
}
addAuthorization(authName, auth);
if (auth != null) {
addAuthorization(authName, auth);
}
}
}

View File

@@ -53,25 +53,21 @@ public class ApiClient {
public ApiClient(String[] authNames) {
this();
for(String authName : authNames) {
Interceptor auth;
Interceptor auth = null;
if ("petstore_auth".equals(authName)) {
auth = new OAuth(OAuthFlow.IMPLICIT, "http://petstore.swagger.io/api/oauth/dialog", "", "write:pets, read:pets");
} else if ("api_key".equals(authName)) {
auth = new ApiKeyAuth("header", "api_key");
} else if ("api_key_query".equals(authName)) {
auth = new ApiKeyAuth("query", "api_key_query");
} else if ("http_basic_test".equals(authName)) {
auth = new HttpBasicAuth();
} else {
} else {
throw new RuntimeException("auth name \"" + authName + "\" not found in available auth names");
}
addAuthorization(authName, auth);
if (auth != null) {
addAuthorization(authName, auth);
}
}
}

View File

@@ -53,25 +53,21 @@ public class ApiClient {
public ApiClient(String[] authNames) {
this();
for(String authName : authNames) {
Interceptor auth;
Interceptor auth = null;
if ("petstore_auth".equals(authName)) {
auth = new OAuth(OAuthFlow.IMPLICIT, "http://petstore.swagger.io/api/oauth/dialog", "", "write:pets, read:pets");
} else if ("api_key".equals(authName)) {
auth = new ApiKeyAuth("header", "api_key");
} else if ("api_key_query".equals(authName)) {
auth = new ApiKeyAuth("query", "api_key_query");
} else if ("http_basic_test".equals(authName)) {
auth = new HttpBasicAuth();
} else {
} else {
throw new RuntimeException("auth name \"" + authName + "\" not found in available auth names");
}
addAuthorization(authName, auth);
if (auth != null) {
addAuthorization(authName, auth);
}
}
}