forked from loafle/openapi-generator-original
[Java] [Kotlin] ignore unsupported schemes instead of throwing exception (#15817)
This commit is contained in:
parent
882b9a8c50
commit
0e212f53f2
@ -94,21 +94,14 @@ public class ApiClient {
|
|||||||
for(String authName : authNames) {
|
for(String authName : authNames) {
|
||||||
log.log(Level.FINE, "Creating authentication {0}", authName);
|
log.log(Level.FINE, "Creating authentication {0}", authName);
|
||||||
{{#hasAuthMethods}}
|
{{#hasAuthMethods}}
|
||||||
RequestInterceptor auth;
|
RequestInterceptor auth = null;
|
||||||
{{#authMethods}}if ("{{name}}".equals(authName)) {
|
{{#authMethods}}if ("{{name}}".equals(authName)) {
|
||||||
{{#isBasic}}
|
|
||||||
{{#isBasicBasic}}
|
{{#isBasicBasic}}
|
||||||
auth = new HttpBasicAuth();
|
auth = new HttpBasicAuth();
|
||||||
{{/isBasicBasic}}
|
{{/isBasicBasic}}
|
||||||
{{^isBasicBasic}}
|
|
||||||
{{#isBasicBearer}}
|
{{#isBasicBearer}}
|
||||||
auth = new HttpBearerAuth("{{scheme}}");
|
auth = new HttpBearerAuth("{{scheme}}");
|
||||||
{{/isBasicBearer}}
|
{{/isBasicBearer}}
|
||||||
{{^isBasicBearer}}
|
|
||||||
throw new RuntimeException("auth name \"" + authName + "\" does not have a supported http scheme type");
|
|
||||||
{{/isBasicBearer}}
|
|
||||||
{{/isBasicBasic}}
|
|
||||||
{{/isBasic}}
|
|
||||||
{{#isApiKey}}
|
{{#isApiKey}}
|
||||||
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}}
|
||||||
@ -118,7 +111,9 @@ public class ApiClient {
|
|||||||
} 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");
|
||||||
}
|
}
|
||||||
addAuthorization(authName, auth);
|
if (auth != null) {
|
||||||
|
addAuthorization(authName, auth);
|
||||||
|
}
|
||||||
{{/hasAuthMethods}}
|
{{/hasAuthMethods}}
|
||||||
{{^hasAuthMethods}}
|
{{^hasAuthMethods}}
|
||||||
throw new RuntimeException("auth name \"" + authName + "\" not found in available auth names");
|
throw new RuntimeException("auth name \"" + authName + "\" not found in available auth names");
|
||||||
|
@ -59,21 +59,14 @@ public class ApiClient {
|
|||||||
this();
|
this();
|
||||||
for(String authName : authNames) {
|
for(String authName : authNames) {
|
||||||
{{#hasAuthMethods}}
|
{{#hasAuthMethods}}
|
||||||
Interceptor auth;
|
Interceptor auth = null;
|
||||||
{{#authMethods}}if ("{{name}}".equals(authName)) {
|
{{#authMethods}}if ("{{name}}".equals(authName)) {
|
||||||
{{#isBasic}}
|
|
||||||
{{#isBasicBasic}}
|
{{#isBasicBasic}}
|
||||||
auth = new HttpBasicAuth();
|
auth = new HttpBasicAuth();
|
||||||
{{/isBasicBasic}}
|
{{/isBasicBasic}}
|
||||||
{{^isBasicBasic}}
|
|
||||||
{{#isBasicBearer}}
|
{{#isBasicBearer}}
|
||||||
auth = new HttpBearerAuth("{{scheme}}");
|
auth = new HttpBearerAuth("{{scheme}}");
|
||||||
{{/isBasicBearer}}
|
{{/isBasicBearer}}
|
||||||
{{^isBasicBearer}}
|
|
||||||
throw new RuntimeException("auth name \"" + authName + "\" does not have a supported http scheme type");
|
|
||||||
{{/isBasicBearer}}
|
|
||||||
{{/isBasicBasic}}
|
|
||||||
{{/isBasic}}
|
|
||||||
{{#isApiKey}}
|
{{#isApiKey}}
|
||||||
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}}
|
||||||
@ -83,7 +76,9 @@ public class ApiClient {
|
|||||||
} 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");
|
||||||
}
|
}
|
||||||
addAuthorization(authName, auth);
|
if (auth != null) {
|
||||||
|
addAuthorization(authName, auth);
|
||||||
|
}
|
||||||
{{/hasAuthMethods}}
|
{{/hasAuthMethods}}
|
||||||
{{^hasAuthMethods}}
|
{{^hasAuthMethods}}
|
||||||
throw new RuntimeException("auth name \"" + authName + "\" not found in available auth names");
|
throw new RuntimeException("auth name \"" + authName + "\" not found in available auth names");
|
||||||
|
@ -66,15 +66,13 @@ public class ApiClient {
|
|||||||
this();
|
this();
|
||||||
for(String authName : authNames) {
|
for(String authName : authNames) {
|
||||||
{{#hasAuthMethods}}
|
{{#hasAuthMethods}}
|
||||||
Interceptor auth;
|
Interceptor auth = null;
|
||||||
{{#authMethods}}if ("{{name}}".equals(authName)) {
|
{{#authMethods}}if ("{{name}}".equals(authName)) {
|
||||||
{{#isBasic}}{{#isBasicBasic}}
|
{{#isBasicBasic}}
|
||||||
auth = new HttpBasicAuth();
|
auth = new HttpBasicAuth();
|
||||||
{{/isBasicBasic}}{{^isBasicBasic}}{{#isBasicBearer}}
|
{{/isBasicBasic}}{{#isBasicBearer}}
|
||||||
auth = new HttpBearerAuth("{{scheme}}");
|
auth = new HttpBearerAuth("{{scheme}}");
|
||||||
{{/isBasicBearer}}{{^isBasicBearer}}
|
{{/isBasicBearer}}
|
||||||
throw new RuntimeException("auth name \"" + authName + "\" does not have a supported http scheme type");
|
|
||||||
{{/isBasicBearer}}{{/isBasicBasic}}{{/isBasic}}
|
|
||||||
{{#isApiKey}}
|
{{#isApiKey}}
|
||||||
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}}
|
||||||
@ -84,8 +82,9 @@ public class ApiClient {
|
|||||||
} 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");
|
||||||
}
|
}
|
||||||
|
if (auth != null) {
|
||||||
addAuthorization(authName, auth);
|
addAuthorization(authName, auth);
|
||||||
|
}
|
||||||
{{/hasAuthMethods}}
|
{{/hasAuthMethods}}
|
||||||
{{^hasAuthMethods}}
|
{{^hasAuthMethods}}
|
||||||
throw new RuntimeException("auth name \"" + authName + "\" not found in available auth names");
|
throw new RuntimeException("auth name \"" + authName + "\" not found in available auth names");
|
||||||
|
@ -127,11 +127,17 @@ import okhttp3.MediaType.Companion.toMediaType
|
|||||||
authNames: Array<String>
|
authNames: Array<String>
|
||||||
) : this(baseUrl, okHttpClientBuilder{{^kotlinx_serialization}}, serializerBuilder{{/kotlinx_serialization}}) {
|
) : this(baseUrl, okHttpClientBuilder{{^kotlinx_serialization}}, serializerBuilder{{/kotlinx_serialization}}) {
|
||||||
authNames.forEach { authName ->
|
authNames.forEach { authName ->
|
||||||
val auth = when (authName) {
|
val auth = when (authName) { {{#authMethods}}
|
||||||
{{#authMethods}}"{{name}}" -> {{#isBasic}}{{#isBasicBasic}}HttpBasicAuth(){{/isBasicBasic}}{{^isBasicBasic}}{{#isBasicBearer}}HttpBearerAuth("{{scheme}}"){{/isBasicBearer}}{{^isBasicBearer}}throw RuntimeException("auth name $authName does not have a supported http scheme type"){{/isBasicBearer}}{{/isBasicBasic}}{{/isBasic}}{{#isApiKey}}ApiKeyAuth({{#isKeyInHeader}}"header"{{/isKeyInHeader}}{{#isKeyInQuery}}"query"{{/isKeyInQuery}}{{#isKeyInCookie}}"cookie"{{/isKeyInCookie}}, "{{keyParamName}}"){{/isApiKey}}{{#isOAuth}}OAuth(OAuthFlow.{{flow}}, "{{authorizationUrl}}", "{{tokenUrl}}", "{{#scopes}}{{scope}}{{^-last}}, {{/-last}}{{/scopes}}"){{/isOAuth}}{{/authMethods}}
|
{{#isBasicBasic}}"{{name}}" -> HttpBasicAuth()
|
||||||
|
{{/isBasicBasic}}{{#isBasicBearer}}"{{name}}" -> HttpBearerAuth("{{scheme}}")
|
||||||
|
{{/isBasicBearer}}{{#isApiKey}}"{{name}}" -> ApiKeyAuth({{#isKeyInHeader}}"header"{{/isKeyInHeader}}{{#isKeyInQuery}}"query"{{/isKeyInQuery}}{{#isKeyInCookie}}"cookie"{{/isKeyInCookie}}, "{{keyParamName}}")
|
||||||
|
{{/isApiKey}}{{#isOAuth}}"{{name}}" -> OAuth(OAuthFlow.{{flow}}, "{{authorizationUrl}}", "{{tokenUrl}}", "{{#scopes}}{{scope}}{{^-last}}, {{/-last}}{{/scopes}}")
|
||||||
|
{{/isOAuth}}{{^isBasicBasic}}{{^isBasicBearer}}{{^isApiKey}}{{^isOAuth}}"{{name}}" -> null{{/isOAuth}}{{/isApiKey}}{{/isBasicBearer}}{{/isBasicBasic}}{{/authMethods}}
|
||||||
else -> throw RuntimeException("auth name $authName not found in available auth names")
|
else -> throw RuntimeException("auth name $authName not found in available auth names")
|
||||||
}
|
}
|
||||||
addAuthorization(authName, auth)
|
if (auth != null) {
|
||||||
|
addAuthorization(authName, auth)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
{{#authMethods}}
|
{{#authMethods}}
|
||||||
{{#isBasicBasic}}
|
{{#isBasicBasic}}
|
||||||
val principal = call.authentication.principal<UserIdPrincipal>()!!
|
val principal = call.authentication.principal<UserIdPrincipal>()!!
|
||||||
{{/isBasicBasic}}
|
{{/isBasicBasic}}{{^isBasicBasic}}{{#isApiKey}}
|
||||||
{{#isApiKey}}
|
|
||||||
val principal = call.authentication.principal<ApiPrincipal>()!!
|
val principal = call.authentication.principal<ApiPrincipal>()!!
|
||||||
{{/isApiKey}}
|
{{/isApiKey}}{{^isApiKey}}{{#isOAuth}}
|
||||||
{{#isOAuth}}
|
|
||||||
val principal = call.authentication.principal<OAuthAccessTokenResponse>()!!
|
val principal = call.authentication.principal<OAuthAccessTokenResponse>()!!
|
||||||
{{/isOAuth}}
|
{{/isOAuth}}{{^isOAuth}}
|
||||||
|
val principal = null!!
|
||||||
|
{{/isOAuth}}{{/isApiKey}}{{/isBasicBasic}}
|
||||||
{{/authMethods}}
|
{{/authMethods}}
|
||||||
|
@ -57,7 +57,7 @@ public class ApiClient {
|
|||||||
this();
|
this();
|
||||||
for(String authName : authNames) {
|
for(String authName : authNames) {
|
||||||
log.log(Level.FINE, "Creating authentication {0}", authName);
|
log.log(Level.FINE, "Creating authentication {0}", authName);
|
||||||
RequestInterceptor auth;
|
RequestInterceptor auth = null;
|
||||||
if ("petstore_auth".equals(authName)) {
|
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 if ("api_key".equals(authName)) {
|
} else if ("api_key".equals(authName)) {
|
||||||
@ -69,7 +69,9 @@ public class ApiClient {
|
|||||||
} 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");
|
||||||
}
|
}
|
||||||
addAuthorization(authName, auth);
|
if (auth != null) {
|
||||||
|
addAuthorization(authName, auth);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ public class ApiClient {
|
|||||||
this();
|
this();
|
||||||
for(String authName : authNames) {
|
for(String authName : authNames) {
|
||||||
log.log(Level.FINE, "Creating authentication {0}", authName);
|
log.log(Level.FINE, "Creating authentication {0}", authName);
|
||||||
RequestInterceptor auth;
|
RequestInterceptor auth = null;
|
||||||
if ("petstore_auth".equals(authName)) {
|
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 if ("api_key".equals(authName)) {
|
} else if ("api_key".equals(authName)) {
|
||||||
@ -70,11 +70,12 @@ public class ApiClient {
|
|||||||
} else if ("bearer_test".equals(authName)) {
|
} else if ("bearer_test".equals(authName)) {
|
||||||
auth = new HttpBearerAuth("bearer");
|
auth = new HttpBearerAuth("bearer");
|
||||||
} else if ("http_signature_test".equals(authName)) {
|
} else if ("http_signature_test".equals(authName)) {
|
||||||
throw new RuntimeException("auth name \"" + authName + "\" does not have a supported http scheme type");
|
|
||||||
} 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");
|
||||||
}
|
}
|
||||||
addAuthorization(authName, auth);
|
if (auth != null) {
|
||||||
|
addAuthorization(authName, auth);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,25 +52,21 @@ public class ApiClient {
|
|||||||
public ApiClient(String[] authNames) {
|
public ApiClient(String[] authNames) {
|
||||||
this();
|
this();
|
||||||
for(String authName : authNames) {
|
for(String authName : authNames) {
|
||||||
Interceptor auth;
|
Interceptor auth = null;
|
||||||
if ("petstore_auth".equals(authName)) {
|
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 if ("api_key".equals(authName)) {
|
} else if ("api_key".equals(authName)) {
|
||||||
|
|
||||||
auth = new ApiKeyAuth("header", "api_key");
|
auth = new ApiKeyAuth("header", "api_key");
|
||||||
} else if ("api_key_query".equals(authName)) {
|
} else if ("api_key_query".equals(authName)) {
|
||||||
|
|
||||||
auth = new ApiKeyAuth("query", "api_key_query");
|
auth = new ApiKeyAuth("query", "api_key_query");
|
||||||
} else if ("http_basic_test".equals(authName)) {
|
} else if ("http_basic_test".equals(authName)) {
|
||||||
|
|
||||||
auth = new HttpBasicAuth();
|
auth = new HttpBasicAuth();
|
||||||
|
} 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");
|
||||||
}
|
}
|
||||||
|
if (auth != null) {
|
||||||
addAuthorization(authName, auth);
|
addAuthorization(authName, auth);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,25 +53,21 @@ public class ApiClient {
|
|||||||
public ApiClient(String[] authNames) {
|
public ApiClient(String[] authNames) {
|
||||||
this();
|
this();
|
||||||
for(String authName : authNames) {
|
for(String authName : authNames) {
|
||||||
Interceptor auth;
|
Interceptor auth = null;
|
||||||
if ("petstore_auth".equals(authName)) {
|
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 if ("api_key".equals(authName)) {
|
} else if ("api_key".equals(authName)) {
|
||||||
|
|
||||||
auth = new ApiKeyAuth("header", "api_key");
|
auth = new ApiKeyAuth("header", "api_key");
|
||||||
} else if ("api_key_query".equals(authName)) {
|
} else if ("api_key_query".equals(authName)) {
|
||||||
|
|
||||||
auth = new ApiKeyAuth("query", "api_key_query");
|
auth = new ApiKeyAuth("query", "api_key_query");
|
||||||
} else if ("http_basic_test".equals(authName)) {
|
} else if ("http_basic_test".equals(authName)) {
|
||||||
|
|
||||||
auth = new HttpBasicAuth();
|
auth = new HttpBasicAuth();
|
||||||
|
} 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");
|
||||||
}
|
}
|
||||||
|
if (auth != null) {
|
||||||
addAuthorization(authName, auth);
|
addAuthorization(authName, auth);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,25 +53,21 @@ public class ApiClient {
|
|||||||
public ApiClient(String[] authNames) {
|
public ApiClient(String[] authNames) {
|
||||||
this();
|
this();
|
||||||
for(String authName : authNames) {
|
for(String authName : authNames) {
|
||||||
Interceptor auth;
|
Interceptor auth = null;
|
||||||
if ("petstore_auth".equals(authName)) {
|
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 if ("api_key".equals(authName)) {
|
} else if ("api_key".equals(authName)) {
|
||||||
|
|
||||||
auth = new ApiKeyAuth("header", "api_key");
|
auth = new ApiKeyAuth("header", "api_key");
|
||||||
} else if ("api_key_query".equals(authName)) {
|
} else if ("api_key_query".equals(authName)) {
|
||||||
|
|
||||||
auth = new ApiKeyAuth("query", "api_key_query");
|
auth = new ApiKeyAuth("query", "api_key_query");
|
||||||
} else if ("http_basic_test".equals(authName)) {
|
} else if ("http_basic_test".equals(authName)) {
|
||||||
|
|
||||||
auth = new HttpBasicAuth();
|
auth = new HttpBasicAuth();
|
||||||
|
} 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");
|
||||||
}
|
}
|
||||||
|
if (auth != null) {
|
||||||
addAuthorization(authName, auth);
|
addAuthorization(authName, auth);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,11 +72,16 @@ class ApiClient(
|
|||||||
authNames: Array<String>
|
authNames: Array<String>
|
||||||
) : this(baseUrl, okHttpClientBuilder) {
|
) : this(baseUrl, okHttpClientBuilder) {
|
||||||
authNames.forEach { authName ->
|
authNames.forEach { authName ->
|
||||||
val auth = when (authName) {
|
val auth = when (authName) {
|
||||||
"petstore_auth" -> OAuth(OAuthFlow.implicit, "http://petstore.swagger.io/api/oauth/dialog", "", "write:pets, read:pets")"api_key" -> ApiKeyAuth("header", "api_key")
|
"petstore_auth" -> OAuth(OAuthFlow.implicit, "http://petstore.swagger.io/api/oauth/dialog", "", "write:pets, read:pets")
|
||||||
|
|
||||||
|
"api_key" -> ApiKeyAuth("header", "api_key")
|
||||||
|
|
||||||
else -> throw RuntimeException("auth name $authName not found in available auth names")
|
else -> throw RuntimeException("auth name $authName not found in available auth names")
|
||||||
}
|
}
|
||||||
addAuthorization(authName, auth)
|
if (auth != null) {
|
||||||
|
addAuthorization(authName, auth)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,11 +74,16 @@ class ApiClient(
|
|||||||
authNames: Array<String>
|
authNames: Array<String>
|
||||||
) : this(baseUrl, okHttpClientBuilder, serializerBuilder) {
|
) : this(baseUrl, okHttpClientBuilder, serializerBuilder) {
|
||||||
authNames.forEach { authName ->
|
authNames.forEach { authName ->
|
||||||
val auth = when (authName) {
|
val auth = when (authName) {
|
||||||
"petstore_auth" -> OAuth(OAuthFlow.implicit, "http://petstore.swagger.io/api/oauth/dialog", "", "write:pets, read:pets")"api_key" -> ApiKeyAuth("header", "api_key")
|
"petstore_auth" -> OAuth(OAuthFlow.implicit, "http://petstore.swagger.io/api/oauth/dialog", "", "write:pets, read:pets")
|
||||||
|
|
||||||
|
"api_key" -> ApiKeyAuth("header", "api_key")
|
||||||
|
|
||||||
else -> throw RuntimeException("auth name $authName not found in available auth names")
|
else -> throw RuntimeException("auth name $authName not found in available auth names")
|
||||||
}
|
}
|
||||||
addAuthorization(authName, auth)
|
if (auth != null) {
|
||||||
|
addAuthorization(authName, auth)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,11 +72,16 @@ class ApiClient(
|
|||||||
authNames: Array<String>
|
authNames: Array<String>
|
||||||
) : this(baseUrl, okHttpClientBuilder, serializerBuilder) {
|
) : this(baseUrl, okHttpClientBuilder, serializerBuilder) {
|
||||||
authNames.forEach { authName ->
|
authNames.forEach { authName ->
|
||||||
val auth = when (authName) {
|
val auth = when (authName) {
|
||||||
"petstore_auth" -> OAuth(OAuthFlow.implicit, "http://petstore.swagger.io/api/oauth/dialog", "", "write:pets, read:pets")"api_key" -> ApiKeyAuth("header", "api_key")
|
"petstore_auth" -> OAuth(OAuthFlow.implicit, "http://petstore.swagger.io/api/oauth/dialog", "", "write:pets, read:pets")
|
||||||
|
|
||||||
|
"api_key" -> ApiKeyAuth("header", "api_key")
|
||||||
|
|
||||||
else -> throw RuntimeException("auth name $authName not found in available auth names")
|
else -> throw RuntimeException("auth name $authName not found in available auth names")
|
||||||
}
|
}
|
||||||
addAuthorization(authName, auth)
|
if (auth != null) {
|
||||||
|
addAuthorization(authName, auth)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,24 +35,30 @@ fun Route.PetApi() {
|
|||||||
|
|
||||||
authenticate("petstore_auth") {
|
authenticate("petstore_auth") {
|
||||||
post<Paths.addPet> {
|
post<Paths.addPet> {
|
||||||
|
|
||||||
val principal = call.authentication.principal<OAuthAccessTokenResponse>()!!
|
val principal = call.authentication.principal<OAuthAccessTokenResponse>()!!
|
||||||
|
|
||||||
|
|
||||||
call.respond(HttpStatusCode.NotImplemented)
|
call.respond(HttpStatusCode.NotImplemented)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
authenticate("petstore_auth") {
|
authenticate("petstore_auth") {
|
||||||
delete<Paths.deletePet> {
|
delete<Paths.deletePet> {
|
||||||
|
|
||||||
val principal = call.authentication.principal<OAuthAccessTokenResponse>()!!
|
val principal = call.authentication.principal<OAuthAccessTokenResponse>()!!
|
||||||
|
|
||||||
|
|
||||||
call.respond(HttpStatusCode.NotImplemented)
|
call.respond(HttpStatusCode.NotImplemented)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
authenticate("petstore_auth") {
|
authenticate("petstore_auth") {
|
||||||
get<Paths.findPetsByStatus> {
|
get<Paths.findPetsByStatus> {
|
||||||
|
|
||||||
val principal = call.authentication.principal<OAuthAccessTokenResponse>()!!
|
val principal = call.authentication.principal<OAuthAccessTokenResponse>()!!
|
||||||
|
|
||||||
|
|
||||||
val exampleContentType = "application/json"
|
val exampleContentType = "application/json"
|
||||||
val exampleContentString = """[ {
|
val exampleContentString = """[ {
|
||||||
"photoUrls" : [ "photoUrls", "photoUrls" ],
|
"photoUrls" : [ "photoUrls", "photoUrls" ],
|
||||||
@ -98,8 +104,10 @@ fun Route.PetApi() {
|
|||||||
|
|
||||||
authenticate("petstore_auth") {
|
authenticate("petstore_auth") {
|
||||||
get<Paths.findPetsByTags> {
|
get<Paths.findPetsByTags> {
|
||||||
|
|
||||||
val principal = call.authentication.principal<OAuthAccessTokenResponse>()!!
|
val principal = call.authentication.principal<OAuthAccessTokenResponse>()!!
|
||||||
|
|
||||||
|
|
||||||
val exampleContentType = "application/json"
|
val exampleContentType = "application/json"
|
||||||
val exampleContentString = """[ {
|
val exampleContentString = """[ {
|
||||||
"photoUrls" : [ "photoUrls", "photoUrls" ],
|
"photoUrls" : [ "photoUrls", "photoUrls" ],
|
||||||
@ -145,8 +153,10 @@ fun Route.PetApi() {
|
|||||||
|
|
||||||
authenticate("api_key") {
|
authenticate("api_key") {
|
||||||
get<Paths.getPetById> {
|
get<Paths.getPetById> {
|
||||||
|
|
||||||
val principal = call.authentication.principal<ApiPrincipal>()!!
|
val principal = call.authentication.principal<ApiPrincipal>()!!
|
||||||
|
|
||||||
|
|
||||||
val exampleContentType = "application/json"
|
val exampleContentType = "application/json"
|
||||||
val exampleContentString = """{
|
val exampleContentString = """{
|
||||||
"photoUrls" : [ "photoUrls", "photoUrls" ],
|
"photoUrls" : [ "photoUrls", "photoUrls" ],
|
||||||
@ -176,24 +186,30 @@ fun Route.PetApi() {
|
|||||||
|
|
||||||
authenticate("petstore_auth") {
|
authenticate("petstore_auth") {
|
||||||
put<Paths.updatePet> {
|
put<Paths.updatePet> {
|
||||||
|
|
||||||
val principal = call.authentication.principal<OAuthAccessTokenResponse>()!!
|
val principal = call.authentication.principal<OAuthAccessTokenResponse>()!!
|
||||||
|
|
||||||
|
|
||||||
call.respond(HttpStatusCode.NotImplemented)
|
call.respond(HttpStatusCode.NotImplemented)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
authenticate("petstore_auth") {
|
authenticate("petstore_auth") {
|
||||||
post<Paths.updatePetWithForm> {
|
post<Paths.updatePetWithForm> {
|
||||||
|
|
||||||
val principal = call.authentication.principal<OAuthAccessTokenResponse>()!!
|
val principal = call.authentication.principal<OAuthAccessTokenResponse>()!!
|
||||||
|
|
||||||
|
|
||||||
call.respond(HttpStatusCode.NotImplemented)
|
call.respond(HttpStatusCode.NotImplemented)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
authenticate("petstore_auth") {
|
authenticate("petstore_auth") {
|
||||||
post<Paths.uploadFile> {
|
post<Paths.uploadFile> {
|
||||||
|
|
||||||
val principal = call.authentication.principal<OAuthAccessTokenResponse>()!!
|
val principal = call.authentication.principal<OAuthAccessTokenResponse>()!!
|
||||||
|
|
||||||
|
|
||||||
val exampleContentType = "application/json"
|
val exampleContentType = "application/json"
|
||||||
val exampleContentString = """{
|
val exampleContentString = """{
|
||||||
"code" : 0,
|
"code" : 0,
|
||||||
|
@ -38,8 +38,10 @@ fun Route.StoreApi() {
|
|||||||
|
|
||||||
authenticate("api_key") {
|
authenticate("api_key") {
|
||||||
get<Paths.getInventory> {
|
get<Paths.getInventory> {
|
||||||
|
|
||||||
val principal = call.authentication.principal<ApiPrincipal>()!!
|
val principal = call.authentication.principal<ApiPrincipal>()!!
|
||||||
|
|
||||||
|
|
||||||
call.respond(HttpStatusCode.NotImplemented)
|
call.respond(HttpStatusCode.NotImplemented)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -35,24 +35,30 @@ fun Route.PetApi() {
|
|||||||
|
|
||||||
authenticate("petstore_auth") {
|
authenticate("petstore_auth") {
|
||||||
post<Paths.addPet> {
|
post<Paths.addPet> {
|
||||||
|
|
||||||
val principal = call.authentication.principal<OAuthAccessTokenResponse>()!!
|
val principal = call.authentication.principal<OAuthAccessTokenResponse>()!!
|
||||||
|
|
||||||
|
|
||||||
call.respond(HttpStatusCode.NotImplemented)
|
call.respond(HttpStatusCode.NotImplemented)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
authenticate("petstore_auth") {
|
authenticate("petstore_auth") {
|
||||||
delete<Paths.deletePet> {
|
delete<Paths.deletePet> {
|
||||||
|
|
||||||
val principal = call.authentication.principal<OAuthAccessTokenResponse>()!!
|
val principal = call.authentication.principal<OAuthAccessTokenResponse>()!!
|
||||||
|
|
||||||
|
|
||||||
call.respond(HttpStatusCode.NotImplemented)
|
call.respond(HttpStatusCode.NotImplemented)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
authenticate("petstore_auth") {
|
authenticate("petstore_auth") {
|
||||||
get<Paths.findPetsByStatus> {
|
get<Paths.findPetsByStatus> {
|
||||||
|
|
||||||
val principal = call.authentication.principal<OAuthAccessTokenResponse>()!!
|
val principal = call.authentication.principal<OAuthAccessTokenResponse>()!!
|
||||||
|
|
||||||
|
|
||||||
val exampleContentType = "application/json"
|
val exampleContentType = "application/json"
|
||||||
val exampleContentString = """[ {
|
val exampleContentString = """[ {
|
||||||
"photoUrls" : [ "photoUrls", "photoUrls" ],
|
"photoUrls" : [ "photoUrls", "photoUrls" ],
|
||||||
@ -98,8 +104,10 @@ fun Route.PetApi() {
|
|||||||
|
|
||||||
authenticate("petstore_auth") {
|
authenticate("petstore_auth") {
|
||||||
get<Paths.findPetsByTags> {
|
get<Paths.findPetsByTags> {
|
||||||
|
|
||||||
val principal = call.authentication.principal<OAuthAccessTokenResponse>()!!
|
val principal = call.authentication.principal<OAuthAccessTokenResponse>()!!
|
||||||
|
|
||||||
|
|
||||||
val exampleContentType = "application/json"
|
val exampleContentType = "application/json"
|
||||||
val exampleContentString = """[ {
|
val exampleContentString = """[ {
|
||||||
"photoUrls" : [ "photoUrls", "photoUrls" ],
|
"photoUrls" : [ "photoUrls", "photoUrls" ],
|
||||||
@ -145,8 +153,10 @@ fun Route.PetApi() {
|
|||||||
|
|
||||||
authenticate("api_key") {
|
authenticate("api_key") {
|
||||||
get<Paths.getPetById> {
|
get<Paths.getPetById> {
|
||||||
|
|
||||||
val principal = call.authentication.principal<ApiPrincipal>()!!
|
val principal = call.authentication.principal<ApiPrincipal>()!!
|
||||||
|
|
||||||
|
|
||||||
val exampleContentType = "application/json"
|
val exampleContentType = "application/json"
|
||||||
val exampleContentString = """{
|
val exampleContentString = """{
|
||||||
"photoUrls" : [ "photoUrls", "photoUrls" ],
|
"photoUrls" : [ "photoUrls", "photoUrls" ],
|
||||||
@ -176,24 +186,30 @@ fun Route.PetApi() {
|
|||||||
|
|
||||||
authenticate("petstore_auth") {
|
authenticate("petstore_auth") {
|
||||||
put<Paths.updatePet> {
|
put<Paths.updatePet> {
|
||||||
|
|
||||||
val principal = call.authentication.principal<OAuthAccessTokenResponse>()!!
|
val principal = call.authentication.principal<OAuthAccessTokenResponse>()!!
|
||||||
|
|
||||||
|
|
||||||
call.respond(HttpStatusCode.NotImplemented)
|
call.respond(HttpStatusCode.NotImplemented)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
authenticate("petstore_auth") {
|
authenticate("petstore_auth") {
|
||||||
post<Paths.updatePetWithForm> {
|
post<Paths.updatePetWithForm> {
|
||||||
|
|
||||||
val principal = call.authentication.principal<OAuthAccessTokenResponse>()!!
|
val principal = call.authentication.principal<OAuthAccessTokenResponse>()!!
|
||||||
|
|
||||||
|
|
||||||
call.respond(HttpStatusCode.NotImplemented)
|
call.respond(HttpStatusCode.NotImplemented)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
authenticate("petstore_auth") {
|
authenticate("petstore_auth") {
|
||||||
post<Paths.uploadFile> {
|
post<Paths.uploadFile> {
|
||||||
|
|
||||||
val principal = call.authentication.principal<OAuthAccessTokenResponse>()!!
|
val principal = call.authentication.principal<OAuthAccessTokenResponse>()!!
|
||||||
|
|
||||||
|
|
||||||
val exampleContentType = "application/json"
|
val exampleContentType = "application/json"
|
||||||
val exampleContentString = """{
|
val exampleContentString = """{
|
||||||
"code" : 0,
|
"code" : 0,
|
||||||
|
@ -38,8 +38,10 @@ fun Route.StoreApi() {
|
|||||||
|
|
||||||
authenticate("api_key") {
|
authenticate("api_key") {
|
||||||
get<Paths.getInventory> {
|
get<Paths.getInventory> {
|
||||||
|
|
||||||
val principal = call.authentication.principal<ApiPrincipal>()!!
|
val principal = call.authentication.principal<ApiPrincipal>()!!
|
||||||
|
|
||||||
|
|
||||||
call.respond(HttpStatusCode.NotImplemented)
|
call.respond(HttpStatusCode.NotImplemented)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user