Merge remote-tracking branch 'origin' into 7.0.x

This commit is contained in:
William Cheng
2023-03-03 21:52:50 +08:00
10595 changed files with 418520 additions and 73194 deletions

View File

@@ -70,13 +70,6 @@ Class | Method | HTTP request | Description
<a name="documentation-for-authorization"></a>
## Documentation for Authorization
<a name="api_key"></a>
### api_key
- **Type**: API key
- **API key parameter name**: api_key
- **Location**: HTTP header
<a name="petstore_auth"></a>
### petstore_auth
@@ -87,3 +80,10 @@ Class | Method | HTTP request | Description
- write:pets: modify pets in your account
- read:pets: read your pets
<a name="api_key"></a>
### api_key
- **Type**: API key
- **API key parameter name**: api_key
- **Location**: HTTP header

View File

@@ -85,13 +85,6 @@ Class | Method | HTTP request | Description
<a name="documentation-for-authorization"></a>
## Documentation for Authorization
<a name="api_key"></a>
### api_key
- **Type**: API key
- **API key parameter name**: api_key
- **Location**: HTTP header
<a name="petstore_auth"></a>
### petstore_auth
@@ -102,3 +95,10 @@ Class | Method | HTTP request | Description
- write:pets: modify pets in your account
- read:pets: read your pets
<a name="api_key"></a>
### api_key
- **Type**: API key
- **API key parameter name**: api_key
- **Location**: HTTP header

View File

@@ -47,6 +47,14 @@ fun Application.main() {
install(HSTS, ApplicationHstsConfiguration()) // see https://ktor.io/docs/hsts.html
install(Locations) // see https://ktor.io/docs/features-locations.html
install(Authentication) {
oauth("petstore_auth") {
client = HttpClient(Apache)
providerLookup = { ApplicationAuthProviders["petstore_auth"] }
urlProvider = { _ ->
// TODO: define a callback url here.
"/"
}
}
// "Implement API key auth (api_key) for parameter name 'api_key'."
apiKeyAuth("api_key") {
validate { apikeyCredential: ApiKeyCredential ->
@@ -56,14 +64,6 @@ fun Application.main() {
}
}
}
oauth("petstore_auth") {
client = HttpClient(Apache)
providerLookup = { ApplicationAuthProviders["petstore_auth"] }
urlProvider = { _ ->
// TODO: define a callback url here.
"/"
}
}
}
install(Routing) {
PetApi()

View File

@@ -57,7 +57,7 @@ val ApplicationAuthProviders: Map<String, OAuthServerSettings> = listOf<OAuthSer
clientId = settings.property("auth.oauth.petstore_auth.clientId").getString(),
clientSecret = settings.property("auth.oauth.petstore_auth.clientSecret").getString(),
defaultScopes = listOf("write:pets", "read:pets")
)
),
// OAuthServerSettings.OAuth2ServerSettings(
// name = "facebook",
// authorizeUrl = "https://graph.facebook.com/oauth/authorize",

View File

@@ -92,7 +92,7 @@ object Paths {
/**
* Find purchase order by ID
* For valid response try integer IDs with value &lt;&#x3D; 5 or &gt; 10. Other values will generated exceptions
* For valid response try integer IDs with value &lt;&#x3D; 5 or &gt; 10. Other values will generate exceptions
* @param orderId ID of pet that needs to be fetched
*/
@Location("/store/order/{orderId}") class getOrderById(val orderId: kotlin.Long)

View File

@@ -49,7 +49,7 @@ fun Route.PetApi() {
val principal = call.authentication.principal<OAuthAccessTokenResponse>()!!
val exampleContentType = "application/json"
val exampleContentString = """{
val exampleContentString = """[ {
"photoUrls" : [ "photoUrls", "photoUrls" ],
"name" : "doggie",
"id" : 0,
@@ -65,7 +65,23 @@ fun Route.PetApi() {
"id" : 1
} ],
"status" : "available"
}"""
}, {
"photoUrls" : [ "photoUrls", "photoUrls" ],
"name" : "doggie",
"id" : 0,
"category" : {
"name" : "name",
"id" : 6
},
"tags" : [ {
"name" : "name",
"id" : 1
}, {
"name" : "name",
"id" : 1
} ],
"status" : "available"
} ]"""
when (exampleContentType) {
"application/json" -> call.respond(gson.fromJson(exampleContentString, empty::class.java))
@@ -80,7 +96,7 @@ fun Route.PetApi() {
val principal = call.authentication.principal<OAuthAccessTokenResponse>()!!
val exampleContentType = "application/json"
val exampleContentString = """{
val exampleContentString = """[ {
"photoUrls" : [ "photoUrls", "photoUrls" ],
"name" : "doggie",
"id" : 0,
@@ -96,7 +112,23 @@ fun Route.PetApi() {
"id" : 1
} ],
"status" : "available"
}"""
}, {
"photoUrls" : [ "photoUrls", "photoUrls" ],
"name" : "doggie",
"id" : 0,
"category" : {
"name" : "name",
"id" : 6
},
"tags" : [ {
"name" : "name",
"id" : 1
}, {
"name" : "name",
"id" : 1
} ],
"status" : "available"
} ]"""
when (exampleContentType) {
"application/json" -> call.respond(gson.fromJson(exampleContentString, empty::class.java))