[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
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
17 changed files with 112 additions and 75 deletions

View File

@ -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");
} }
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");

View File

@ -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");
} }
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");

View File

@ -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");

View File

@ -127,13 +127,19 @@ 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")
} }
if (auth != null) {
addAuthorization(authName, auth) addAuthorization(authName, auth)
} }
} }
}
{{#authMethods}} {{#authMethods}}
{{#isBasic}} {{#isBasic}}

View File

@ -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}}

View File

@ -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,9 +69,11 @@ 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");
} }
if (auth != null) {
addAuthorization(authName, auth); addAuthorization(authName, auth);
} }
} }
}
/** /**
* Basic constructor for single auth name * Basic constructor for single auth name

View File

@ -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,13 +70,14 @@ 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");
} }
if (auth != null) {
addAuthorization(authName, auth); addAuthorization(authName, auth);
} }
} }
}
/** /**
* Basic constructor for single auth name * Basic constructor for single auth name

View File

@ -52,27 +52,23 @@ 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);
} }
} }
}
/** /**
* Basic constructor for single auth name * Basic constructor for single auth name

View File

@ -53,27 +53,23 @@ 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);
} }
} }
}
/** /**
* Basic constructor for single auth name * Basic constructor for single auth name

View File

@ -53,27 +53,23 @@ 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);
} }
} }
}
/** /**
* Basic constructor for single auth name * Basic constructor for single auth name

View File

@ -73,12 +73,17 @@ class ApiClient(
) : 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")
} }
if (auth != null) {
addAuthorization(authName, auth) addAuthorization(authName, auth)
} }
} }
}
constructor( constructor(
baseUrl: String = defaultBasePath, baseUrl: String = defaultBasePath,

View File

@ -75,12 +75,17 @@ class ApiClient(
) : 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")
} }
if (auth != null) {
addAuthorization(authName, auth) addAuthorization(authName, auth)
} }
} }
}
constructor( constructor(
baseUrl: String = defaultBasePath, baseUrl: String = defaultBasePath,

View File

@ -73,12 +73,17 @@ class ApiClient(
) : 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")
} }
if (auth != null) {
addAuthorization(authName, auth) addAuthorization(authName, auth)
} }
} }
}
constructor( constructor(
baseUrl: String = defaultBasePath, baseUrl: String = defaultBasePath,

View File

@ -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,

View File

@ -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)
} }
} }

View File

@ -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,

View File

@ -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)
} }
} }