-
-
Notifications
You must be signed in to change notification settings - Fork 6.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support library option via additionalProperties (#16242)
* set library option obtain from additionalProperties * test library * update samples * remove old files
- Loading branch information
Showing
127 changed files
with
3,587 additions
and
609 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
generatorName: java | ||
outputDir: samples/client/petstore/java/resteasy | ||
library: resteasy | ||
inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml | ||
templateDir: modules/openapi-generator/src/main/resources/Java | ||
additionalProperties: | ||
artifactId: petstore-resteasy | ||
hideGenerationTimestamp: "true" | ||
library: resteasy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
...ple-string-multiplatform/src/commonMain/kotlin/org/openapitools/client/apis/DefaultApi.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
/** | ||
* | ||
* Please note: | ||
* This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). | ||
* Do not edit this file manually. | ||
* | ||
*/ | ||
|
||
@file:Suppress( | ||
"ArrayInDataClass", | ||
"EnumEntryName", | ||
"RemoveRedundantQualifierName", | ||
"UnusedImport" | ||
) | ||
|
||
package org.openapitools.client.apis | ||
|
||
|
||
import org.openapitools.client.infrastructure.* | ||
import io.ktor.client.HttpClientConfig | ||
import io.ktor.client.request.forms.formData | ||
import io.ktor.client.engine.HttpClientEngine | ||
import kotlinx.serialization.json.Json | ||
import io.ktor.http.ParametersBuilder | ||
import kotlinx.serialization.* | ||
import kotlinx.serialization.descriptors.* | ||
import kotlinx.serialization.encoding.* | ||
|
||
open class DefaultApi( | ||
baseUrl: String = ApiClient.BASE_URL, | ||
httpClientEngine: HttpClientEngine? = null, | ||
httpClientConfig: ((HttpClientConfig<*>) -> Unit)? = null, | ||
jsonSerializer: Json = ApiClient.JSON_DEFAULT | ||
) : ApiClient(baseUrl, httpClientEngine, httpClientConfig, jsonSerializer) { | ||
|
||
/** | ||
* | ||
* | ||
* @param ids | ||
* @return void | ||
*/ | ||
open suspend fun idsGet(ids: kotlin.collections.List<kotlin.String>): HttpResponse<Unit> { | ||
|
||
val localVariableAuthNames = listOf<String>() | ||
|
||
val localVariableBody = | ||
io.ktor.client.utils.EmptyContent | ||
|
||
val localVariableQuery = mutableMapOf<String, List<String>>() | ||
val localVariableHeaders = mutableMapOf<String, String>() | ||
|
||
val localVariableConfig = RequestConfig<kotlin.Any?>( | ||
RequestMethod.GET, | ||
"/{ids}".replace("{" + "ids" + "}", ids.joinToString(",")), | ||
query = localVariableQuery, | ||
headers = localVariableHeaders, | ||
requiresAuthentication = false, | ||
) | ||
|
||
return request( | ||
localVariableConfig, | ||
localVariableBody, | ||
localVariableAuthNames | ||
).wrap() | ||
} | ||
|
||
|
||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
...al-default-multiplatform/src/commonMain/kotlin/org/openapitools/client/apis/DefaultApi.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/** | ||
* | ||
* Please note: | ||
* This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). | ||
* Do not edit this file manually. | ||
* | ||
*/ | ||
|
||
@file:Suppress( | ||
"ArrayInDataClass", | ||
"EnumEntryName", | ||
"RemoveRedundantQualifierName", | ||
"UnusedImport" | ||
) | ||
|
||
package org.openapitools.client.apis | ||
|
||
import org.openapitools.client.models.Apa | ||
|
||
import org.openapitools.client.infrastructure.* | ||
import io.ktor.client.HttpClientConfig | ||
import io.ktor.client.request.forms.formData | ||
import io.ktor.client.engine.HttpClientEngine | ||
import kotlinx.serialization.json.Json | ||
import io.ktor.http.ParametersBuilder | ||
import kotlinx.serialization.* | ||
import kotlinx.serialization.descriptors.* | ||
import kotlinx.serialization.encoding.* | ||
|
||
open class DefaultApi( | ||
baseUrl: String = ApiClient.BASE_URL, | ||
httpClientEngine: HttpClientEngine? = null, | ||
httpClientConfig: ((HttpClientConfig<*>) -> Unit)? = null, | ||
jsonSerializer: Json = ApiClient.JSON_DEFAULT | ||
) : ApiClient(baseUrl, httpClientEngine, httpClientConfig, jsonSerializer) { | ||
|
||
/** | ||
* | ||
* | ||
* @param apa | ||
* @return void | ||
*/ | ||
open suspend fun testPost(apa: Apa): HttpResponse<Unit> { | ||
|
||
val localVariableAuthNames = listOf<String>() | ||
|
||
val localVariableBody = apa | ||
|
||
val localVariableQuery = mutableMapOf<String, List<String>>() | ||
val localVariableHeaders = mutableMapOf<String, String>() | ||
|
||
val localVariableConfig = RequestConfig<kotlin.Any?>( | ||
RequestMethod.POST, | ||
"/test", | ||
query = localVariableQuery, | ||
headers = localVariableHeaders, | ||
requiresAuthentication = false, | ||
) | ||
|
||
return jsonRequest( | ||
localVariableConfig, | ||
localVariableBody, | ||
localVariableAuthNames | ||
).wrap() | ||
} | ||
|
||
|
||
|
||
} |
16 changes: 16 additions & 0 deletions
16
...al-default-multiplatform/src/commonMain/kotlin/org/openapitools/client/auth/ApiKeyAuth.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package org.openapitools.client.auth | ||
|
||
class ApiKeyAuth(private val location: String, val paramName: String) : Authentication { | ||
var apiKey: String? = null | ||
var apiKeyPrefix: String? = null | ||
|
||
override fun apply(query: MutableMap<String, List<String>>, headers: MutableMap<String, String>) { | ||
val key: String = apiKey ?: return | ||
val prefix: String? = apiKeyPrefix | ||
val value: String = if (prefix != null) "$prefix $key" else key | ||
when (location) { | ||
"query" -> query[paramName] = listOf(value) | ||
"header" -> headers[paramName] = value | ||
} | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
...efault-multiplatform/src/commonMain/kotlin/org/openapitools/client/auth/Authentication.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package org.openapitools.client.auth | ||
|
||
interface Authentication { | ||
|
||
/** | ||
* Apply authentication settings to header and query params. | ||
* | ||
* @param query Query parameters. | ||
* @param headers Header parameters. | ||
*/ | ||
fun apply(query: MutableMap<String, List<String>>, headers: MutableMap<String, String>) | ||
|
||
} |
17 changes: 17 additions & 0 deletions
17
...default-multiplatform/src/commonMain/kotlin/org/openapitools/client/auth/HttpBasicAuth.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package org.openapitools.client.auth | ||
|
||
import io.ktor.util.InternalAPI | ||
import io.ktor.util.encodeBase64 | ||
|
||
class HttpBasicAuth : Authentication { | ||
var username: String? = null | ||
var password: String? = null | ||
|
||
@OptIn(InternalAPI::class) | ||
override fun apply(query: MutableMap<String, List<String>>, headers: MutableMap<String, String>) { | ||
if (username == null && password == null) return | ||
val str = (username ?: "") + ":" + (password ?: "") | ||
val auth = str.encodeBase64() | ||
headers["Authorization"] = "Basic $auth" | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
...efault-multiplatform/src/commonMain/kotlin/org/openapitools/client/auth/HttpBearerAuth.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package org.openapitools.client.auth | ||
|
||
class HttpBearerAuth(private val scheme: String?) : Authentication { | ||
var bearerToken: String? = null | ||
|
||
override fun apply(query: MutableMap<String, List<String>>, headers: MutableMap<String, String>) { | ||
val token: String = bearerToken ?: return | ||
headers["Authorization"] = (if (scheme != null) upperCaseBearer(scheme)!! + " " else "") + token | ||
} | ||
|
||
private fun upperCaseBearer(scheme: String): String? { | ||
return if ("bearer".equals(scheme, ignoreCase = true)) "Bearer" else scheme | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
...decimal-default-multiplatform/src/commonMain/kotlin/org/openapitools/client/auth/OAuth.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package org.openapitools.client.auth | ||
|
||
class OAuth : Authentication { | ||
var accessToken: String? = null | ||
|
||
override fun apply(query: MutableMap<String, List<String>>, headers: MutableMap<String, String>) { | ||
val token: String = accessToken ?: return | ||
headers["Authorization"] = "Bearer $token" | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
...iplatform/src/commonMain/kotlin/org/openapitools/client/infrastructure/ApiAbstractions.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package org.openapitools.client.infrastructure | ||
|
||
typealias MultiValueMap = MutableMap<String,List<String>> | ||
|
||
fun collectionDelimiter(collectionFormat: String) = when(collectionFormat) { | ||
"csv" -> "," | ||
"tsv" -> "\t" | ||
"pipe" -> "|" | ||
"space" -> " " | ||
else -> "" | ||
} | ||
|
||
val defaultMultiValueConverter: (item: Any?) -> String = { item -> "$item" } | ||
|
||
fun <T : Any?> toMultiValue(items: Array<T>, collectionFormat: String, map: (item: T) -> String = defaultMultiValueConverter) | ||
= toMultiValue(items.asIterable(), collectionFormat, map) | ||
|
||
fun <T : Any?> toMultiValue(items: Iterable<T>, collectionFormat: String, map: (item: T) -> String = defaultMultiValueConverter): List<String> { | ||
return when(collectionFormat) { | ||
"multi" -> items.map(map) | ||
else -> listOf(items.joinToString(separator = collectionDelimiter(collectionFormat), transform = map)) | ||
} | ||
} |
Oops, something went wrong.