forked from loafle/openapi-generator-original
Kotlin multiplatform auth (#4284)
* Includes support for the Javascript platform * Fixes enum serialization with non-string values * Updates to expose api dependencies to consumers * Uses explicit class name for Kotlin collection classes * Maps unknown object type to Kotlin String The Kotlinx serialization library uses reflectionless serialization and requires compile-time serialization declarations. As a result, unknown objects are mapped to Kotlin String instances to enable compilation where object types are not explicitly defined. * Improves support for binary objects Previously, objects that contained binary data were assigned the InputProvider data type. This was suitable for a binary input form parameter, but unsuitable for Base64 or octet binary strings. These binary strings are now assigned a more suitable object. * Includes Kotlin Multiplatform auth classes Includes support for: - api key - http basic - http bearer - oauth (partial support) https://github.com/OpenAPITools/openapi-generator/issues/4283 * Updates Kotlin samples
This commit is contained in:
parent
0f2272d9a4
commit
d92d84bb12
@ -21,6 +21,7 @@ import org.openapitools.codegen.CliOption;
|
||||
import org.openapitools.codegen.CodegenConstants;
|
||||
import org.openapitools.codegen.CodegenModel;
|
||||
import org.openapitools.codegen.CodegenOperation;
|
||||
import org.openapitools.codegen.CodegenParameter;
|
||||
import org.openapitools.codegen.CodegenProperty;
|
||||
import org.openapitools.codegen.CodegenType;
|
||||
import org.openapitools.codegen.SupportingFile;
|
||||
@ -192,29 +193,48 @@ public class KotlinClientCodegen extends AbstractKotlinCodegen {
|
||||
|
||||
// multiplatform default includes
|
||||
defaultIncludes.add("io.ktor.client.request.forms.InputProvider");
|
||||
defaultIncludes.add(packageName + ".infrastructure.Base64ByteArray");
|
||||
defaultIncludes.add(packageName + ".infrastructure.OctetByteArray");
|
||||
|
||||
// multiplatform type mapping
|
||||
typeMapping.put("number", "kotlin.Double");
|
||||
typeMapping.put("file", "InputProvider");
|
||||
typeMapping.put("file", "OctetByteArray");
|
||||
typeMapping.put("binary", "OctetByteArray");
|
||||
typeMapping.put("ByteArray", "Base64ByteArray");
|
||||
typeMapping.put("object", "kotlin.String"); // kotlin.Any not serializable
|
||||
|
||||
// multiplatform import mapping
|
||||
importMapping.put("BigDecimal", "kotlin.Double");
|
||||
importMapping.put("UUID", "kotlin.String");
|
||||
importMapping.put("URI", "kotlin.String");
|
||||
importMapping.put("InputProvider", "io.ktor.client.request.forms.InputProvider");
|
||||
importMapping.put("File", "io.ktor.client.request.forms.InputProvider");
|
||||
importMapping.put("File", packageName + ".infrastructure.OctetByteArray");
|
||||
importMapping.put("Timestamp", "kotlin.String");
|
||||
importMapping.put("LocalDateTime", "kotlin.String");
|
||||
importMapping.put("LocalDate", "kotlin.String");
|
||||
importMapping.put("LocalTime", "kotlin.String");
|
||||
importMapping.put("Base64ByteArray", packageName + ".infrastructure.Base64ByteArray");
|
||||
importMapping.put("OctetByteArray", packageName + ".infrastructure.OctetByteArray");
|
||||
|
||||
// multiplatform specific supporting files
|
||||
supportingFiles.add(new SupportingFile("infrastructure/Base64ByteArray.kt.mustache", infrastructureFolder, "Base64ByteArray.kt"));
|
||||
supportingFiles.add(new SupportingFile("infrastructure/Bytes.kt.mustache", infrastructureFolder, "Bytes.kt"));
|
||||
supportingFiles.add(new SupportingFile("infrastructure/HttpResponse.kt.mustache", infrastructureFolder, "HttpResponse.kt"));
|
||||
supportingFiles.add(new SupportingFile("infrastructure/OctetByteArray.kt.mustache", infrastructureFolder, "OctetByteArray.kt"));
|
||||
|
||||
// multiplatform specific auth
|
||||
final String authFolder = (sourceFolder + File.separator + packageName + File.separator + "auth").replace(".", "/");
|
||||
supportingFiles.add(new SupportingFile("auth/ApiKeyAuth.kt.mustache", authFolder, "ApiKeyAuth.kt"));
|
||||
supportingFiles.add(new SupportingFile("auth/Authentication.kt.mustache", authFolder, "Authentication.kt"));
|
||||
supportingFiles.add(new SupportingFile("auth/HttpBasicAuth.kt.mustache", authFolder, "HttpBasicAuth.kt"));
|
||||
supportingFiles.add(new SupportingFile("auth/HttpBearerAuth.kt.mustache", authFolder, "HttpBearerAuth.kt"));
|
||||
supportingFiles.add(new SupportingFile("auth/OAuth.kt.mustache", authFolder, "OAuth.kt"));
|
||||
|
||||
// multiplatform specific testing files
|
||||
supportingFiles.add(new SupportingFile("commonTest/coroutine.mustache", "src/commonTest/kotlin/util", "Coroutine.kt"));
|
||||
supportingFiles.add(new SupportingFile("iosTest/coroutine.mustache", "src/iosTest/kotlin/util", "Coroutine.kt"));
|
||||
supportingFiles.add(new SupportingFile("jvmTest/coroutine.mustache", "src/jvmTest/kotlin/util", "Coroutine.kt"));
|
||||
supportingFiles.add(new SupportingFile("commonTest/Coroutine.kt.mustache", "src/commonTest/kotlin/util", "Coroutine.kt"));
|
||||
supportingFiles.add(new SupportingFile("iosTest/Coroutine.kt.mustache", "src/iosTest/kotlin/util", "Coroutine.kt"));
|
||||
supportingFiles.add(new SupportingFile("jsTest/Coroutine.kt.mustache", "src/jsTest/kotlin/util", "Coroutine.kt"));
|
||||
supportingFiles.add(new SupportingFile("jvmTest/Coroutine.kt.mustache", "src/jvmTest/kotlin/util", "Coroutine.kt"));
|
||||
|
||||
// gradle wrapper supporting files
|
||||
supportingFiles.add(new SupportingFile("gradlew.mustache", "", "gradlew"));
|
||||
@ -290,11 +310,22 @@ public class KotlinClientCodegen extends AbstractKotlinCodegen {
|
||||
if (operations != null) {
|
||||
List<CodegenOperation> ops = (List<CodegenOperation>) operations.get("operation");
|
||||
for (CodegenOperation operation : ops) {
|
||||
|
||||
// set multipart against all relevant operations
|
||||
if (operation.hasConsumes == Boolean.TRUE) {
|
||||
if (isMultipartType(operation.consumes)) {
|
||||
operation.isMultipart = Boolean.TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
// modify the data type of binary form parameters to a more friendly type for multiplatform builds
|
||||
if (MULTIPLATFORM.equals(getLibrary()) && operation.allParams != null) {
|
||||
for (CodegenParameter param : operation.allParams) {
|
||||
if (param.dataFormat != null && param.dataFormat.equals("binary")) {
|
||||
param.baseType = param.dataType = "io.ktor.client.request.forms.InputProvider";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return operations;
|
||||
|
@ -29,7 +29,7 @@ import {{packageName}}.infrastructure.toMultiValue
|
||||
@Suppress("UNCHECKED_CAST"){{/returnType}}
|
||||
fun {{operationId}}({{#allParams}}{{paramName}}: {{{dataType}}}{{^required}}?{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) : {{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Unit{{/returnType}} {
|
||||
val localVariableBody: kotlin.Any? = {{#hasBodyParam}}{{#bodyParams}}{{paramName}}{{/bodyParams}}{{/hasBodyParam}}{{^hasBodyParam}}{{^hasFormParams}}null{{/hasFormParams}}{{#hasFormParams}}mapOf({{#formParams}}"{{{baseName}}}" to "${{paramName}}"{{#hasMore}}, {{/hasMore}}{{/formParams}}){{/hasFormParams}}{{/hasBodyParam}}
|
||||
val localVariableQuery: MultiValueMap = {{^hasQueryParams}}mapOf()
|
||||
val localVariableQuery: MultiValueMap = {{^hasQueryParams}}mutableMapOf()
|
||||
{{/hasQueryParams}}{{#hasQueryParams}}mutableMapOf<kotlin.String, List<kotlin.String>>()
|
||||
.apply {
|
||||
{{#queryParams}}
|
||||
|
@ -71,7 +71,7 @@ import java.io.Serializable
|
||||
{{/allowableValues}}
|
||||
{{#multiplatform}}
|
||||
|
||||
{{#nonPublicApi}}internal {{/nonPublicApi}}object Serializer : CommonEnumSerializer<{{nameInCamelCase}}>("{{nameInCamelCase}}", values(), values().map { it.value }.toTypedArray())
|
||||
{{#nonPublicApi}}internal {{/nonPublicApi}}object Serializer : CommonEnumSerializer<{{nameInCamelCase}}>("{{nameInCamelCase}}", values(), values().map { it.value.toString() }.toTypedArray())
|
||||
{{/multiplatform}}
|
||||
}
|
||||
{{/isEnum}}
|
||||
|
@ -42,6 +42,6 @@ import kotlinx.serialization.internal.CommonEnumSerializer
|
||||
{{/enumVars}}{{/allowableValues}}
|
||||
|
||||
{{#multiplatform}}
|
||||
{{#nonPublicApi}}internal {{/nonPublicApi}}object Serializer : CommonEnumSerializer<{{classname}}>("{{classname}}", values(), values().map { it.value }.toTypedArray())
|
||||
{{#nonPublicApi}}internal {{/nonPublicApi}}object Serializer : CommonEnumSerializer<{{classname}}>("{{classname}}", values(), values().map { it.value.toString() }.toTypedArray())
|
||||
{{/multiplatform}}
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
package {{packageName}}.infrastructure
|
||||
|
||||
typealias MultiValueMap = Map<String,List<String>>
|
||||
typealias MultiValueMap = MutableMap<String,List<String>>
|
||||
|
||||
{{#nonPublicApi}}internal {{/nonPublicApi}}fun collectionDelimiter(collectionFormat: String) = when(collectionFormat) {
|
||||
"csv" -> ","
|
||||
|
@ -12,5 +12,5 @@ package {{packageName}}.infrastructure
|
||||
val method: RequestMethod,
|
||||
val path: String,
|
||||
val headers: MutableMap<String, String> = mutableMapOf(),
|
||||
val query: Map<String, List<String>> = mapOf()
|
||||
val query: MutableMap<String, List<String>> = mutableMapOf()
|
||||
)
|
@ -41,6 +41,8 @@ import kotlinx.serialization.internal.StringDescriptor
|
||||
{{/returnType}}
|
||||
suspend fun {{operationId}}({{#allParams}}{{paramName}}: {{{dataType}}}{{^required}}?{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) : HttpResponse<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Unit{{/returnType}}> {
|
||||
|
||||
val localVariableAuthNames = listOf<String>({{#authMethods}}"{{name}}"{{#hasMore}}, {{/hasMore}}{{/authMethods}})
|
||||
|
||||
val localVariableBody = {{#hasBodyParam}}{{#bodyParam}}{{#isListContainer}}{{operationIdCamelCase}}Request({{paramName}}.asList()){{/isListContainer}}{{^isListContainer}}{{#isMapContainer}}{{operationIdCamelCase}}Request({{paramName}}){{/isMapContainer}}{{^isMapContainer}}{{paramName}}{{/isMapContainer}}{{/isListContainer}}{{/bodyParam}}{{/hasBodyParam}}
|
||||
{{^hasBodyParam}}
|
||||
{{#hasFormParams}}
|
||||
@ -83,7 +85,8 @@ import kotlinx.serialization.internal.StringDescriptor
|
||||
|
||||
return {{#hasBodyParam}}jsonRequest{{/hasBodyParam}}{{^hasBodyParam}}{{#hasFormParams}}{{#isMultipart}}multipartFormRequest{{/isMultipart}}{{^isMultipart}}urlEncodedFormRequest{{/isMultipart}}{{/hasFormParams}}{{^hasFormParams}}request{{/hasFormParams}}{{/hasBodyParam}}(
|
||||
localVariableConfig,
|
||||
localVariableBody
|
||||
localVariableBody,
|
||||
localVariableAuthNames
|
||||
).{{#isListContainer}}wrap<{{operationIdCamelCase}}Response>().map { value.toTypedArray() }{{/isListContainer}}{{^isListContainer}}{{#isMapContainer}}wrap<{{operationIdCamelCase}}Response>().map { value }{{/isMapContainer}}{{^isMapContainer}}wrap(){{/isMapContainer}}{{/isListContainer}}
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,16 @@
|
||||
package {{packageName}}.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
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
package {{packageName}}.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>)
|
||||
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
package {{packageName}}.auth
|
||||
|
||||
import io.ktor.util.InternalAPI
|
||||
import io.ktor.util.encodeBase64
|
||||
|
||||
class HttpBasicAuth : Authentication {
|
||||
var username: String? = null
|
||||
var password: String? = null
|
||||
|
||||
@InternalAPI
|
||||
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"
|
||||
}
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
package {{packageName}}.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
|
||||
}
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
package {{packageName}}.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"
|
||||
}
|
||||
}
|
@ -30,6 +30,7 @@ kotlin {
|
||||
jvm()
|
||||
iosArm64() { binaries { framework { freeCompilerArgs.add("-Xobjc-generics") } } }
|
||||
iosX64() { binaries { framework { freeCompilerArgs.add("-Xobjc-generics") } } }
|
||||
js()
|
||||
|
||||
sourceSets {
|
||||
commonMain {
|
||||
@ -37,9 +38,9 @@ kotlin {
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-common:$kotlin_version"
|
||||
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core-common:$coroutines_version"
|
||||
implementation "org.jetbrains.kotlinx:kotlinx-serialization-runtime-common:$serialization_version"
|
||||
implementation "io.ktor:ktor-client-core:$ktor_version"
|
||||
implementation "io.ktor:ktor-client-json:$ktor_version"
|
||||
implementation "io.ktor:ktor-client-serialization:$ktor_version"
|
||||
api "io.ktor:ktor-client-core:$ktor_version"
|
||||
api "io.ktor:ktor-client-json:$ktor_version"
|
||||
api "io.ktor:ktor-client-serialization:$ktor_version"
|
||||
}
|
||||
}
|
||||
|
||||
@ -57,9 +58,9 @@ kotlin {
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
|
||||
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version"
|
||||
implementation "org.jetbrains.kotlinx:kotlinx-serialization-runtime:$serialization_version"
|
||||
implementation "io.ktor:ktor-client-core-jvm:$ktor_version"
|
||||
implementation "io.ktor:ktor-client-json-jvm:$ktor_version"
|
||||
implementation "io.ktor:ktor-client-serialization-jvm:$ktor_version"
|
||||
api "io.ktor:ktor-client-core-jvm:$ktor_version"
|
||||
api "io.ktor:ktor-client-json-jvm:$ktor_version"
|
||||
api "io.ktor:ktor-client-serialization-jvm:$ktor_version"
|
||||
}
|
||||
}
|
||||
|
||||
@ -77,7 +78,7 @@ kotlin {
|
||||
dependencies {
|
||||
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core-native:$coroutines_version"
|
||||
implementation "org.jetbrains.kotlinx:kotlinx-serialization-runtime-native:$serialization_version"
|
||||
implementation "io.ktor:ktor-client-ios:$ktor_version"
|
||||
api "io.ktor:ktor-client-ios:$ktor_version"
|
||||
}
|
||||
}
|
||||
|
||||
@ -91,9 +92,9 @@ kotlin {
|
||||
iosArm64().compilations.main.defaultSourceSet {
|
||||
dependsOn iosMain
|
||||
dependencies {
|
||||
implementation "io.ktor:ktor-client-ios-iosarm64:$ktor_version"
|
||||
implementation "io.ktor:ktor-client-json-iosarm64:$ktor_version"
|
||||
implementation "io.ktor:ktor-client-serialization-iosarm64:$ktor_version"
|
||||
api "io.ktor:ktor-client-ios-iosarm64:$ktor_version"
|
||||
api "io.ktor:ktor-client-json-iosarm64:$ktor_version"
|
||||
api "io.ktor:ktor-client-serialization-iosarm64:$ktor_version"
|
||||
}
|
||||
}
|
||||
|
||||
@ -104,9 +105,31 @@ kotlin {
|
||||
iosX64().compilations.main.defaultSourceSet {
|
||||
dependsOn iosMain
|
||||
dependencies {
|
||||
implementation "io.ktor:ktor-client-ios-iosx64:$ktor_version"
|
||||
implementation "io.ktor:ktor-client-json-iosx64:$ktor_version"
|
||||
implementation "io.ktor:ktor-client-serialization-iosx64:$ktor_version"
|
||||
api "io.ktor:ktor-client-ios-iosx64:$ktor_version"
|
||||
api "io.ktor:ktor-client-json-iosx64:$ktor_version"
|
||||
api "io.ktor:ktor-client-serialization-iosx64:$ktor_version"
|
||||
}
|
||||
}
|
||||
|
||||
jsMain {
|
||||
dependsOn commonMain
|
||||
dependencies {
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-js:$kotlin_version"
|
||||
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core-js:$coroutines_version"
|
||||
implementation "org.jetbrains.kotlinx:kotlinx-serialization-runtime-js:$serialization_version"
|
||||
api "io.ktor:ktor-client-js:$ktor_version"
|
||||
api "io.ktor:ktor-client-json-js:$ktor_version"
|
||||
api "io.ktor:ktor-client-serialization-js:$ktor_version"
|
||||
}
|
||||
}
|
||||
|
||||
jsTest {
|
||||
dependsOn commonTest
|
||||
dependencies {
|
||||
implementation "io.ktor:ktor-client-mock-js:$ktor_version"
|
||||
implementation "io.ktor:ktor-client-js:$ktor_version"
|
||||
implementation "io.ktor:ktor-client-json:$ktor_version"
|
||||
implementation "io.ktor:ktor-client-serialization-js:$ktor_version"
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -23,6 +23,7 @@ import kotlinx.serialization.json.JsonConfiguration
|
||||
|
||||
import {{apiPackage}}.*
|
||||
import {{modelPackage}}.*
|
||||
import {{packageName}}.auth.*
|
||||
|
||||
{{#nonPublicApi}}internal {{/nonPublicApi}}open class ApiClient(
|
||||
private val baseUrl: String,
|
||||
@ -46,6 +47,14 @@ import {{modelPackage}}.*
|
||||
httpClientEngine?.let { HttpClient(it, clientConfig) } ?: HttpClient(clientConfig)
|
||||
}
|
||||
|
||||
private val authentications: kotlin.collections.Map<String, Authentication> by lazy {
|
||||
mapOf({{#authMethods}}{{#isBasic}}{{#isBasicBasic}}
|
||||
"{{name}}" to HttpBasicAuth(){{/isBasicBasic}}{{^isBasicBasic}}
|
||||
"{{name}}" to HttpBearerAuth("{{scheme}}"){{/isBasicBasic}}{{/isBasic}}{{#isApiKey}}
|
||||
"{{name}}" to ApiKeyAuth({{#isKeyInHeader}}"header"{{/isKeyInHeader}}{{^isKeyInHeader}}"query"{{/isKeyInHeader}}, "{{keyParamName}}"){{/isApiKey}}{{#isOAuth}}
|
||||
"{{name}}" to OAuth(){{/isOAuth}}{{#hasMore}}, {{/hasMore}}{{/authMethods}})
|
||||
}
|
||||
|
||||
{{#nonPublicApi}}internal {{/nonPublicApi}}companion object {
|
||||
protected val UNSAFE_HEADERS = listOf(HttpHeaders.ContentType)
|
||||
|
||||
@ -54,27 +63,96 @@ import {{modelPackage}}.*
|
||||
{{classname}}.setMappers(serializer)
|
||||
{{/apis}}{{/apiInfo}}
|
||||
{{#models}}
|
||||
{{#model}}{{^isAlias}}serializer.setMapper({{classname}}::class, {{classname}}.serializer()){{/isAlias}}{{/model}}
|
||||
{{#model}}{{^isAlias}}serializer.setMapper({{modelPackage}}.{{classname}}::class, {{modelPackage}}.{{classname}}.{{#isEnum}}Serializer{{/isEnum}}{{^isEnum}}serializer(){{/isEnum}}){{/isAlias}}{{/model}}
|
||||
{{/models}}
|
||||
}
|
||||
}
|
||||
|
||||
protected suspend fun multipartFormRequest(requestConfig: RequestConfig, body: List<PartData>?): HttpResponse {
|
||||
return request(requestConfig, MultiPartFormDataContent(body ?: listOf()))
|
||||
/**
|
||||
* Set the username for the first HTTP basic authentication.
|
||||
*
|
||||
* @param username Username
|
||||
*/
|
||||
fun setUsername(username: String) {
|
||||
val auth = authentications.values.firstOrNull { it is HttpBasicAuth } as HttpBasicAuth?
|
||||
?: throw Exception("No HTTP basic authentication configured")
|
||||
auth.username = username
|
||||
}
|
||||
|
||||
protected suspend fun urlEncodedFormRequest(requestConfig: RequestConfig, body: Parameters?): HttpResponse {
|
||||
return request(requestConfig, FormDataContent(body ?: Parameters.Empty))
|
||||
/**
|
||||
* Set the password for the first HTTP basic authentication.
|
||||
*
|
||||
* @param password Password
|
||||
*/
|
||||
fun setPassword(password: String) {
|
||||
val auth = authentications.values.firstOrNull { it is HttpBasicAuth } as HttpBasicAuth?
|
||||
?: throw Exception("No HTTP basic authentication configured")
|
||||
auth.password = password
|
||||
}
|
||||
|
||||
protected suspend fun jsonRequest(requestConfig: RequestConfig, body: Any? = null): HttpResponse {
|
||||
/**
|
||||
* Set the API key value for the first API key authentication.
|
||||
*
|
||||
* @param apiKey API key
|
||||
* @param paramName The name of the API key parameter, or null or set the first key.
|
||||
*/
|
||||
fun setApiKey(apiKey: String, paramName: String? = null) {
|
||||
val auth = authentications.values.firstOrNull { it is ApiKeyAuth && (paramName == null || paramName == it.paramName)} as ApiKeyAuth?
|
||||
?: throw Exception("No API key authentication configured")
|
||||
auth.apiKey = apiKey
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the API key prefix for the first API key authentication.
|
||||
*
|
||||
* @param apiKeyPrefix API key prefix
|
||||
* @param paramName The name of the API key parameter, or null or set the first key.
|
||||
*/
|
||||
fun setApiKeyPrefix(apiKeyPrefix: String, paramName: String? = null) {
|
||||
val auth = authentications.values.firstOrNull { it is ApiKeyAuth && (paramName == null || paramName == it.paramName) } as ApiKeyAuth?
|
||||
?: throw Exception("No API key authentication configured")
|
||||
auth.apiKeyPrefix = apiKeyPrefix
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the access token for the first OAuth2 authentication.
|
||||
*
|
||||
* @param accessToken Access token
|
||||
*/
|
||||
fun setAccessToken(accessToken: String) {
|
||||
val auth = authentications.values.firstOrNull { it is OAuth } as OAuth?
|
||||
?: throw Exception("No OAuth2 authentication configured")
|
||||
auth.accessToken = accessToken
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the access token for the first Bearer authentication.
|
||||
*
|
||||
* @param bearerToken The bearer token.
|
||||
*/
|
||||
fun setBearerToken(bearerToken: String) {
|
||||
val auth = authentications.values.firstOrNull { it is HttpBearerAuth } as HttpBearerAuth?
|
||||
?: throw Exception("No Bearer authentication configured")
|
||||
auth.bearerToken = bearerToken
|
||||
}
|
||||
|
||||
protected suspend fun multipartFormRequest(requestConfig: RequestConfig, body: kotlin.collections.List<PartData>?, authNames: kotlin.collections.List<String>): HttpResponse {
|
||||
return request(requestConfig, MultiPartFormDataContent(body ?: listOf()), authNames)
|
||||
}
|
||||
|
||||
protected suspend fun urlEncodedFormRequest(requestConfig: RequestConfig, body: Parameters?, authNames: kotlin.collections.List<String>): HttpResponse {
|
||||
return request(requestConfig, FormDataContent(body ?: Parameters.Empty), authNames)
|
||||
}
|
||||
|
||||
protected suspend fun jsonRequest(requestConfig: RequestConfig, body: Any? = null, authNames: kotlin.collections.List<String>): HttpResponse {
|
||||
val contentType = (requestConfig.headers[HttpHeaders.ContentType]?.let { ContentType.parse(it) }
|
||||
?: ContentType.Application.Json)
|
||||
return if (body != null) request(requestConfig, serializer.write(body, contentType))
|
||||
else request(requestConfig)
|
||||
return if (body != null) request(requestConfig, serializer.write(body, contentType), authNames)
|
||||
else request(requestConfig, authNames = authNames)
|
||||
}
|
||||
|
||||
protected suspend fun request(requestConfig: RequestConfig, body: OutgoingContent = EmptyContent): HttpResponse {
|
||||
protected suspend fun request(requestConfig: RequestConfig, body: OutgoingContent = EmptyContent, authNames: kotlin.collections.List<String>): HttpResponse {
|
||||
requestConfig.updateForAuth(authNames)
|
||||
val headers = requestConfig.headers
|
||||
|
||||
return client.call {
|
||||
@ -95,7 +173,14 @@ import {{modelPackage}}.*
|
||||
}.response
|
||||
}
|
||||
|
||||
private fun URLBuilder.appendPath(components: List<String>): URLBuilder = apply {
|
||||
private fun RequestConfig.updateForAuth(authNames: kotlin.collections.List<String>) {
|
||||
for (authName in authNames) {
|
||||
val auth = authentications[authName] ?: throw Exception("Authentication undefined: $authName")
|
||||
auth.apply(query, headers)
|
||||
}
|
||||
}
|
||||
|
||||
private fun URLBuilder.appendPath(components: kotlin.collections.List<String>): URLBuilder = apply {
|
||||
encodedPath = encodedPath.trimEnd('/') + components.joinToString("/", prefix = "/") { it.encodeURLQueryComponent() }
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,29 @@
|
||||
package {{packageName}}.infrastructure
|
||||
|
||||
import kotlinx.serialization.*
|
||||
import kotlinx.serialization.internal.StringDescriptor
|
||||
|
||||
@Serializable
|
||||
class Base64ByteArray(val value: ByteArray) {
|
||||
@Serializer(Base64ByteArray::class)
|
||||
companion object : KSerializer<Base64ByteArray> {
|
||||
override val descriptor = StringDescriptor.withName("Base64ByteArray")
|
||||
override fun serialize(encoder: Encoder, obj: Base64ByteArray) = encoder.encodeString(obj.value.encodeBase64())
|
||||
override fun deserialize(decoder: Decoder) = Base64ByteArray(decoder.decodeString().decodeBase64Bytes())
|
||||
}
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (this === other) return true
|
||||
if (other == null || this::class != other::class) return false
|
||||
other as Base64ByteArray
|
||||
return value.contentEquals(other.value)
|
||||
}
|
||||
|
||||
override fun hashCode(): Int {
|
||||
return value.contentHashCode()
|
||||
}
|
||||
|
||||
override fun toString(): String {
|
||||
return "Base64ByteArray(${hex(value)})"
|
||||
}
|
||||
}
|
@ -0,0 +1,102 @@
|
||||
package {{packageName}}.infrastructure
|
||||
|
||||
import kotlinx.io.core.*
|
||||
import kotlin.experimental.and
|
||||
|
||||
private val digits = "0123456789abcdef".toCharArray()
|
||||
private const val BASE64_ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
|
||||
private const val BASE64_MASK: Byte = 0x3f
|
||||
private const val BASE64_PAD = '='
|
||||
private val BASE64_INVERSE_ALPHABET = IntArray(256) { BASE64_ALPHABET.indexOf(it.toChar()) }
|
||||
|
||||
private fun String.toCharArray(): CharArray = CharArray(length) { get(it) }
|
||||
private fun ByteArray.clearFrom(from: Int) = (from until size).forEach { this[it] = 0 }
|
||||
private fun Int.toBase64(): Char = BASE64_ALPHABET[this]
|
||||
private fun Byte.fromBase64(): Byte = BASE64_INVERSE_ALPHABET[toInt() and 0xff].toByte() and BASE64_MASK
|
||||
internal fun ByteArray.encodeBase64(): String = buildPacket { writeFully(this@encodeBase64) }.encodeBase64()
|
||||
internal fun String.decodeBase64Bytes(): ByteArray = buildPacket { writeStringUtf8(dropLastWhile { it == BASE64_PAD }) }.decodeBase64Bytes().readBytes()
|
||||
|
||||
/**
|
||||
* Encode [bytes] as a HEX string with no spaces, newlines and `0x` prefixes.
|
||||
*
|
||||
* Taken from https://github.com/ktorio/ktor/blob/master/ktor-utils/common/src/io/ktor/util/Crypto.kt
|
||||
*/
|
||||
internal fun hex(bytes: ByteArray): String {
|
||||
val result = CharArray(bytes.size * 2)
|
||||
var resultIndex = 0
|
||||
val digits = digits
|
||||
|
||||
for (element in bytes) {
|
||||
val b = element.toInt() and 0xff
|
||||
result[resultIndex++] = digits[b shr 4]
|
||||
result[resultIndex++] = digits[b and 0x0f]
|
||||
}
|
||||
|
||||
return String(result)
|
||||
}
|
||||
|
||||
/**
|
||||
* Decode bytes from HEX string. It should be no spaces and `0x` prefixes.
|
||||
*
|
||||
* Taken from https://github.com/ktorio/ktor/blob/master/ktor-utils/common/src/io/ktor/util/Crypto.kt
|
||||
*/
|
||||
internal fun hex(s: String): ByteArray {
|
||||
val result = ByteArray(s.length / 2)
|
||||
for (idx in result.indices) {
|
||||
val srcIdx = idx * 2
|
||||
val high = s[srcIdx].toString().toInt(16) shl 4
|
||||
val low = s[srcIdx + 1].toString().toInt(16)
|
||||
result[idx] = (high or low).toByte()
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* Encode [ByteReadPacket] in base64 format.
|
||||
*
|
||||
* Taken from https://github.com/ktorio/ktor/blob/424d1d2cfaa3281302c60af9500f738c8c2fc846/ktor-utils/common/src/io/ktor/util/Base64.kt
|
||||
*/
|
||||
private fun ByteReadPacket.encodeBase64(): String = buildString {
|
||||
val data = ByteArray(3)
|
||||
while (remaining > 0) {
|
||||
val read = readAvailable(data)
|
||||
data.clearFrom(read)
|
||||
|
||||
val padSize = (data.size - read) * 8 / 6
|
||||
val chunk = ((data[0].toInt() and 0xFF) shl 16) or
|
||||
((data[1].toInt() and 0xFF) shl 8) or
|
||||
(data[2].toInt() and 0xFF)
|
||||
|
||||
for (index in data.size downTo padSize) {
|
||||
val char = (chunk shr (6 * index)) and BASE64_MASK.toInt()
|
||||
append(char.toBase64())
|
||||
}
|
||||
|
||||
repeat(padSize) { append(BASE64_PAD) }
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Decode [ByteReadPacket] from base64 format
|
||||
*
|
||||
* Taken from https://github.com/ktorio/ktor/blob/424d1d2cfaa3281302c60af9500f738c8c2fc846/ktor-utils/common/src/io/ktor/util/Base64.kt
|
||||
*/
|
||||
private fun ByteReadPacket.decodeBase64Bytes(): Input = buildPacket {
|
||||
val data = ByteArray(4)
|
||||
|
||||
while (remaining > 0) {
|
||||
val read = readAvailable(data)
|
||||
|
||||
val chunk = data.foldIndexed(0) { index, result, current ->
|
||||
result or (current.fromBase64().toInt() shl ((3 - index) * 6))
|
||||
}
|
||||
|
||||
for (index in data.size - 2 downTo (data.size - read)) {
|
||||
val origin = (chunk shr (8 * index)) and 0xff
|
||||
writeByte(origin.toByte())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,29 @@
|
||||
package {{packageName}}.infrastructure
|
||||
|
||||
import kotlinx.serialization.*
|
||||
import kotlinx.serialization.internal.StringDescriptor
|
||||
|
||||
@Serializable
|
||||
class OctetByteArray(val value: ByteArray) {
|
||||
@Serializer(OctetByteArray::class)
|
||||
companion object : KSerializer<OctetByteArray> {
|
||||
override val descriptor = StringDescriptor.withName("OctetByteArray")
|
||||
override fun serialize(encoder: Encoder, obj: OctetByteArray) = encoder.encodeString(hex(obj.value))
|
||||
override fun deserialize(decoder: Decoder) = OctetByteArray(hex(decoder.decodeString()))
|
||||
}
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (this === other) return true
|
||||
if (other == null || this::class != other::class) return false
|
||||
other as OctetByteArray
|
||||
return value.contentEquals(other.value)
|
||||
}
|
||||
|
||||
override fun hashCode(): Int {
|
||||
return value.contentHashCode()
|
||||
}
|
||||
|
||||
override fun toString(): String {
|
||||
return "OctetByteArray(${hex(value)})"
|
||||
}
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
package util
|
||||
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.GlobalScope
|
||||
import kotlinx.coroutines.promise
|
||||
|
||||
actual fun <T> runTest(block: suspend (scope : CoroutineScope) -> T): dynamic = GlobalScope.promise { block(this) }
|
@ -30,6 +30,7 @@ kotlin {
|
||||
jvm()
|
||||
iosArm64() { binaries { framework { freeCompilerArgs.add("-Xobjc-generics") } } }
|
||||
iosX64() { binaries { framework { freeCompilerArgs.add("-Xobjc-generics") } } }
|
||||
js()
|
||||
|
||||
sourceSets {
|
||||
commonMain {
|
||||
@ -37,9 +38,9 @@ kotlin {
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-common:$kotlin_version"
|
||||
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core-common:$coroutines_version"
|
||||
implementation "org.jetbrains.kotlinx:kotlinx-serialization-runtime-common:$serialization_version"
|
||||
implementation "io.ktor:ktor-client-core:$ktor_version"
|
||||
implementation "io.ktor:ktor-client-json:$ktor_version"
|
||||
implementation "io.ktor:ktor-client-serialization:$ktor_version"
|
||||
api "io.ktor:ktor-client-core:$ktor_version"
|
||||
api "io.ktor:ktor-client-json:$ktor_version"
|
||||
api "io.ktor:ktor-client-serialization:$ktor_version"
|
||||
}
|
||||
}
|
||||
|
||||
@ -57,9 +58,9 @@ kotlin {
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
|
||||
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version"
|
||||
implementation "org.jetbrains.kotlinx:kotlinx-serialization-runtime:$serialization_version"
|
||||
implementation "io.ktor:ktor-client-core-jvm:$ktor_version"
|
||||
implementation "io.ktor:ktor-client-json-jvm:$ktor_version"
|
||||
implementation "io.ktor:ktor-client-serialization-jvm:$ktor_version"
|
||||
api "io.ktor:ktor-client-core-jvm:$ktor_version"
|
||||
api "io.ktor:ktor-client-json-jvm:$ktor_version"
|
||||
api "io.ktor:ktor-client-serialization-jvm:$ktor_version"
|
||||
}
|
||||
}
|
||||
|
||||
@ -77,7 +78,7 @@ kotlin {
|
||||
dependencies {
|
||||
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core-native:$coroutines_version"
|
||||
implementation "org.jetbrains.kotlinx:kotlinx-serialization-runtime-native:$serialization_version"
|
||||
implementation "io.ktor:ktor-client-ios:$ktor_version"
|
||||
api "io.ktor:ktor-client-ios:$ktor_version"
|
||||
}
|
||||
}
|
||||
|
||||
@ -91,9 +92,9 @@ kotlin {
|
||||
iosArm64().compilations.main.defaultSourceSet {
|
||||
dependsOn iosMain
|
||||
dependencies {
|
||||
implementation "io.ktor:ktor-client-ios-iosarm64:$ktor_version"
|
||||
implementation "io.ktor:ktor-client-json-iosarm64:$ktor_version"
|
||||
implementation "io.ktor:ktor-client-serialization-iosarm64:$ktor_version"
|
||||
api "io.ktor:ktor-client-ios-iosarm64:$ktor_version"
|
||||
api "io.ktor:ktor-client-json-iosarm64:$ktor_version"
|
||||
api "io.ktor:ktor-client-serialization-iosarm64:$ktor_version"
|
||||
}
|
||||
}
|
||||
|
||||
@ -104,9 +105,31 @@ kotlin {
|
||||
iosX64().compilations.main.defaultSourceSet {
|
||||
dependsOn iosMain
|
||||
dependencies {
|
||||
implementation "io.ktor:ktor-client-ios-iosx64:$ktor_version"
|
||||
implementation "io.ktor:ktor-client-json-iosx64:$ktor_version"
|
||||
implementation "io.ktor:ktor-client-serialization-iosx64:$ktor_version"
|
||||
api "io.ktor:ktor-client-ios-iosx64:$ktor_version"
|
||||
api "io.ktor:ktor-client-json-iosx64:$ktor_version"
|
||||
api "io.ktor:ktor-client-serialization-iosx64:$ktor_version"
|
||||
}
|
||||
}
|
||||
|
||||
jsMain {
|
||||
dependsOn commonMain
|
||||
dependencies {
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-js:$kotlin_version"
|
||||
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core-js:$coroutines_version"
|
||||
implementation "org.jetbrains.kotlinx:kotlinx-serialization-runtime-js:$serialization_version"
|
||||
api "io.ktor:ktor-client-js:$ktor_version"
|
||||
api "io.ktor:ktor-client-json-js:$ktor_version"
|
||||
api "io.ktor:ktor-client-serialization-js:$ktor_version"
|
||||
}
|
||||
}
|
||||
|
||||
jsTest {
|
||||
dependsOn commonTest
|
||||
dependencies {
|
||||
implementation "io.ktor:ktor-client-mock-js:$ktor_version"
|
||||
implementation "io.ktor:ktor-client-js:$ktor_version"
|
||||
implementation "io.ktor:ktor-client-json:$ktor_version"
|
||||
implementation "io.ktor:ktor-client-serialization-js:$ktor_version"
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -46,6 +46,8 @@ class PetApi @UseExperimental(UnstableDefault::class) constructor(
|
||||
*/
|
||||
suspend fun addPet(body: Pet) : HttpResponse<Unit> {
|
||||
|
||||
val localVariableAuthNames = listOf<String>("petstore_auth")
|
||||
|
||||
val localVariableBody = body
|
||||
|
||||
val localVariableQuery = mutableMapOf<String, List<String>>()
|
||||
@ -61,7 +63,8 @@ class PetApi @UseExperimental(UnstableDefault::class) constructor(
|
||||
|
||||
return jsonRequest(
|
||||
localVariableConfig,
|
||||
localVariableBody
|
||||
localVariableBody,
|
||||
localVariableAuthNames
|
||||
).wrap()
|
||||
}
|
||||
|
||||
@ -76,6 +79,8 @@ class PetApi @UseExperimental(UnstableDefault::class) constructor(
|
||||
*/
|
||||
suspend fun deletePet(petId: kotlin.Long, apiKey: kotlin.String?) : HttpResponse<Unit> {
|
||||
|
||||
val localVariableAuthNames = listOf<String>("petstore_auth")
|
||||
|
||||
val localVariableBody =
|
||||
io.ktor.client.utils.EmptyContent
|
||||
|
||||
@ -93,7 +98,8 @@ class PetApi @UseExperimental(UnstableDefault::class) constructor(
|
||||
|
||||
return request(
|
||||
localVariableConfig,
|
||||
localVariableBody
|
||||
localVariableBody,
|
||||
localVariableAuthNames
|
||||
).wrap()
|
||||
}
|
||||
|
||||
@ -107,6 +113,8 @@ class PetApi @UseExperimental(UnstableDefault::class) constructor(
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
suspend fun findPetsByStatus(status: kotlin.Array<kotlin.String>) : HttpResponse<kotlin.Array<Pet>> {
|
||||
|
||||
val localVariableAuthNames = listOf<String>("petstore_auth")
|
||||
|
||||
val localVariableBody =
|
||||
io.ktor.client.utils.EmptyContent
|
||||
|
||||
@ -124,7 +132,8 @@ class PetApi @UseExperimental(UnstableDefault::class) constructor(
|
||||
|
||||
return request(
|
||||
localVariableConfig,
|
||||
localVariableBody
|
||||
localVariableBody,
|
||||
localVariableAuthNames
|
||||
).wrap<FindPetsByStatusResponse>().map { value.toTypedArray() }
|
||||
}
|
||||
|
||||
@ -148,6 +157,8 @@ private class FindPetsByStatusResponse(val value: List<Pet>) {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
suspend fun findPetsByTags(tags: kotlin.Array<kotlin.String>) : HttpResponse<kotlin.Array<Pet>> {
|
||||
|
||||
val localVariableAuthNames = listOf<String>("petstore_auth")
|
||||
|
||||
val localVariableBody =
|
||||
io.ktor.client.utils.EmptyContent
|
||||
|
||||
@ -165,7 +176,8 @@ private class FindPetsByStatusResponse(val value: List<Pet>) {
|
||||
|
||||
return request(
|
||||
localVariableConfig,
|
||||
localVariableBody
|
||||
localVariableBody,
|
||||
localVariableAuthNames
|
||||
).wrap<FindPetsByTagsResponse>().map { value.toTypedArray() }
|
||||
}
|
||||
|
||||
@ -189,6 +201,8 @@ private class FindPetsByTagsResponse(val value: List<Pet>) {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
suspend fun getPetById(petId: kotlin.Long) : HttpResponse<Pet> {
|
||||
|
||||
val localVariableAuthNames = listOf<String>("api_key")
|
||||
|
||||
val localVariableBody =
|
||||
io.ktor.client.utils.EmptyContent
|
||||
|
||||
@ -205,7 +219,8 @@ private class FindPetsByTagsResponse(val value: List<Pet>) {
|
||||
|
||||
return request(
|
||||
localVariableConfig,
|
||||
localVariableBody
|
||||
localVariableBody,
|
||||
localVariableAuthNames
|
||||
).wrap()
|
||||
}
|
||||
|
||||
@ -218,6 +233,8 @@ private class FindPetsByTagsResponse(val value: List<Pet>) {
|
||||
*/
|
||||
suspend fun updatePet(body: Pet) : HttpResponse<Unit> {
|
||||
|
||||
val localVariableAuthNames = listOf<String>("petstore_auth")
|
||||
|
||||
val localVariableBody = body
|
||||
|
||||
val localVariableQuery = mutableMapOf<String, List<String>>()
|
||||
@ -233,7 +250,8 @@ private class FindPetsByTagsResponse(val value: List<Pet>) {
|
||||
|
||||
return jsonRequest(
|
||||
localVariableConfig,
|
||||
localVariableBody
|
||||
localVariableBody,
|
||||
localVariableAuthNames
|
||||
).wrap()
|
||||
}
|
||||
|
||||
@ -249,6 +267,8 @@ private class FindPetsByTagsResponse(val value: List<Pet>) {
|
||||
*/
|
||||
suspend fun updatePetWithForm(petId: kotlin.Long, name: kotlin.String?, status: kotlin.String?) : HttpResponse<Unit> {
|
||||
|
||||
val localVariableAuthNames = listOf<String>("petstore_auth")
|
||||
|
||||
val localVariableBody =
|
||||
ParametersBuilder().also {
|
||||
name?.apply { it.append("name", name.toString()) }
|
||||
@ -268,7 +288,8 @@ private class FindPetsByTagsResponse(val value: List<Pet>) {
|
||||
|
||||
return urlEncodedFormRequest(
|
||||
localVariableConfig,
|
||||
localVariableBody
|
||||
localVariableBody,
|
||||
localVariableAuthNames
|
||||
).wrap()
|
||||
}
|
||||
|
||||
@ -284,6 +305,8 @@ private class FindPetsByTagsResponse(val value: List<Pet>) {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
suspend fun uploadFile(petId: kotlin.Long, additionalMetadata: kotlin.String?, file: io.ktor.client.request.forms.InputProvider?) : HttpResponse<ApiResponse> {
|
||||
|
||||
val localVariableAuthNames = listOf<String>("petstore_auth")
|
||||
|
||||
val localVariableBody =
|
||||
formData {
|
||||
additionalMetadata?.apply { append("additionalMetadata", additionalMetadata) }
|
||||
@ -303,7 +326,8 @@ private class FindPetsByTagsResponse(val value: List<Pet>) {
|
||||
|
||||
return multipartFormRequest(
|
||||
localVariableConfig,
|
||||
localVariableBody
|
||||
localVariableBody,
|
||||
localVariableAuthNames
|
||||
).wrap()
|
||||
}
|
||||
|
||||
|
@ -45,6 +45,8 @@ class StoreApi @UseExperimental(UnstableDefault::class) constructor(
|
||||
*/
|
||||
suspend fun deleteOrder(orderId: kotlin.String) : HttpResponse<Unit> {
|
||||
|
||||
val localVariableAuthNames = listOf<String>()
|
||||
|
||||
val localVariableBody =
|
||||
io.ktor.client.utils.EmptyContent
|
||||
|
||||
@ -61,7 +63,8 @@ class StoreApi @UseExperimental(UnstableDefault::class) constructor(
|
||||
|
||||
return request(
|
||||
localVariableConfig,
|
||||
localVariableBody
|
||||
localVariableBody,
|
||||
localVariableAuthNames
|
||||
).wrap()
|
||||
}
|
||||
|
||||
@ -74,6 +77,8 @@ class StoreApi @UseExperimental(UnstableDefault::class) constructor(
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
suspend fun getInventory() : HttpResponse<kotlin.collections.Map<kotlin.String, kotlin.Int>> {
|
||||
|
||||
val localVariableAuthNames = listOf<String>("api_key")
|
||||
|
||||
val localVariableBody =
|
||||
io.ktor.client.utils.EmptyContent
|
||||
|
||||
@ -90,7 +95,8 @@ class StoreApi @UseExperimental(UnstableDefault::class) constructor(
|
||||
|
||||
return request(
|
||||
localVariableConfig,
|
||||
localVariableBody
|
||||
localVariableBody,
|
||||
localVariableAuthNames
|
||||
).wrap<GetInventoryResponse>().map { value }
|
||||
}
|
||||
|
||||
@ -114,6 +120,8 @@ private class GetInventoryResponse(val value: Map<kotlin.String, kotlin.Int>) {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
suspend fun getOrderById(orderId: kotlin.Long) : HttpResponse<Order> {
|
||||
|
||||
val localVariableAuthNames = listOf<String>()
|
||||
|
||||
val localVariableBody =
|
||||
io.ktor.client.utils.EmptyContent
|
||||
|
||||
@ -130,7 +138,8 @@ private class GetInventoryResponse(val value: Map<kotlin.String, kotlin.Int>) {
|
||||
|
||||
return request(
|
||||
localVariableConfig,
|
||||
localVariableBody
|
||||
localVariableBody,
|
||||
localVariableAuthNames
|
||||
).wrap()
|
||||
}
|
||||
|
||||
@ -144,6 +153,8 @@ private class GetInventoryResponse(val value: Map<kotlin.String, kotlin.Int>) {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
suspend fun placeOrder(body: Order) : HttpResponse<Order> {
|
||||
|
||||
val localVariableAuthNames = listOf<String>()
|
||||
|
||||
val localVariableBody = body
|
||||
|
||||
val localVariableQuery = mutableMapOf<String, List<String>>()
|
||||
@ -159,7 +170,8 @@ private class GetInventoryResponse(val value: Map<kotlin.String, kotlin.Int>) {
|
||||
|
||||
return jsonRequest(
|
||||
localVariableConfig,
|
||||
localVariableBody
|
||||
localVariableBody,
|
||||
localVariableAuthNames
|
||||
).wrap()
|
||||
}
|
||||
|
||||
|
@ -45,6 +45,8 @@ class UserApi @UseExperimental(UnstableDefault::class) constructor(
|
||||
*/
|
||||
suspend fun createUser(body: User) : HttpResponse<Unit> {
|
||||
|
||||
val localVariableAuthNames = listOf<String>()
|
||||
|
||||
val localVariableBody = body
|
||||
|
||||
val localVariableQuery = mutableMapOf<String, List<String>>()
|
||||
@ -60,7 +62,8 @@ class UserApi @UseExperimental(UnstableDefault::class) constructor(
|
||||
|
||||
return jsonRequest(
|
||||
localVariableConfig,
|
||||
localVariableBody
|
||||
localVariableBody,
|
||||
localVariableAuthNames
|
||||
).wrap()
|
||||
}
|
||||
|
||||
@ -74,6 +77,8 @@ class UserApi @UseExperimental(UnstableDefault::class) constructor(
|
||||
*/
|
||||
suspend fun createUsersWithArrayInput(body: kotlin.Array<User>) : HttpResponse<Unit> {
|
||||
|
||||
val localVariableAuthNames = listOf<String>()
|
||||
|
||||
val localVariableBody = CreateUsersWithArrayInputRequest(body.asList())
|
||||
|
||||
val localVariableQuery = mutableMapOf<String, List<String>>()
|
||||
@ -89,7 +94,8 @@ class UserApi @UseExperimental(UnstableDefault::class) constructor(
|
||||
|
||||
return jsonRequest(
|
||||
localVariableConfig,
|
||||
localVariableBody
|
||||
localVariableBody,
|
||||
localVariableAuthNames
|
||||
).wrap()
|
||||
}
|
||||
|
||||
@ -112,6 +118,8 @@ private class CreateUsersWithArrayInputRequest(val value: List<User>) {
|
||||
*/
|
||||
suspend fun createUsersWithListInput(body: kotlin.Array<User>) : HttpResponse<Unit> {
|
||||
|
||||
val localVariableAuthNames = listOf<String>()
|
||||
|
||||
val localVariableBody = CreateUsersWithListInputRequest(body.asList())
|
||||
|
||||
val localVariableQuery = mutableMapOf<String, List<String>>()
|
||||
@ -127,7 +135,8 @@ private class CreateUsersWithArrayInputRequest(val value: List<User>) {
|
||||
|
||||
return jsonRequest(
|
||||
localVariableConfig,
|
||||
localVariableBody
|
||||
localVariableBody,
|
||||
localVariableAuthNames
|
||||
).wrap()
|
||||
}
|
||||
|
||||
@ -150,6 +159,8 @@ private class CreateUsersWithListInputRequest(val value: List<User>) {
|
||||
*/
|
||||
suspend fun deleteUser(username: kotlin.String) : HttpResponse<Unit> {
|
||||
|
||||
val localVariableAuthNames = listOf<String>()
|
||||
|
||||
val localVariableBody =
|
||||
io.ktor.client.utils.EmptyContent
|
||||
|
||||
@ -166,7 +177,8 @@ private class CreateUsersWithListInputRequest(val value: List<User>) {
|
||||
|
||||
return request(
|
||||
localVariableConfig,
|
||||
localVariableBody
|
||||
localVariableBody,
|
||||
localVariableAuthNames
|
||||
).wrap()
|
||||
}
|
||||
|
||||
@ -180,6 +192,8 @@ private class CreateUsersWithListInputRequest(val value: List<User>) {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
suspend fun getUserByName(username: kotlin.String) : HttpResponse<User> {
|
||||
|
||||
val localVariableAuthNames = listOf<String>()
|
||||
|
||||
val localVariableBody =
|
||||
io.ktor.client.utils.EmptyContent
|
||||
|
||||
@ -196,7 +210,8 @@ private class CreateUsersWithListInputRequest(val value: List<User>) {
|
||||
|
||||
return request(
|
||||
localVariableConfig,
|
||||
localVariableBody
|
||||
localVariableBody,
|
||||
localVariableAuthNames
|
||||
).wrap()
|
||||
}
|
||||
|
||||
@ -211,6 +226,8 @@ private class CreateUsersWithListInputRequest(val value: List<User>) {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
suspend fun loginUser(username: kotlin.String, password: kotlin.String) : HttpResponse<kotlin.String> {
|
||||
|
||||
val localVariableAuthNames = listOf<String>()
|
||||
|
||||
val localVariableBody =
|
||||
io.ktor.client.utils.EmptyContent
|
||||
|
||||
@ -229,7 +246,8 @@ private class CreateUsersWithListInputRequest(val value: List<User>) {
|
||||
|
||||
return request(
|
||||
localVariableConfig,
|
||||
localVariableBody
|
||||
localVariableBody,
|
||||
localVariableAuthNames
|
||||
).wrap()
|
||||
}
|
||||
|
||||
@ -241,6 +259,8 @@ private class CreateUsersWithListInputRequest(val value: List<User>) {
|
||||
*/
|
||||
suspend fun logoutUser() : HttpResponse<Unit> {
|
||||
|
||||
val localVariableAuthNames = listOf<String>()
|
||||
|
||||
val localVariableBody =
|
||||
io.ktor.client.utils.EmptyContent
|
||||
|
||||
@ -257,7 +277,8 @@ private class CreateUsersWithListInputRequest(val value: List<User>) {
|
||||
|
||||
return request(
|
||||
localVariableConfig,
|
||||
localVariableBody
|
||||
localVariableBody,
|
||||
localVariableAuthNames
|
||||
).wrap()
|
||||
}
|
||||
|
||||
@ -271,6 +292,8 @@ private class CreateUsersWithListInputRequest(val value: List<User>) {
|
||||
*/
|
||||
suspend fun updateUser(username: kotlin.String, body: User) : HttpResponse<Unit> {
|
||||
|
||||
val localVariableAuthNames = listOf<String>()
|
||||
|
||||
val localVariableBody = body
|
||||
|
||||
val localVariableQuery = mutableMapOf<String, List<String>>()
|
||||
@ -286,7 +309,8 @@ private class CreateUsersWithListInputRequest(val value: List<User>) {
|
||||
|
||||
return jsonRequest(
|
||||
localVariableConfig,
|
||||
localVariableBody
|
||||
localVariableBody,
|
||||
localVariableAuthNames
|
||||
).wrap()
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
}
|
||||
}
|
||||
}
|
@ -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>)
|
||||
|
||||
}
|
@ -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
|
||||
|
||||
@InternalAPI
|
||||
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"
|
||||
}
|
||||
}
|
@ -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
|
||||
}
|
||||
}
|
@ -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"
|
||||
}
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
package org.openapitools.client.infrastructure
|
||||
|
||||
typealias MultiValueMap = Map<String,List<String>>
|
||||
typealias MultiValueMap = MutableMap<String,List<String>>
|
||||
|
||||
fun collectionDelimiter(collectionFormat: String) = when(collectionFormat) {
|
||||
"csv" -> ","
|
||||
|
@ -23,6 +23,7 @@ import kotlinx.serialization.json.JsonConfiguration
|
||||
|
||||
import org.openapitools.client.apis.*
|
||||
import org.openapitools.client.models.*
|
||||
import org.openapitools.client.auth.*
|
||||
|
||||
open class ApiClient(
|
||||
private val baseUrl: String,
|
||||
@ -46,6 +47,12 @@ open class ApiClient(
|
||||
httpClientEngine?.let { HttpClient(it, clientConfig) } ?: HttpClient(clientConfig)
|
||||
}
|
||||
|
||||
private val authentications: kotlin.collections.Map<String, Authentication> by lazy {
|
||||
mapOf(
|
||||
"api_key" to ApiKeyAuth("header", "api_key"),
|
||||
"petstore_auth" to OAuth())
|
||||
}
|
||||
|
||||
companion object {
|
||||
protected val UNSAFE_HEADERS = listOf(HttpHeaders.ContentType)
|
||||
|
||||
@ -57,31 +64,100 @@ open class ApiClient(
|
||||
|
||||
UserApi.setMappers(serializer)
|
||||
|
||||
serializer.setMapper(ApiResponse::class, ApiResponse.serializer())
|
||||
serializer.setMapper(Category::class, Category.serializer())
|
||||
serializer.setMapper(Order::class, Order.serializer())
|
||||
serializer.setMapper(Pet::class, Pet.serializer())
|
||||
serializer.setMapper(Tag::class, Tag.serializer())
|
||||
serializer.setMapper(User::class, User.serializer())
|
||||
serializer.setMapper(org.openapitools.client.models.ApiResponse::class, org.openapitools.client.models.ApiResponse.serializer())
|
||||
serializer.setMapper(org.openapitools.client.models.Category::class, org.openapitools.client.models.Category.serializer())
|
||||
serializer.setMapper(org.openapitools.client.models.Order::class, org.openapitools.client.models.Order.serializer())
|
||||
serializer.setMapper(org.openapitools.client.models.Pet::class, org.openapitools.client.models.Pet.serializer())
|
||||
serializer.setMapper(org.openapitools.client.models.Tag::class, org.openapitools.client.models.Tag.serializer())
|
||||
serializer.setMapper(org.openapitools.client.models.User::class, org.openapitools.client.models.User.serializer())
|
||||
}
|
||||
}
|
||||
|
||||
protected suspend fun multipartFormRequest(requestConfig: RequestConfig, body: List<PartData>?): HttpResponse {
|
||||
return request(requestConfig, MultiPartFormDataContent(body ?: listOf()))
|
||||
/**
|
||||
* Set the username for the first HTTP basic authentication.
|
||||
*
|
||||
* @param username Username
|
||||
*/
|
||||
fun setUsername(username: String) {
|
||||
val auth = authentications.values.firstOrNull { it is HttpBasicAuth } as HttpBasicAuth?
|
||||
?: throw Exception("No HTTP basic authentication configured")
|
||||
auth.username = username
|
||||
}
|
||||
|
||||
protected suspend fun urlEncodedFormRequest(requestConfig: RequestConfig, body: Parameters?): HttpResponse {
|
||||
return request(requestConfig, FormDataContent(body ?: Parameters.Empty))
|
||||
/**
|
||||
* Set the password for the first HTTP basic authentication.
|
||||
*
|
||||
* @param password Password
|
||||
*/
|
||||
fun setPassword(password: String) {
|
||||
val auth = authentications.values.firstOrNull { it is HttpBasicAuth } as HttpBasicAuth?
|
||||
?: throw Exception("No HTTP basic authentication configured")
|
||||
auth.password = password
|
||||
}
|
||||
|
||||
protected suspend fun jsonRequest(requestConfig: RequestConfig, body: Any? = null): HttpResponse {
|
||||
/**
|
||||
* Set the API key value for the first API key authentication.
|
||||
*
|
||||
* @param apiKey API key
|
||||
* @param paramName The name of the API key parameter, or null or set the first key.
|
||||
*/
|
||||
fun setApiKey(apiKey: String, paramName: String? = null) {
|
||||
val auth = authentications.values.firstOrNull { it is ApiKeyAuth && (paramName == null || paramName == it.paramName)} as ApiKeyAuth?
|
||||
?: throw Exception("No API key authentication configured")
|
||||
auth.apiKey = apiKey
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the API key prefix for the first API key authentication.
|
||||
*
|
||||
* @param apiKeyPrefix API key prefix
|
||||
* @param paramName The name of the API key parameter, or null or set the first key.
|
||||
*/
|
||||
fun setApiKeyPrefix(apiKeyPrefix: String, paramName: String? = null) {
|
||||
val auth = authentications.values.firstOrNull { it is ApiKeyAuth && (paramName == null || paramName == it.paramName) } as ApiKeyAuth?
|
||||
?: throw Exception("No API key authentication configured")
|
||||
auth.apiKeyPrefix = apiKeyPrefix
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the access token for the first OAuth2 authentication.
|
||||
*
|
||||
* @param accessToken Access token
|
||||
*/
|
||||
fun setAccessToken(accessToken: String) {
|
||||
val auth = authentications.values.firstOrNull { it is OAuth } as OAuth?
|
||||
?: throw Exception("No OAuth2 authentication configured")
|
||||
auth.accessToken = accessToken
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the access token for the first Bearer authentication.
|
||||
*
|
||||
* @param bearerToken The bearer token.
|
||||
*/
|
||||
fun setBearerToken(bearerToken: String) {
|
||||
val auth = authentications.values.firstOrNull { it is HttpBearerAuth } as HttpBearerAuth?
|
||||
?: throw Exception("No Bearer authentication configured")
|
||||
auth.bearerToken = bearerToken
|
||||
}
|
||||
|
||||
protected suspend fun multipartFormRequest(requestConfig: RequestConfig, body: kotlin.collections.List<PartData>?, authNames: kotlin.collections.List<String>): HttpResponse {
|
||||
return request(requestConfig, MultiPartFormDataContent(body ?: listOf()), authNames)
|
||||
}
|
||||
|
||||
protected suspend fun urlEncodedFormRequest(requestConfig: RequestConfig, body: Parameters?, authNames: kotlin.collections.List<String>): HttpResponse {
|
||||
return request(requestConfig, FormDataContent(body ?: Parameters.Empty), authNames)
|
||||
}
|
||||
|
||||
protected suspend fun jsonRequest(requestConfig: RequestConfig, body: Any? = null, authNames: kotlin.collections.List<String>): HttpResponse {
|
||||
val contentType = (requestConfig.headers[HttpHeaders.ContentType]?.let { ContentType.parse(it) }
|
||||
?: ContentType.Application.Json)
|
||||
return if (body != null) request(requestConfig, serializer.write(body, contentType))
|
||||
else request(requestConfig)
|
||||
return if (body != null) request(requestConfig, serializer.write(body, contentType), authNames)
|
||||
else request(requestConfig, authNames = authNames)
|
||||
}
|
||||
|
||||
protected suspend fun request(requestConfig: RequestConfig, body: OutgoingContent = EmptyContent): HttpResponse {
|
||||
protected suspend fun request(requestConfig: RequestConfig, body: OutgoingContent = EmptyContent, authNames: kotlin.collections.List<String>): HttpResponse {
|
||||
requestConfig.updateForAuth(authNames)
|
||||
val headers = requestConfig.headers
|
||||
|
||||
return client.call {
|
||||
@ -102,7 +178,14 @@ open class ApiClient(
|
||||
}.response
|
||||
}
|
||||
|
||||
private fun URLBuilder.appendPath(components: List<String>): URLBuilder = apply {
|
||||
private fun RequestConfig.updateForAuth(authNames: kotlin.collections.List<String>) {
|
||||
for (authName in authNames) {
|
||||
val auth = authentications[authName] ?: throw Exception("Authentication undefined: $authName")
|
||||
auth.apply(query, headers)
|
||||
}
|
||||
}
|
||||
|
||||
private fun URLBuilder.appendPath(components: kotlin.collections.List<String>): URLBuilder = apply {
|
||||
encodedPath = encodedPath.trimEnd('/') + components.joinToString("/", prefix = "/") { it.encodeURLQueryComponent() }
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,29 @@
|
||||
package org.openapitools.client.infrastructure
|
||||
|
||||
import kotlinx.serialization.*
|
||||
import kotlinx.serialization.internal.StringDescriptor
|
||||
|
||||
@Serializable
|
||||
class Base64ByteArray(val value: ByteArray) {
|
||||
@Serializer(Base64ByteArray::class)
|
||||
companion object : KSerializer<Base64ByteArray> {
|
||||
override val descriptor = StringDescriptor.withName("Base64ByteArray")
|
||||
override fun serialize(encoder: Encoder, obj: Base64ByteArray) = encoder.encodeString(obj.value.encodeBase64())
|
||||
override fun deserialize(decoder: Decoder) = Base64ByteArray(decoder.decodeString().decodeBase64Bytes())
|
||||
}
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (this === other) return true
|
||||
if (other == null || this::class != other::class) return false
|
||||
other as Base64ByteArray
|
||||
return value.contentEquals(other.value)
|
||||
}
|
||||
|
||||
override fun hashCode(): Int {
|
||||
return value.contentHashCode()
|
||||
}
|
||||
|
||||
override fun toString(): String {
|
||||
return "Base64ByteArray(${hex(value)})"
|
||||
}
|
||||
}
|
@ -0,0 +1,102 @@
|
||||
package org.openapitools.client.infrastructure
|
||||
|
||||
import kotlinx.io.core.*
|
||||
import kotlin.experimental.and
|
||||
|
||||
private val digits = "0123456789abcdef".toCharArray()
|
||||
private const val BASE64_ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
|
||||
private const val BASE64_MASK: Byte = 0x3f
|
||||
private const val BASE64_PAD = '='
|
||||
private val BASE64_INVERSE_ALPHABET = IntArray(256) { BASE64_ALPHABET.indexOf(it.toChar()) }
|
||||
|
||||
private fun String.toCharArray(): CharArray = CharArray(length) { get(it) }
|
||||
private fun ByteArray.clearFrom(from: Int) = (from until size).forEach { this[it] = 0 }
|
||||
private fun Int.toBase64(): Char = BASE64_ALPHABET[this]
|
||||
private fun Byte.fromBase64(): Byte = BASE64_INVERSE_ALPHABET[toInt() and 0xff].toByte() and BASE64_MASK
|
||||
internal fun ByteArray.encodeBase64(): String = buildPacket { writeFully(this@encodeBase64) }.encodeBase64()
|
||||
internal fun String.decodeBase64Bytes(): ByteArray = buildPacket { writeStringUtf8(dropLastWhile { it == BASE64_PAD }) }.decodeBase64Bytes().readBytes()
|
||||
|
||||
/**
|
||||
* Encode [bytes] as a HEX string with no spaces, newlines and `0x` prefixes.
|
||||
*
|
||||
* Taken from https://github.com/ktorio/ktor/blob/master/ktor-utils/common/src/io/ktor/util/Crypto.kt
|
||||
*/
|
||||
internal fun hex(bytes: ByteArray): String {
|
||||
val result = CharArray(bytes.size * 2)
|
||||
var resultIndex = 0
|
||||
val digits = digits
|
||||
|
||||
for (element in bytes) {
|
||||
val b = element.toInt() and 0xff
|
||||
result[resultIndex++] = digits[b shr 4]
|
||||
result[resultIndex++] = digits[b and 0x0f]
|
||||
}
|
||||
|
||||
return String(result)
|
||||
}
|
||||
|
||||
/**
|
||||
* Decode bytes from HEX string. It should be no spaces and `0x` prefixes.
|
||||
*
|
||||
* Taken from https://github.com/ktorio/ktor/blob/master/ktor-utils/common/src/io/ktor/util/Crypto.kt
|
||||
*/
|
||||
internal fun hex(s: String): ByteArray {
|
||||
val result = ByteArray(s.length / 2)
|
||||
for (idx in result.indices) {
|
||||
val srcIdx = idx * 2
|
||||
val high = s[srcIdx].toString().toInt(16) shl 4
|
||||
val low = s[srcIdx + 1].toString().toInt(16)
|
||||
result[idx] = (high or low).toByte()
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* Encode [ByteReadPacket] in base64 format.
|
||||
*
|
||||
* Taken from https://github.com/ktorio/ktor/blob/424d1d2cfaa3281302c60af9500f738c8c2fc846/ktor-utils/common/src/io/ktor/util/Base64.kt
|
||||
*/
|
||||
private fun ByteReadPacket.encodeBase64(): String = buildString {
|
||||
val data = ByteArray(3)
|
||||
while (remaining > 0) {
|
||||
val read = readAvailable(data)
|
||||
data.clearFrom(read)
|
||||
|
||||
val padSize = (data.size - read) * 8 / 6
|
||||
val chunk = ((data[0].toInt() and 0xFF) shl 16) or
|
||||
((data[1].toInt() and 0xFF) shl 8) or
|
||||
(data[2].toInt() and 0xFF)
|
||||
|
||||
for (index in data.size downTo padSize) {
|
||||
val char = (chunk shr (6 * index)) and BASE64_MASK.toInt()
|
||||
append(char.toBase64())
|
||||
}
|
||||
|
||||
repeat(padSize) { append(BASE64_PAD) }
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Decode [ByteReadPacket] from base64 format
|
||||
*
|
||||
* Taken from https://github.com/ktorio/ktor/blob/424d1d2cfaa3281302c60af9500f738c8c2fc846/ktor-utils/common/src/io/ktor/util/Base64.kt
|
||||
*/
|
||||
private fun ByteReadPacket.decodeBase64Bytes(): Input = buildPacket {
|
||||
val data = ByteArray(4)
|
||||
|
||||
while (remaining > 0) {
|
||||
val read = readAvailable(data)
|
||||
|
||||
val chunk = data.foldIndexed(0) { index, result, current ->
|
||||
result or (current.fromBase64().toInt() shl ((3 - index) * 6))
|
||||
}
|
||||
|
||||
for (index in data.size - 2 downTo (data.size - read)) {
|
||||
val origin = (chunk shr (8 * index)) and 0xff
|
||||
writeByte(origin.toByte())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,29 @@
|
||||
package org.openapitools.client.infrastructure
|
||||
|
||||
import kotlinx.serialization.*
|
||||
import kotlinx.serialization.internal.StringDescriptor
|
||||
|
||||
@Serializable
|
||||
class OctetByteArray(val value: ByteArray) {
|
||||
@Serializer(OctetByteArray::class)
|
||||
companion object : KSerializer<OctetByteArray> {
|
||||
override val descriptor = StringDescriptor.withName("OctetByteArray")
|
||||
override fun serialize(encoder: Encoder, obj: OctetByteArray) = encoder.encodeString(hex(obj.value))
|
||||
override fun deserialize(decoder: Decoder) = OctetByteArray(hex(decoder.decodeString()))
|
||||
}
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (this === other) return true
|
||||
if (other == null || this::class != other::class) return false
|
||||
other as OctetByteArray
|
||||
return value.contentEquals(other.value)
|
||||
}
|
||||
|
||||
override fun hashCode(): Int {
|
||||
return value.contentHashCode()
|
||||
}
|
||||
|
||||
override fun toString(): String {
|
||||
return "OctetByteArray(${hex(value)})"
|
||||
}
|
||||
}
|
@ -12,5 +12,5 @@ data class RequestConfig(
|
||||
val method: RequestMethod,
|
||||
val path: String,
|
||||
val headers: MutableMap<String, String> = mutableMapOf(),
|
||||
val query: Map<String, List<String>> = mapOf()
|
||||
val query: MutableMap<String, List<String>> = mutableMapOf()
|
||||
)
|
@ -46,7 +46,7 @@ data class Order (
|
||||
approved("approved"),
|
||||
delivered("delivered");
|
||||
|
||||
object Serializer : CommonEnumSerializer<Status>("Status", values(), values().map { it.value }.toTypedArray())
|
||||
object Serializer : CommonEnumSerializer<Status>("Status", values(), values().map { it.value.toString() }.toTypedArray())
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -48,7 +48,7 @@ data class Pet (
|
||||
pending("pending"),
|
||||
sold("sold");
|
||||
|
||||
object Serializer : CommonEnumSerializer<Status>("Status", values(), values().map { it.value }.toTypedArray())
|
||||
object Serializer : CommonEnumSerializer<Status>("Status", values(), values().map { it.value.toString() }.toTypedArray())
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,7 @@
|
||||
package util
|
||||
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.GlobalScope
|
||||
import kotlinx.coroutines.promise
|
||||
|
||||
actual fun <T> runTest(block: suspend (scope : CoroutineScope) -> T): dynamic = GlobalScope.promise { block(this) }
|
@ -36,7 +36,7 @@ internal class PetApi(basePath: kotlin.String = "http://petstore.swagger.io/v2")
|
||||
*/
|
||||
fun addPet(body: Pet) : Unit {
|
||||
val localVariableBody: kotlin.Any? = body
|
||||
val localVariableQuery: MultiValueMap = mapOf()
|
||||
val localVariableQuery: MultiValueMap = mutableMapOf()
|
||||
val localVariableHeaders: MutableMap<String, String> = mutableMapOf()
|
||||
val localVariableConfig = RequestConfig(
|
||||
RequestMethod.POST,
|
||||
@ -67,7 +67,7 @@ internal class PetApi(basePath: kotlin.String = "http://petstore.swagger.io/v2")
|
||||
*/
|
||||
fun deletePet(petId: kotlin.Long, apiKey: kotlin.String?) : Unit {
|
||||
val localVariableBody: kotlin.Any? = null
|
||||
val localVariableQuery: MultiValueMap = mapOf()
|
||||
val localVariableQuery: MultiValueMap = mutableMapOf()
|
||||
val localVariableHeaders: MutableMap<String, String> = mutableMapOf("api_key" to apiKey.toString())
|
||||
val localVariableConfig = RequestConfig(
|
||||
RequestMethod.DELETE,
|
||||
@ -166,7 +166,7 @@ internal class PetApi(basePath: kotlin.String = "http://petstore.swagger.io/v2")
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
fun getPetById(petId: kotlin.Long) : Pet {
|
||||
val localVariableBody: kotlin.Any? = null
|
||||
val localVariableQuery: MultiValueMap = mapOf()
|
||||
val localVariableQuery: MultiValueMap = mutableMapOf()
|
||||
val localVariableHeaders: MutableMap<String, String> = mutableMapOf()
|
||||
val localVariableConfig = RequestConfig(
|
||||
RequestMethod.GET,
|
||||
@ -196,7 +196,7 @@ internal class PetApi(basePath: kotlin.String = "http://petstore.swagger.io/v2")
|
||||
*/
|
||||
fun updatePet(body: Pet) : Unit {
|
||||
val localVariableBody: kotlin.Any? = body
|
||||
val localVariableQuery: MultiValueMap = mapOf()
|
||||
val localVariableQuery: MultiValueMap = mutableMapOf()
|
||||
val localVariableHeaders: MutableMap<String, String> = mutableMapOf()
|
||||
val localVariableConfig = RequestConfig(
|
||||
RequestMethod.PUT,
|
||||
@ -228,7 +228,7 @@ internal class PetApi(basePath: kotlin.String = "http://petstore.swagger.io/v2")
|
||||
*/
|
||||
fun updatePetWithForm(petId: kotlin.Long, name: kotlin.String?, status: kotlin.String?) : Unit {
|
||||
val localVariableBody: kotlin.Any? = mapOf("name" to "$name", "status" to "$status")
|
||||
val localVariableQuery: MultiValueMap = mapOf()
|
||||
val localVariableQuery: MultiValueMap = mutableMapOf()
|
||||
val localVariableHeaders: MutableMap<String, String> = mutableMapOf("Content-Type" to "")
|
||||
val localVariableConfig = RequestConfig(
|
||||
RequestMethod.POST,
|
||||
@ -261,7 +261,7 @@ internal class PetApi(basePath: kotlin.String = "http://petstore.swagger.io/v2")
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
fun uploadFile(petId: kotlin.Long, additionalMetadata: kotlin.String?, file: java.io.File?) : ApiResponse {
|
||||
val localVariableBody: kotlin.Any? = mapOf("additionalMetadata" to "$additionalMetadata", "file" to "$file")
|
||||
val localVariableQuery: MultiValueMap = mapOf()
|
||||
val localVariableQuery: MultiValueMap = mutableMapOf()
|
||||
val localVariableHeaders: MutableMap<String, String> = mutableMapOf("Content-Type" to "")
|
||||
val localVariableConfig = RequestConfig(
|
||||
RequestMethod.POST,
|
||||
|
@ -35,7 +35,7 @@ internal class StoreApi(basePath: kotlin.String = "http://petstore.swagger.io/v2
|
||||
*/
|
||||
fun deleteOrder(orderId: kotlin.String) : Unit {
|
||||
val localVariableBody: kotlin.Any? = null
|
||||
val localVariableQuery: MultiValueMap = mapOf()
|
||||
val localVariableQuery: MultiValueMap = mutableMapOf()
|
||||
val localVariableHeaders: MutableMap<String, String> = mutableMapOf()
|
||||
val localVariableConfig = RequestConfig(
|
||||
RequestMethod.DELETE,
|
||||
@ -65,7 +65,7 @@ internal class StoreApi(basePath: kotlin.String = "http://petstore.swagger.io/v2
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
fun getInventory() : kotlin.collections.Map<kotlin.String, kotlin.Int> {
|
||||
val localVariableBody: kotlin.Any? = null
|
||||
val localVariableQuery: MultiValueMap = mapOf()
|
||||
val localVariableQuery: MultiValueMap = mutableMapOf()
|
||||
val localVariableHeaders: MutableMap<String, String> = mutableMapOf()
|
||||
val localVariableConfig = RequestConfig(
|
||||
RequestMethod.GET,
|
||||
@ -96,7 +96,7 @@ internal class StoreApi(basePath: kotlin.String = "http://petstore.swagger.io/v2
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
fun getOrderById(orderId: kotlin.Long) : Order {
|
||||
val localVariableBody: kotlin.Any? = null
|
||||
val localVariableQuery: MultiValueMap = mapOf()
|
||||
val localVariableQuery: MultiValueMap = mutableMapOf()
|
||||
val localVariableHeaders: MutableMap<String, String> = mutableMapOf()
|
||||
val localVariableConfig = RequestConfig(
|
||||
RequestMethod.GET,
|
||||
@ -127,7 +127,7 @@ internal class StoreApi(basePath: kotlin.String = "http://petstore.swagger.io/v2
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
fun placeOrder(body: Order) : Order {
|
||||
val localVariableBody: kotlin.Any? = body
|
||||
val localVariableQuery: MultiValueMap = mapOf()
|
||||
val localVariableQuery: MultiValueMap = mutableMapOf()
|
||||
val localVariableHeaders: MutableMap<String, String> = mutableMapOf()
|
||||
val localVariableConfig = RequestConfig(
|
||||
RequestMethod.POST,
|
||||
|
@ -35,7 +35,7 @@ internal class UserApi(basePath: kotlin.String = "http://petstore.swagger.io/v2"
|
||||
*/
|
||||
fun createUser(body: User) : Unit {
|
||||
val localVariableBody: kotlin.Any? = body
|
||||
val localVariableQuery: MultiValueMap = mapOf()
|
||||
val localVariableQuery: MultiValueMap = mutableMapOf()
|
||||
val localVariableHeaders: MutableMap<String, String> = mutableMapOf()
|
||||
val localVariableConfig = RequestConfig(
|
||||
RequestMethod.POST,
|
||||
@ -65,7 +65,7 @@ internal class UserApi(basePath: kotlin.String = "http://petstore.swagger.io/v2"
|
||||
*/
|
||||
fun createUsersWithArrayInput(body: kotlin.Array<User>) : Unit {
|
||||
val localVariableBody: kotlin.Any? = body
|
||||
val localVariableQuery: MultiValueMap = mapOf()
|
||||
val localVariableQuery: MultiValueMap = mutableMapOf()
|
||||
val localVariableHeaders: MutableMap<String, String> = mutableMapOf()
|
||||
val localVariableConfig = RequestConfig(
|
||||
RequestMethod.POST,
|
||||
@ -95,7 +95,7 @@ internal class UserApi(basePath: kotlin.String = "http://petstore.swagger.io/v2"
|
||||
*/
|
||||
fun createUsersWithListInput(body: kotlin.Array<User>) : Unit {
|
||||
val localVariableBody: kotlin.Any? = body
|
||||
val localVariableQuery: MultiValueMap = mapOf()
|
||||
val localVariableQuery: MultiValueMap = mutableMapOf()
|
||||
val localVariableHeaders: MutableMap<String, String> = mutableMapOf()
|
||||
val localVariableConfig = RequestConfig(
|
||||
RequestMethod.POST,
|
||||
@ -125,7 +125,7 @@ internal class UserApi(basePath: kotlin.String = "http://petstore.swagger.io/v2"
|
||||
*/
|
||||
fun deleteUser(username: kotlin.String) : Unit {
|
||||
val localVariableBody: kotlin.Any? = null
|
||||
val localVariableQuery: MultiValueMap = mapOf()
|
||||
val localVariableQuery: MultiValueMap = mutableMapOf()
|
||||
val localVariableHeaders: MutableMap<String, String> = mutableMapOf()
|
||||
val localVariableConfig = RequestConfig(
|
||||
RequestMethod.DELETE,
|
||||
@ -156,7 +156,7 @@ internal class UserApi(basePath: kotlin.String = "http://petstore.swagger.io/v2"
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
fun getUserByName(username: kotlin.String) : User {
|
||||
val localVariableBody: kotlin.Any? = null
|
||||
val localVariableQuery: MultiValueMap = mapOf()
|
||||
val localVariableQuery: MultiValueMap = mutableMapOf()
|
||||
val localVariableHeaders: MutableMap<String, String> = mutableMapOf()
|
||||
val localVariableConfig = RequestConfig(
|
||||
RequestMethod.GET,
|
||||
@ -221,7 +221,7 @@ internal class UserApi(basePath: kotlin.String = "http://petstore.swagger.io/v2"
|
||||
*/
|
||||
fun logoutUser() : Unit {
|
||||
val localVariableBody: kotlin.Any? = null
|
||||
val localVariableQuery: MultiValueMap = mapOf()
|
||||
val localVariableQuery: MultiValueMap = mutableMapOf()
|
||||
val localVariableHeaders: MutableMap<String, String> = mutableMapOf()
|
||||
val localVariableConfig = RequestConfig(
|
||||
RequestMethod.GET,
|
||||
@ -252,7 +252,7 @@ internal class UserApi(basePath: kotlin.String = "http://petstore.swagger.io/v2"
|
||||
*/
|
||||
fun updateUser(username: kotlin.String, body: User) : Unit {
|
||||
val localVariableBody: kotlin.Any? = body
|
||||
val localVariableQuery: MultiValueMap = mapOf()
|
||||
val localVariableQuery: MultiValueMap = mutableMapOf()
|
||||
val localVariableHeaders: MutableMap<String, String> = mutableMapOf()
|
||||
val localVariableConfig = RequestConfig(
|
||||
RequestMethod.PUT,
|
||||
|
@ -1,6 +1,6 @@
|
||||
package org.openapitools.client.infrastructure
|
||||
|
||||
typealias MultiValueMap = Map<String,List<String>>
|
||||
typealias MultiValueMap = MutableMap<String,List<String>>
|
||||
|
||||
internal fun collectionDelimiter(collectionFormat: String) = when(collectionFormat) {
|
||||
"csv" -> ","
|
||||
|
@ -12,5 +12,5 @@ internal data class RequestConfig(
|
||||
val method: RequestMethod,
|
||||
val path: String,
|
||||
val headers: MutableMap<String, String> = mutableMapOf(),
|
||||
val query: Map<String, List<String>> = mapOf()
|
||||
val query: MutableMap<String, List<String>> = mutableMapOf()
|
||||
)
|
@ -36,7 +36,7 @@ class PetApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCli
|
||||
*/
|
||||
fun addPet(body: Pet) : Unit {
|
||||
val localVariableBody: kotlin.Any? = body
|
||||
val localVariableQuery: MultiValueMap = mapOf()
|
||||
val localVariableQuery: MultiValueMap = mutableMapOf()
|
||||
val localVariableHeaders: MutableMap<String, String> = mutableMapOf()
|
||||
val localVariableConfig = RequestConfig(
|
||||
RequestMethod.POST,
|
||||
@ -67,7 +67,7 @@ class PetApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCli
|
||||
*/
|
||||
fun deletePet(petId: kotlin.Long, apiKey: kotlin.String?) : Unit {
|
||||
val localVariableBody: kotlin.Any? = null
|
||||
val localVariableQuery: MultiValueMap = mapOf()
|
||||
val localVariableQuery: MultiValueMap = mutableMapOf()
|
||||
val localVariableHeaders: MutableMap<String, String> = mutableMapOf("api_key" to apiKey.toString())
|
||||
val localVariableConfig = RequestConfig(
|
||||
RequestMethod.DELETE,
|
||||
@ -166,7 +166,7 @@ class PetApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCli
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
fun getPetById(petId: kotlin.Long) : Pet {
|
||||
val localVariableBody: kotlin.Any? = null
|
||||
val localVariableQuery: MultiValueMap = mapOf()
|
||||
val localVariableQuery: MultiValueMap = mutableMapOf()
|
||||
val localVariableHeaders: MutableMap<String, String> = mutableMapOf()
|
||||
val localVariableConfig = RequestConfig(
|
||||
RequestMethod.GET,
|
||||
@ -196,7 +196,7 @@ class PetApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCli
|
||||
*/
|
||||
fun updatePet(body: Pet) : Unit {
|
||||
val localVariableBody: kotlin.Any? = body
|
||||
val localVariableQuery: MultiValueMap = mapOf()
|
||||
val localVariableQuery: MultiValueMap = mutableMapOf()
|
||||
val localVariableHeaders: MutableMap<String, String> = mutableMapOf()
|
||||
val localVariableConfig = RequestConfig(
|
||||
RequestMethod.PUT,
|
||||
@ -228,7 +228,7 @@ class PetApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCli
|
||||
*/
|
||||
fun updatePetWithForm(petId: kotlin.Long, name: kotlin.String?, status: kotlin.String?) : Unit {
|
||||
val localVariableBody: kotlin.Any? = mapOf("name" to "$name", "status" to "$status")
|
||||
val localVariableQuery: MultiValueMap = mapOf()
|
||||
val localVariableQuery: MultiValueMap = mutableMapOf()
|
||||
val localVariableHeaders: MutableMap<String, String> = mutableMapOf("Content-Type" to "")
|
||||
val localVariableConfig = RequestConfig(
|
||||
RequestMethod.POST,
|
||||
@ -261,7 +261,7 @@ class PetApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCli
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
fun uploadFile(petId: kotlin.Long, additionalMetadata: kotlin.String?, file: java.io.File?) : ApiResponse {
|
||||
val localVariableBody: kotlin.Any? = mapOf("additionalMetadata" to "$additionalMetadata", "file" to "$file")
|
||||
val localVariableQuery: MultiValueMap = mapOf()
|
||||
val localVariableQuery: MultiValueMap = mutableMapOf()
|
||||
val localVariableHeaders: MutableMap<String, String> = mutableMapOf("Content-Type" to "")
|
||||
val localVariableConfig = RequestConfig(
|
||||
RequestMethod.POST,
|
||||
|
@ -35,7 +35,7 @@ class StoreApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiC
|
||||
*/
|
||||
fun deleteOrder(orderId: kotlin.String) : Unit {
|
||||
val localVariableBody: kotlin.Any? = null
|
||||
val localVariableQuery: MultiValueMap = mapOf()
|
||||
val localVariableQuery: MultiValueMap = mutableMapOf()
|
||||
val localVariableHeaders: MutableMap<String, String> = mutableMapOf()
|
||||
val localVariableConfig = RequestConfig(
|
||||
RequestMethod.DELETE,
|
||||
@ -65,7 +65,7 @@ class StoreApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiC
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
fun getInventory() : kotlin.collections.Map<kotlin.String, kotlin.Int> {
|
||||
val localVariableBody: kotlin.Any? = null
|
||||
val localVariableQuery: MultiValueMap = mapOf()
|
||||
val localVariableQuery: MultiValueMap = mutableMapOf()
|
||||
val localVariableHeaders: MutableMap<String, String> = mutableMapOf()
|
||||
val localVariableConfig = RequestConfig(
|
||||
RequestMethod.GET,
|
||||
@ -96,7 +96,7 @@ class StoreApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiC
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
fun getOrderById(orderId: kotlin.Long) : Order {
|
||||
val localVariableBody: kotlin.Any? = null
|
||||
val localVariableQuery: MultiValueMap = mapOf()
|
||||
val localVariableQuery: MultiValueMap = mutableMapOf()
|
||||
val localVariableHeaders: MutableMap<String, String> = mutableMapOf()
|
||||
val localVariableConfig = RequestConfig(
|
||||
RequestMethod.GET,
|
||||
@ -127,7 +127,7 @@ class StoreApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiC
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
fun placeOrder(body: Order) : Order {
|
||||
val localVariableBody: kotlin.Any? = body
|
||||
val localVariableQuery: MultiValueMap = mapOf()
|
||||
val localVariableQuery: MultiValueMap = mutableMapOf()
|
||||
val localVariableHeaders: MutableMap<String, String> = mutableMapOf()
|
||||
val localVariableConfig = RequestConfig(
|
||||
RequestMethod.POST,
|
||||
|
@ -35,7 +35,7 @@ class UserApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCl
|
||||
*/
|
||||
fun createUser(body: User) : Unit {
|
||||
val localVariableBody: kotlin.Any? = body
|
||||
val localVariableQuery: MultiValueMap = mapOf()
|
||||
val localVariableQuery: MultiValueMap = mutableMapOf()
|
||||
val localVariableHeaders: MutableMap<String, String> = mutableMapOf()
|
||||
val localVariableConfig = RequestConfig(
|
||||
RequestMethod.POST,
|
||||
@ -65,7 +65,7 @@ class UserApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCl
|
||||
*/
|
||||
fun createUsersWithArrayInput(body: kotlin.Array<User>) : Unit {
|
||||
val localVariableBody: kotlin.Any? = body
|
||||
val localVariableQuery: MultiValueMap = mapOf()
|
||||
val localVariableQuery: MultiValueMap = mutableMapOf()
|
||||
val localVariableHeaders: MutableMap<String, String> = mutableMapOf()
|
||||
val localVariableConfig = RequestConfig(
|
||||
RequestMethod.POST,
|
||||
@ -95,7 +95,7 @@ class UserApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCl
|
||||
*/
|
||||
fun createUsersWithListInput(body: kotlin.Array<User>) : Unit {
|
||||
val localVariableBody: kotlin.Any? = body
|
||||
val localVariableQuery: MultiValueMap = mapOf()
|
||||
val localVariableQuery: MultiValueMap = mutableMapOf()
|
||||
val localVariableHeaders: MutableMap<String, String> = mutableMapOf()
|
||||
val localVariableConfig = RequestConfig(
|
||||
RequestMethod.POST,
|
||||
@ -125,7 +125,7 @@ class UserApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCl
|
||||
*/
|
||||
fun deleteUser(username: kotlin.String) : Unit {
|
||||
val localVariableBody: kotlin.Any? = null
|
||||
val localVariableQuery: MultiValueMap = mapOf()
|
||||
val localVariableQuery: MultiValueMap = mutableMapOf()
|
||||
val localVariableHeaders: MutableMap<String, String> = mutableMapOf()
|
||||
val localVariableConfig = RequestConfig(
|
||||
RequestMethod.DELETE,
|
||||
@ -156,7 +156,7 @@ class UserApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCl
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
fun getUserByName(username: kotlin.String) : User {
|
||||
val localVariableBody: kotlin.Any? = null
|
||||
val localVariableQuery: MultiValueMap = mapOf()
|
||||
val localVariableQuery: MultiValueMap = mutableMapOf()
|
||||
val localVariableHeaders: MutableMap<String, String> = mutableMapOf()
|
||||
val localVariableConfig = RequestConfig(
|
||||
RequestMethod.GET,
|
||||
@ -221,7 +221,7 @@ class UserApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCl
|
||||
*/
|
||||
fun logoutUser() : Unit {
|
||||
val localVariableBody: kotlin.Any? = null
|
||||
val localVariableQuery: MultiValueMap = mapOf()
|
||||
val localVariableQuery: MultiValueMap = mutableMapOf()
|
||||
val localVariableHeaders: MutableMap<String, String> = mutableMapOf()
|
||||
val localVariableConfig = RequestConfig(
|
||||
RequestMethod.GET,
|
||||
@ -252,7 +252,7 @@ class UserApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCl
|
||||
*/
|
||||
fun updateUser(username: kotlin.String, body: User) : Unit {
|
||||
val localVariableBody: kotlin.Any? = body
|
||||
val localVariableQuery: MultiValueMap = mapOf()
|
||||
val localVariableQuery: MultiValueMap = mutableMapOf()
|
||||
val localVariableHeaders: MutableMap<String, String> = mutableMapOf()
|
||||
val localVariableConfig = RequestConfig(
|
||||
RequestMethod.PUT,
|
||||
|
@ -1,6 +1,6 @@
|
||||
package org.openapitools.client.infrastructure
|
||||
|
||||
typealias MultiValueMap = Map<String,List<String>>
|
||||
typealias MultiValueMap = MutableMap<String,List<String>>
|
||||
|
||||
fun collectionDelimiter(collectionFormat: String) = when(collectionFormat) {
|
||||
"csv" -> ","
|
||||
|
@ -12,5 +12,5 @@ data class RequestConfig(
|
||||
val method: RequestMethod,
|
||||
val path: String,
|
||||
val headers: MutableMap<String, String> = mutableMapOf(),
|
||||
val query: Map<String, List<String>> = mapOf()
|
||||
val query: MutableMap<String, List<String>> = mutableMapOf()
|
||||
)
|
@ -36,7 +36,7 @@ class PetApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCli
|
||||
*/
|
||||
fun addPet(body: Pet) : Unit {
|
||||
val localVariableBody: kotlin.Any? = body
|
||||
val localVariableQuery: MultiValueMap = mapOf()
|
||||
val localVariableQuery: MultiValueMap = mutableMapOf()
|
||||
val localVariableHeaders: MutableMap<String, String> = mutableMapOf()
|
||||
val localVariableConfig = RequestConfig(
|
||||
RequestMethod.POST,
|
||||
@ -67,7 +67,7 @@ class PetApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCli
|
||||
*/
|
||||
fun deletePet(petId: kotlin.Long, apiKey: kotlin.String?) : Unit {
|
||||
val localVariableBody: kotlin.Any? = null
|
||||
val localVariableQuery: MultiValueMap = mapOf()
|
||||
val localVariableQuery: MultiValueMap = mutableMapOf()
|
||||
val localVariableHeaders: MutableMap<String, String> = mutableMapOf("api_key" to apiKey.toString())
|
||||
val localVariableConfig = RequestConfig(
|
||||
RequestMethod.DELETE,
|
||||
@ -166,7 +166,7 @@ class PetApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCli
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
fun getPetById(petId: kotlin.Long) : Pet {
|
||||
val localVariableBody: kotlin.Any? = null
|
||||
val localVariableQuery: MultiValueMap = mapOf()
|
||||
val localVariableQuery: MultiValueMap = mutableMapOf()
|
||||
val localVariableHeaders: MutableMap<String, String> = mutableMapOf()
|
||||
val localVariableConfig = RequestConfig(
|
||||
RequestMethod.GET,
|
||||
@ -196,7 +196,7 @@ class PetApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCli
|
||||
*/
|
||||
fun updatePet(body: Pet) : Unit {
|
||||
val localVariableBody: kotlin.Any? = body
|
||||
val localVariableQuery: MultiValueMap = mapOf()
|
||||
val localVariableQuery: MultiValueMap = mutableMapOf()
|
||||
val localVariableHeaders: MutableMap<String, String> = mutableMapOf()
|
||||
val localVariableConfig = RequestConfig(
|
||||
RequestMethod.PUT,
|
||||
@ -228,7 +228,7 @@ class PetApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCli
|
||||
*/
|
||||
fun updatePetWithForm(petId: kotlin.Long, name: kotlin.String?, status: kotlin.String?) : Unit {
|
||||
val localVariableBody: kotlin.Any? = mapOf("name" to "$name", "status" to "$status")
|
||||
val localVariableQuery: MultiValueMap = mapOf()
|
||||
val localVariableQuery: MultiValueMap = mutableMapOf()
|
||||
val localVariableHeaders: MutableMap<String, String> = mutableMapOf("Content-Type" to "")
|
||||
val localVariableConfig = RequestConfig(
|
||||
RequestMethod.POST,
|
||||
@ -261,7 +261,7 @@ class PetApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCli
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
fun uploadFile(petId: kotlin.Long, additionalMetadata: kotlin.String?, file: java.io.File?) : ApiResponse {
|
||||
val localVariableBody: kotlin.Any? = mapOf("additionalMetadata" to "$additionalMetadata", "file" to "$file")
|
||||
val localVariableQuery: MultiValueMap = mapOf()
|
||||
val localVariableQuery: MultiValueMap = mutableMapOf()
|
||||
val localVariableHeaders: MutableMap<String, String> = mutableMapOf("Content-Type" to "")
|
||||
val localVariableConfig = RequestConfig(
|
||||
RequestMethod.POST,
|
||||
|
@ -35,7 +35,7 @@ class StoreApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiC
|
||||
*/
|
||||
fun deleteOrder(orderId: kotlin.String) : Unit {
|
||||
val localVariableBody: kotlin.Any? = null
|
||||
val localVariableQuery: MultiValueMap = mapOf()
|
||||
val localVariableQuery: MultiValueMap = mutableMapOf()
|
||||
val localVariableHeaders: MutableMap<String, String> = mutableMapOf()
|
||||
val localVariableConfig = RequestConfig(
|
||||
RequestMethod.DELETE,
|
||||
@ -65,7 +65,7 @@ class StoreApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiC
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
fun getInventory() : kotlin.collections.Map<kotlin.String, kotlin.Int> {
|
||||
val localVariableBody: kotlin.Any? = null
|
||||
val localVariableQuery: MultiValueMap = mapOf()
|
||||
val localVariableQuery: MultiValueMap = mutableMapOf()
|
||||
val localVariableHeaders: MutableMap<String, String> = mutableMapOf()
|
||||
val localVariableConfig = RequestConfig(
|
||||
RequestMethod.GET,
|
||||
@ -96,7 +96,7 @@ class StoreApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiC
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
fun getOrderById(orderId: kotlin.Long) : Order {
|
||||
val localVariableBody: kotlin.Any? = null
|
||||
val localVariableQuery: MultiValueMap = mapOf()
|
||||
val localVariableQuery: MultiValueMap = mutableMapOf()
|
||||
val localVariableHeaders: MutableMap<String, String> = mutableMapOf()
|
||||
val localVariableConfig = RequestConfig(
|
||||
RequestMethod.GET,
|
||||
@ -127,7 +127,7 @@ class StoreApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiC
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
fun placeOrder(body: Order) : Order {
|
||||
val localVariableBody: kotlin.Any? = body
|
||||
val localVariableQuery: MultiValueMap = mapOf()
|
||||
val localVariableQuery: MultiValueMap = mutableMapOf()
|
||||
val localVariableHeaders: MutableMap<String, String> = mutableMapOf()
|
||||
val localVariableConfig = RequestConfig(
|
||||
RequestMethod.POST,
|
||||
|
@ -35,7 +35,7 @@ class UserApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCl
|
||||
*/
|
||||
fun createUser(body: User) : Unit {
|
||||
val localVariableBody: kotlin.Any? = body
|
||||
val localVariableQuery: MultiValueMap = mapOf()
|
||||
val localVariableQuery: MultiValueMap = mutableMapOf()
|
||||
val localVariableHeaders: MutableMap<String, String> = mutableMapOf()
|
||||
val localVariableConfig = RequestConfig(
|
||||
RequestMethod.POST,
|
||||
@ -65,7 +65,7 @@ class UserApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCl
|
||||
*/
|
||||
fun createUsersWithArrayInput(body: kotlin.Array<User>) : Unit {
|
||||
val localVariableBody: kotlin.Any? = body
|
||||
val localVariableQuery: MultiValueMap = mapOf()
|
||||
val localVariableQuery: MultiValueMap = mutableMapOf()
|
||||
val localVariableHeaders: MutableMap<String, String> = mutableMapOf()
|
||||
val localVariableConfig = RequestConfig(
|
||||
RequestMethod.POST,
|
||||
@ -95,7 +95,7 @@ class UserApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCl
|
||||
*/
|
||||
fun createUsersWithListInput(body: kotlin.Array<User>) : Unit {
|
||||
val localVariableBody: kotlin.Any? = body
|
||||
val localVariableQuery: MultiValueMap = mapOf()
|
||||
val localVariableQuery: MultiValueMap = mutableMapOf()
|
||||
val localVariableHeaders: MutableMap<String, String> = mutableMapOf()
|
||||
val localVariableConfig = RequestConfig(
|
||||
RequestMethod.POST,
|
||||
@ -125,7 +125,7 @@ class UserApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCl
|
||||
*/
|
||||
fun deleteUser(username: kotlin.String) : Unit {
|
||||
val localVariableBody: kotlin.Any? = null
|
||||
val localVariableQuery: MultiValueMap = mapOf()
|
||||
val localVariableQuery: MultiValueMap = mutableMapOf()
|
||||
val localVariableHeaders: MutableMap<String, String> = mutableMapOf()
|
||||
val localVariableConfig = RequestConfig(
|
||||
RequestMethod.DELETE,
|
||||
@ -156,7 +156,7 @@ class UserApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCl
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
fun getUserByName(username: kotlin.String) : User {
|
||||
val localVariableBody: kotlin.Any? = null
|
||||
val localVariableQuery: MultiValueMap = mapOf()
|
||||
val localVariableQuery: MultiValueMap = mutableMapOf()
|
||||
val localVariableHeaders: MutableMap<String, String> = mutableMapOf()
|
||||
val localVariableConfig = RequestConfig(
|
||||
RequestMethod.GET,
|
||||
@ -221,7 +221,7 @@ class UserApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCl
|
||||
*/
|
||||
fun logoutUser() : Unit {
|
||||
val localVariableBody: kotlin.Any? = null
|
||||
val localVariableQuery: MultiValueMap = mapOf()
|
||||
val localVariableQuery: MultiValueMap = mutableMapOf()
|
||||
val localVariableHeaders: MutableMap<String, String> = mutableMapOf()
|
||||
val localVariableConfig = RequestConfig(
|
||||
RequestMethod.GET,
|
||||
@ -252,7 +252,7 @@ class UserApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCl
|
||||
*/
|
||||
fun updateUser(username: kotlin.String, body: User) : Unit {
|
||||
val localVariableBody: kotlin.Any? = body
|
||||
val localVariableQuery: MultiValueMap = mapOf()
|
||||
val localVariableQuery: MultiValueMap = mutableMapOf()
|
||||
val localVariableHeaders: MutableMap<String, String> = mutableMapOf()
|
||||
val localVariableConfig = RequestConfig(
|
||||
RequestMethod.PUT,
|
||||
|
@ -1,6 +1,6 @@
|
||||
package org.openapitools.client.infrastructure
|
||||
|
||||
typealias MultiValueMap = Map<String,List<String>>
|
||||
typealias MultiValueMap = MutableMap<String,List<String>>
|
||||
|
||||
fun collectionDelimiter(collectionFormat: String) = when(collectionFormat) {
|
||||
"csv" -> ","
|
||||
|
@ -12,5 +12,5 @@ data class RequestConfig(
|
||||
val method: RequestMethod,
|
||||
val path: String,
|
||||
val headers: MutableMap<String, String> = mutableMapOf(),
|
||||
val query: Map<String, List<String>> = mapOf()
|
||||
val query: MutableMap<String, List<String>> = mutableMapOf()
|
||||
)
|
@ -36,7 +36,7 @@ class PetApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCli
|
||||
*/
|
||||
fun addPet(body: Pet) : Unit {
|
||||
val localVariableBody: kotlin.Any? = body
|
||||
val localVariableQuery: MultiValueMap = mapOf()
|
||||
val localVariableQuery: MultiValueMap = mutableMapOf()
|
||||
val localVariableHeaders: MutableMap<String, String> = mutableMapOf()
|
||||
val localVariableConfig = RequestConfig(
|
||||
RequestMethod.POST,
|
||||
@ -67,7 +67,7 @@ class PetApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCli
|
||||
*/
|
||||
fun deletePet(petId: kotlin.Long, apiKey: kotlin.String?) : Unit {
|
||||
val localVariableBody: kotlin.Any? = null
|
||||
val localVariableQuery: MultiValueMap = mapOf()
|
||||
val localVariableQuery: MultiValueMap = mutableMapOf()
|
||||
val localVariableHeaders: MutableMap<String, String> = mutableMapOf("api_key" to apiKey.toString())
|
||||
val localVariableConfig = RequestConfig(
|
||||
RequestMethod.DELETE,
|
||||
@ -166,7 +166,7 @@ class PetApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCli
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
fun getPetById(petId: kotlin.Long) : Pet {
|
||||
val localVariableBody: kotlin.Any? = null
|
||||
val localVariableQuery: MultiValueMap = mapOf()
|
||||
val localVariableQuery: MultiValueMap = mutableMapOf()
|
||||
val localVariableHeaders: MutableMap<String, String> = mutableMapOf()
|
||||
val localVariableConfig = RequestConfig(
|
||||
RequestMethod.GET,
|
||||
@ -196,7 +196,7 @@ class PetApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCli
|
||||
*/
|
||||
fun updatePet(body: Pet) : Unit {
|
||||
val localVariableBody: kotlin.Any? = body
|
||||
val localVariableQuery: MultiValueMap = mapOf()
|
||||
val localVariableQuery: MultiValueMap = mutableMapOf()
|
||||
val localVariableHeaders: MutableMap<String, String> = mutableMapOf()
|
||||
val localVariableConfig = RequestConfig(
|
||||
RequestMethod.PUT,
|
||||
@ -228,7 +228,7 @@ class PetApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCli
|
||||
*/
|
||||
fun updatePetWithForm(petId: kotlin.Long, name: kotlin.String?, status: kotlin.String?) : Unit {
|
||||
val localVariableBody: kotlin.Any? = mapOf("name" to "$name", "status" to "$status")
|
||||
val localVariableQuery: MultiValueMap = mapOf()
|
||||
val localVariableQuery: MultiValueMap = mutableMapOf()
|
||||
val localVariableHeaders: MutableMap<String, String> = mutableMapOf("Content-Type" to "")
|
||||
val localVariableConfig = RequestConfig(
|
||||
RequestMethod.POST,
|
||||
@ -261,7 +261,7 @@ class PetApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCli
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
fun uploadFile(petId: kotlin.Long, additionalMetadata: kotlin.String?, file: java.io.File?) : ApiResponse {
|
||||
val localVariableBody: kotlin.Any? = mapOf("additionalMetadata" to "$additionalMetadata", "file" to "$file")
|
||||
val localVariableQuery: MultiValueMap = mapOf()
|
||||
val localVariableQuery: MultiValueMap = mutableMapOf()
|
||||
val localVariableHeaders: MutableMap<String, String> = mutableMapOf("Content-Type" to "")
|
||||
val localVariableConfig = RequestConfig(
|
||||
RequestMethod.POST,
|
||||
|
@ -35,7 +35,7 @@ class StoreApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiC
|
||||
*/
|
||||
fun deleteOrder(orderId: kotlin.String) : Unit {
|
||||
val localVariableBody: kotlin.Any? = null
|
||||
val localVariableQuery: MultiValueMap = mapOf()
|
||||
val localVariableQuery: MultiValueMap = mutableMapOf()
|
||||
val localVariableHeaders: MutableMap<String, String> = mutableMapOf()
|
||||
val localVariableConfig = RequestConfig(
|
||||
RequestMethod.DELETE,
|
||||
@ -65,7 +65,7 @@ class StoreApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiC
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
fun getInventory() : kotlin.collections.Map<kotlin.String, kotlin.Int> {
|
||||
val localVariableBody: kotlin.Any? = null
|
||||
val localVariableQuery: MultiValueMap = mapOf()
|
||||
val localVariableQuery: MultiValueMap = mutableMapOf()
|
||||
val localVariableHeaders: MutableMap<String, String> = mutableMapOf()
|
||||
val localVariableConfig = RequestConfig(
|
||||
RequestMethod.GET,
|
||||
@ -96,7 +96,7 @@ class StoreApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiC
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
fun getOrderById(orderId: kotlin.Long) : Order {
|
||||
val localVariableBody: kotlin.Any? = null
|
||||
val localVariableQuery: MultiValueMap = mapOf()
|
||||
val localVariableQuery: MultiValueMap = mutableMapOf()
|
||||
val localVariableHeaders: MutableMap<String, String> = mutableMapOf()
|
||||
val localVariableConfig = RequestConfig(
|
||||
RequestMethod.GET,
|
||||
@ -127,7 +127,7 @@ class StoreApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiC
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
fun placeOrder(body: Order) : Order {
|
||||
val localVariableBody: kotlin.Any? = body
|
||||
val localVariableQuery: MultiValueMap = mapOf()
|
||||
val localVariableQuery: MultiValueMap = mutableMapOf()
|
||||
val localVariableHeaders: MutableMap<String, String> = mutableMapOf()
|
||||
val localVariableConfig = RequestConfig(
|
||||
RequestMethod.POST,
|
||||
|
@ -35,7 +35,7 @@ class UserApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCl
|
||||
*/
|
||||
fun createUser(body: User) : Unit {
|
||||
val localVariableBody: kotlin.Any? = body
|
||||
val localVariableQuery: MultiValueMap = mapOf()
|
||||
val localVariableQuery: MultiValueMap = mutableMapOf()
|
||||
val localVariableHeaders: MutableMap<String, String> = mutableMapOf()
|
||||
val localVariableConfig = RequestConfig(
|
||||
RequestMethod.POST,
|
||||
@ -65,7 +65,7 @@ class UserApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCl
|
||||
*/
|
||||
fun createUsersWithArrayInput(body: kotlin.Array<User>) : Unit {
|
||||
val localVariableBody: kotlin.Any? = body
|
||||
val localVariableQuery: MultiValueMap = mapOf()
|
||||
val localVariableQuery: MultiValueMap = mutableMapOf()
|
||||
val localVariableHeaders: MutableMap<String, String> = mutableMapOf()
|
||||
val localVariableConfig = RequestConfig(
|
||||
RequestMethod.POST,
|
||||
@ -95,7 +95,7 @@ class UserApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCl
|
||||
*/
|
||||
fun createUsersWithListInput(body: kotlin.Array<User>) : Unit {
|
||||
val localVariableBody: kotlin.Any? = body
|
||||
val localVariableQuery: MultiValueMap = mapOf()
|
||||
val localVariableQuery: MultiValueMap = mutableMapOf()
|
||||
val localVariableHeaders: MutableMap<String, String> = mutableMapOf()
|
||||
val localVariableConfig = RequestConfig(
|
||||
RequestMethod.POST,
|
||||
@ -125,7 +125,7 @@ class UserApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCl
|
||||
*/
|
||||
fun deleteUser(username: kotlin.String) : Unit {
|
||||
val localVariableBody: kotlin.Any? = null
|
||||
val localVariableQuery: MultiValueMap = mapOf()
|
||||
val localVariableQuery: MultiValueMap = mutableMapOf()
|
||||
val localVariableHeaders: MutableMap<String, String> = mutableMapOf()
|
||||
val localVariableConfig = RequestConfig(
|
||||
RequestMethod.DELETE,
|
||||
@ -156,7 +156,7 @@ class UserApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCl
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
fun getUserByName(username: kotlin.String) : User {
|
||||
val localVariableBody: kotlin.Any? = null
|
||||
val localVariableQuery: MultiValueMap = mapOf()
|
||||
val localVariableQuery: MultiValueMap = mutableMapOf()
|
||||
val localVariableHeaders: MutableMap<String, String> = mutableMapOf()
|
||||
val localVariableConfig = RequestConfig(
|
||||
RequestMethod.GET,
|
||||
@ -221,7 +221,7 @@ class UserApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCl
|
||||
*/
|
||||
fun logoutUser() : Unit {
|
||||
val localVariableBody: kotlin.Any? = null
|
||||
val localVariableQuery: MultiValueMap = mapOf()
|
||||
val localVariableQuery: MultiValueMap = mutableMapOf()
|
||||
val localVariableHeaders: MutableMap<String, String> = mutableMapOf()
|
||||
val localVariableConfig = RequestConfig(
|
||||
RequestMethod.GET,
|
||||
@ -252,7 +252,7 @@ class UserApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCl
|
||||
*/
|
||||
fun updateUser(username: kotlin.String, body: User) : Unit {
|
||||
val localVariableBody: kotlin.Any? = body
|
||||
val localVariableQuery: MultiValueMap = mapOf()
|
||||
val localVariableQuery: MultiValueMap = mutableMapOf()
|
||||
val localVariableHeaders: MutableMap<String, String> = mutableMapOf()
|
||||
val localVariableConfig = RequestConfig(
|
||||
RequestMethod.PUT,
|
||||
|
@ -1,6 +1,6 @@
|
||||
package org.openapitools.client.infrastructure
|
||||
|
||||
typealias MultiValueMap = Map<String,List<String>>
|
||||
typealias MultiValueMap = MutableMap<String,List<String>>
|
||||
|
||||
fun collectionDelimiter(collectionFormat: String) = when(collectionFormat) {
|
||||
"csv" -> ","
|
||||
|
@ -12,5 +12,5 @@ data class RequestConfig(
|
||||
val method: RequestMethod,
|
||||
val path: String,
|
||||
val headers: MutableMap<String, String> = mutableMapOf(),
|
||||
val query: Map<String, List<String>> = mapOf()
|
||||
val query: MutableMap<String, List<String>> = mutableMapOf()
|
||||
)
|
@ -36,7 +36,7 @@ class PetApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCli
|
||||
*/
|
||||
fun addPet(body: Pet) : Unit {
|
||||
val localVariableBody: kotlin.Any? = body
|
||||
val localVariableQuery: MultiValueMap = mapOf()
|
||||
val localVariableQuery: MultiValueMap = mutableMapOf()
|
||||
val localVariableHeaders: MutableMap<String, String> = mutableMapOf()
|
||||
val localVariableConfig = RequestConfig(
|
||||
RequestMethod.POST,
|
||||
@ -67,7 +67,7 @@ class PetApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCli
|
||||
*/
|
||||
fun deletePet(petId: kotlin.Long, apiKey: kotlin.String?) : Unit {
|
||||
val localVariableBody: kotlin.Any? = null
|
||||
val localVariableQuery: MultiValueMap = mapOf()
|
||||
val localVariableQuery: MultiValueMap = mutableMapOf()
|
||||
val localVariableHeaders: MutableMap<String, String> = mutableMapOf("api_key" to apiKey.toString())
|
||||
val localVariableConfig = RequestConfig(
|
||||
RequestMethod.DELETE,
|
||||
@ -166,7 +166,7 @@ class PetApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCli
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
fun getPetById(petId: kotlin.Long) : Pet {
|
||||
val localVariableBody: kotlin.Any? = null
|
||||
val localVariableQuery: MultiValueMap = mapOf()
|
||||
val localVariableQuery: MultiValueMap = mutableMapOf()
|
||||
val localVariableHeaders: MutableMap<String, String> = mutableMapOf()
|
||||
val localVariableConfig = RequestConfig(
|
||||
RequestMethod.GET,
|
||||
@ -196,7 +196,7 @@ class PetApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCli
|
||||
*/
|
||||
fun updatePet(body: Pet) : Unit {
|
||||
val localVariableBody: kotlin.Any? = body
|
||||
val localVariableQuery: MultiValueMap = mapOf()
|
||||
val localVariableQuery: MultiValueMap = mutableMapOf()
|
||||
val localVariableHeaders: MutableMap<String, String> = mutableMapOf()
|
||||
val localVariableConfig = RequestConfig(
|
||||
RequestMethod.PUT,
|
||||
@ -228,7 +228,7 @@ class PetApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCli
|
||||
*/
|
||||
fun updatePetWithForm(petId: kotlin.Long, name: kotlin.String?, status: kotlin.String?) : Unit {
|
||||
val localVariableBody: kotlin.Any? = mapOf("name" to "$name", "status" to "$status")
|
||||
val localVariableQuery: MultiValueMap = mapOf()
|
||||
val localVariableQuery: MultiValueMap = mutableMapOf()
|
||||
val localVariableHeaders: MutableMap<String, String> = mutableMapOf("Content-Type" to "")
|
||||
val localVariableConfig = RequestConfig(
|
||||
RequestMethod.POST,
|
||||
@ -261,7 +261,7 @@ class PetApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCli
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
fun uploadFile(petId: kotlin.Long, additionalMetadata: kotlin.String?, file: java.io.File?) : ApiResponse {
|
||||
val localVariableBody: kotlin.Any? = mapOf("additionalMetadata" to "$additionalMetadata", "file" to "$file")
|
||||
val localVariableQuery: MultiValueMap = mapOf()
|
||||
val localVariableQuery: MultiValueMap = mutableMapOf()
|
||||
val localVariableHeaders: MutableMap<String, String> = mutableMapOf("Content-Type" to "")
|
||||
val localVariableConfig = RequestConfig(
|
||||
RequestMethod.POST,
|
||||
|
@ -35,7 +35,7 @@ class StoreApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiC
|
||||
*/
|
||||
fun deleteOrder(orderId: kotlin.String) : Unit {
|
||||
val localVariableBody: kotlin.Any? = null
|
||||
val localVariableQuery: MultiValueMap = mapOf()
|
||||
val localVariableQuery: MultiValueMap = mutableMapOf()
|
||||
val localVariableHeaders: MutableMap<String, String> = mutableMapOf()
|
||||
val localVariableConfig = RequestConfig(
|
||||
RequestMethod.DELETE,
|
||||
@ -65,7 +65,7 @@ class StoreApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiC
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
fun getInventory() : kotlin.collections.Map<kotlin.String, kotlin.Int> {
|
||||
val localVariableBody: kotlin.Any? = null
|
||||
val localVariableQuery: MultiValueMap = mapOf()
|
||||
val localVariableQuery: MultiValueMap = mutableMapOf()
|
||||
val localVariableHeaders: MutableMap<String, String> = mutableMapOf()
|
||||
val localVariableConfig = RequestConfig(
|
||||
RequestMethod.GET,
|
||||
@ -96,7 +96,7 @@ class StoreApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiC
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
fun getOrderById(orderId: kotlin.Long) : Order {
|
||||
val localVariableBody: kotlin.Any? = null
|
||||
val localVariableQuery: MultiValueMap = mapOf()
|
||||
val localVariableQuery: MultiValueMap = mutableMapOf()
|
||||
val localVariableHeaders: MutableMap<String, String> = mutableMapOf()
|
||||
val localVariableConfig = RequestConfig(
|
||||
RequestMethod.GET,
|
||||
@ -127,7 +127,7 @@ class StoreApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiC
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
fun placeOrder(body: Order) : Order {
|
||||
val localVariableBody: kotlin.Any? = body
|
||||
val localVariableQuery: MultiValueMap = mapOf()
|
||||
val localVariableQuery: MultiValueMap = mutableMapOf()
|
||||
val localVariableHeaders: MutableMap<String, String> = mutableMapOf()
|
||||
val localVariableConfig = RequestConfig(
|
||||
RequestMethod.POST,
|
||||
|
@ -35,7 +35,7 @@ class UserApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCl
|
||||
*/
|
||||
fun createUser(body: User) : Unit {
|
||||
val localVariableBody: kotlin.Any? = body
|
||||
val localVariableQuery: MultiValueMap = mapOf()
|
||||
val localVariableQuery: MultiValueMap = mutableMapOf()
|
||||
val localVariableHeaders: MutableMap<String, String> = mutableMapOf()
|
||||
val localVariableConfig = RequestConfig(
|
||||
RequestMethod.POST,
|
||||
@ -65,7 +65,7 @@ class UserApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCl
|
||||
*/
|
||||
fun createUsersWithArrayInput(body: kotlin.Array<User>) : Unit {
|
||||
val localVariableBody: kotlin.Any? = body
|
||||
val localVariableQuery: MultiValueMap = mapOf()
|
||||
val localVariableQuery: MultiValueMap = mutableMapOf()
|
||||
val localVariableHeaders: MutableMap<String, String> = mutableMapOf()
|
||||
val localVariableConfig = RequestConfig(
|
||||
RequestMethod.POST,
|
||||
@ -95,7 +95,7 @@ class UserApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCl
|
||||
*/
|
||||
fun createUsersWithListInput(body: kotlin.Array<User>) : Unit {
|
||||
val localVariableBody: kotlin.Any? = body
|
||||
val localVariableQuery: MultiValueMap = mapOf()
|
||||
val localVariableQuery: MultiValueMap = mutableMapOf()
|
||||
val localVariableHeaders: MutableMap<String, String> = mutableMapOf()
|
||||
val localVariableConfig = RequestConfig(
|
||||
RequestMethod.POST,
|
||||
@ -125,7 +125,7 @@ class UserApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCl
|
||||
*/
|
||||
fun deleteUser(username: kotlin.String) : Unit {
|
||||
val localVariableBody: kotlin.Any? = null
|
||||
val localVariableQuery: MultiValueMap = mapOf()
|
||||
val localVariableQuery: MultiValueMap = mutableMapOf()
|
||||
val localVariableHeaders: MutableMap<String, String> = mutableMapOf()
|
||||
val localVariableConfig = RequestConfig(
|
||||
RequestMethod.DELETE,
|
||||
@ -156,7 +156,7 @@ class UserApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCl
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
fun getUserByName(username: kotlin.String) : User {
|
||||
val localVariableBody: kotlin.Any? = null
|
||||
val localVariableQuery: MultiValueMap = mapOf()
|
||||
val localVariableQuery: MultiValueMap = mutableMapOf()
|
||||
val localVariableHeaders: MutableMap<String, String> = mutableMapOf()
|
||||
val localVariableConfig = RequestConfig(
|
||||
RequestMethod.GET,
|
||||
@ -221,7 +221,7 @@ class UserApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCl
|
||||
*/
|
||||
fun logoutUser() : Unit {
|
||||
val localVariableBody: kotlin.Any? = null
|
||||
val localVariableQuery: MultiValueMap = mapOf()
|
||||
val localVariableQuery: MultiValueMap = mutableMapOf()
|
||||
val localVariableHeaders: MutableMap<String, String> = mutableMapOf()
|
||||
val localVariableConfig = RequestConfig(
|
||||
RequestMethod.GET,
|
||||
@ -252,7 +252,7 @@ class UserApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCl
|
||||
*/
|
||||
fun updateUser(username: kotlin.String, body: User) : Unit {
|
||||
val localVariableBody: kotlin.Any? = body
|
||||
val localVariableQuery: MultiValueMap = mapOf()
|
||||
val localVariableQuery: MultiValueMap = mutableMapOf()
|
||||
val localVariableHeaders: MutableMap<String, String> = mutableMapOf()
|
||||
val localVariableConfig = RequestConfig(
|
||||
RequestMethod.PUT,
|
||||
|
@ -1,6 +1,6 @@
|
||||
package org.openapitools.client.infrastructure
|
||||
|
||||
typealias MultiValueMap = Map<String,List<String>>
|
||||
typealias MultiValueMap = MutableMap<String,List<String>>
|
||||
|
||||
fun collectionDelimiter(collectionFormat: String) = when(collectionFormat) {
|
||||
"csv" -> ","
|
||||
|
@ -12,5 +12,5 @@ data class RequestConfig(
|
||||
val method: RequestMethod,
|
||||
val path: String,
|
||||
val headers: MutableMap<String, String> = mutableMapOf(),
|
||||
val query: Map<String, List<String>> = mapOf()
|
||||
val query: MutableMap<String, List<String>> = mutableMapOf()
|
||||
)
|
@ -1 +1 @@
|
||||
4.1.3-SNAPSHOT
|
||||
4.2.0-SNAPSHOT
|
@ -30,6 +30,7 @@ kotlin {
|
||||
jvm()
|
||||
iosArm64() { binaries { framework { freeCompilerArgs.add("-Xobjc-generics") } } }
|
||||
iosX64() { binaries { framework { freeCompilerArgs.add("-Xobjc-generics") } } }
|
||||
js()
|
||||
|
||||
sourceSets {
|
||||
commonMain {
|
||||
@ -37,9 +38,9 @@ kotlin {
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-common:$kotlin_version"
|
||||
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core-common:$coroutines_version"
|
||||
implementation "org.jetbrains.kotlinx:kotlinx-serialization-runtime-common:$serialization_version"
|
||||
implementation "io.ktor:ktor-client-core:$ktor_version"
|
||||
implementation "io.ktor:ktor-client-json:$ktor_version"
|
||||
implementation "io.ktor:ktor-client-serialization:$ktor_version"
|
||||
api "io.ktor:ktor-client-core:$ktor_version"
|
||||
api "io.ktor:ktor-client-json:$ktor_version"
|
||||
api "io.ktor:ktor-client-serialization:$ktor_version"
|
||||
}
|
||||
}
|
||||
|
||||
@ -57,9 +58,9 @@ kotlin {
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
|
||||
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version"
|
||||
implementation "org.jetbrains.kotlinx:kotlinx-serialization-runtime:$serialization_version"
|
||||
implementation "io.ktor:ktor-client-core-jvm:$ktor_version"
|
||||
implementation "io.ktor:ktor-client-json-jvm:$ktor_version"
|
||||
implementation "io.ktor:ktor-client-serialization-jvm:$ktor_version"
|
||||
api "io.ktor:ktor-client-core-jvm:$ktor_version"
|
||||
api "io.ktor:ktor-client-json-jvm:$ktor_version"
|
||||
api "io.ktor:ktor-client-serialization-jvm:$ktor_version"
|
||||
}
|
||||
}
|
||||
|
||||
@ -77,7 +78,7 @@ kotlin {
|
||||
dependencies {
|
||||
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core-native:$coroutines_version"
|
||||
implementation "org.jetbrains.kotlinx:kotlinx-serialization-runtime-native:$serialization_version"
|
||||
implementation "io.ktor:ktor-client-ios:$ktor_version"
|
||||
api "io.ktor:ktor-client-ios:$ktor_version"
|
||||
}
|
||||
}
|
||||
|
||||
@ -91,9 +92,9 @@ kotlin {
|
||||
iosArm64().compilations.main.defaultSourceSet {
|
||||
dependsOn iosMain
|
||||
dependencies {
|
||||
implementation "io.ktor:ktor-client-ios-iosarm64:$ktor_version"
|
||||
implementation "io.ktor:ktor-client-json-iosarm64:$ktor_version"
|
||||
implementation "io.ktor:ktor-client-serialization-iosarm64:$ktor_version"
|
||||
api "io.ktor:ktor-client-ios-iosarm64:$ktor_version"
|
||||
api "io.ktor:ktor-client-json-iosarm64:$ktor_version"
|
||||
api "io.ktor:ktor-client-serialization-iosarm64:$ktor_version"
|
||||
}
|
||||
}
|
||||
|
||||
@ -104,9 +105,31 @@ kotlin {
|
||||
iosX64().compilations.main.defaultSourceSet {
|
||||
dependsOn iosMain
|
||||
dependencies {
|
||||
implementation "io.ktor:ktor-client-ios-iosx64:$ktor_version"
|
||||
implementation "io.ktor:ktor-client-json-iosx64:$ktor_version"
|
||||
implementation "io.ktor:ktor-client-serialization-iosx64:$ktor_version"
|
||||
api "io.ktor:ktor-client-ios-iosx64:$ktor_version"
|
||||
api "io.ktor:ktor-client-json-iosx64:$ktor_version"
|
||||
api "io.ktor:ktor-client-serialization-iosx64:$ktor_version"
|
||||
}
|
||||
}
|
||||
|
||||
jsMain {
|
||||
dependsOn commonMain
|
||||
dependencies {
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-js:$kotlin_version"
|
||||
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core-js:$coroutines_version"
|
||||
implementation "org.jetbrains.kotlinx:kotlinx-serialization-runtime-js:$serialization_version"
|
||||
api "io.ktor:ktor-client-js:$ktor_version"
|
||||
api "io.ktor:ktor-client-json-js:$ktor_version"
|
||||
api "io.ktor:ktor-client-serialization-js:$ktor_version"
|
||||
}
|
||||
}
|
||||
|
||||
jsTest {
|
||||
dependsOn commonTest
|
||||
dependencies {
|
||||
implementation "io.ktor:ktor-client-mock-js:$ktor_version"
|
||||
implementation "io.ktor:ktor-client-js:$ktor_version"
|
||||
implementation "io.ktor:ktor-client-json:$ktor_version"
|
||||
implementation "io.ktor:ktor-client-serialization-js:$ktor_version"
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -406,7 +406,7 @@ val apiInstance = FakeApi()
|
||||
val number : kotlin.Double = 8.14 // kotlin.Double | None
|
||||
val double : kotlin.Double = 1.2 // kotlin.Double | None
|
||||
val patternWithoutDelimiter : kotlin.String = patternWithoutDelimiter_example // kotlin.String | None
|
||||
val byte : kotlin.ByteArray = BYTE_ARRAY_DATA_HERE // kotlin.ByteArray | None
|
||||
val byte : org.openapitools.client.infrastructure.Base64ByteArray = BYTE_ARRAY_DATA_HERE // org.openapitools.client.infrastructure.Base64ByteArray | None
|
||||
val integer : kotlin.Int = 56 // kotlin.Int | None
|
||||
val int32 : kotlin.Int = 56 // kotlin.Int | None
|
||||
val int64 : kotlin.Long = 789 // kotlin.Long | None
|
||||
@ -435,7 +435,7 @@ Name | Type | Description | Notes
|
||||
**number** | **kotlin.Double**| None |
|
||||
**double** | **kotlin.Double**| None |
|
||||
**patternWithoutDelimiter** | **kotlin.String**| None |
|
||||
**byte** | **kotlin.ByteArray**| None |
|
||||
**byte** | **org.openapitools.client.infrastructure.Base64ByteArray**| None |
|
||||
**integer** | **kotlin.Int**| None | [optional]
|
||||
**int32** | **kotlin.Int**| None | [optional]
|
||||
**int64** | **kotlin.Long**| None | [optional]
|
||||
|
@ -4,8 +4,8 @@
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**file** | [**io.ktor.client.request.forms.InputProvider**](io.ktor.client.request.forms.InputProvider.md) | | [optional]
|
||||
**files** | [**kotlin.Array<io.ktor.client.request.forms.InputProvider>**](io.ktor.client.request.forms.InputProvider.md) | | [optional]
|
||||
**file** | [**org.openapitools.client.infrastructure.OctetByteArray**](org.openapitools.client.infrastructure.OctetByteArray.md) | | [optional]
|
||||
**files** | [**kotlin.Array<org.openapitools.client.infrastructure.OctetByteArray>**](org.openapitools.client.infrastructure.OctetByteArray.md) | | [optional]
|
||||
|
||||
|
||||
|
||||
|
@ -11,8 +11,8 @@ Name | Type | Description | Notes
|
||||
**float** | **kotlin.Float** | | [optional]
|
||||
**double** | **kotlin.Double** | | [optional]
|
||||
**string** | **kotlin.String** | | [optional]
|
||||
**byte** | **kotlin.ByteArray** | |
|
||||
**binary** | [**io.ktor.client.request.forms.InputProvider**](io.ktor.client.request.forms.InputProvider.md) | | [optional]
|
||||
**byte** | [**org.openapitools.client.infrastructure.Base64ByteArray**](org.openapitools.client.infrastructure.Base64ByteArray.md) | |
|
||||
**binary** | [**org.openapitools.client.infrastructure.OctetByteArray**](org.openapitools.client.infrastructure.OctetByteArray.md) | | [optional]
|
||||
**date** | **kotlin.String** | |
|
||||
**dateTime** | **kotlin.String** | | [optional]
|
||||
**uuid** | **kotlin.String** | | [optional]
|
||||
|
@ -4,8 +4,8 @@
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**bar** | **kotlin.String** | | [optional]
|
||||
**foo** | **kotlin.String** | | [optional]
|
||||
**bar** | **kotlin.String** | | [optional] [readonly]
|
||||
**foo** | **kotlin.String** | | [optional] [readonly]
|
||||
|
||||
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**additionalMetadata** | **kotlin.String** | Additional data to pass to server | [optional]
|
||||
**file** | [**io.ktor.client.request.forms.InputProvider**](io.ktor.client.request.forms.InputProvider.md) | file to upload | [optional]
|
||||
**file** | [**org.openapitools.client.infrastructure.OctetByteArray**](org.openapitools.client.infrastructure.OctetByteArray.md) | file to upload | [optional]
|
||||
|
||||
|
||||
|
||||
|
@ -12,8 +12,8 @@ Name | Type | Description | Notes
|
||||
**double** | **kotlin.Double** | None |
|
||||
**string** | **kotlin.String** | None | [optional]
|
||||
**patternWithoutDelimiter** | **kotlin.String** | None |
|
||||
**byte** | **kotlin.ByteArray** | None |
|
||||
**binary** | [**io.ktor.client.request.forms.InputProvider**](io.ktor.client.request.forms.InputProvider.md) | None | [optional]
|
||||
**byte** | [**org.openapitools.client.infrastructure.Base64ByteArray**](org.openapitools.client.infrastructure.Base64ByteArray.md) | None |
|
||||
**binary** | [**org.openapitools.client.infrastructure.OctetByteArray**](org.openapitools.client.infrastructure.OctetByteArray.md) | None | [optional]
|
||||
**date** | **kotlin.String** | None | [optional]
|
||||
**dateTime** | **kotlin.String** | None | [optional]
|
||||
**password** | **kotlin.String** | None | [optional]
|
||||
|
@ -5,7 +5,7 @@
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**additionalMetadata** | **kotlin.String** | Additional data to pass to server | [optional]
|
||||
**requiredFile** | [**io.ktor.client.request.forms.InputProvider**](io.ktor.client.request.forms.InputProvider.md) | file to upload |
|
||||
**requiredFile** | [**org.openapitools.client.infrastructure.OctetByteArray**](org.openapitools.client.infrastructure.OctetByteArray.md) | file to upload |
|
||||
|
||||
|
||||
|
||||
|
@ -5,9 +5,9 @@
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**name** | **kotlin.Int** | |
|
||||
**snakeCase** | **kotlin.Int** | | [optional]
|
||||
**snakeCase** | **kotlin.Int** | | [optional] [readonly]
|
||||
**property** | **kotlin.String** | | [optional]
|
||||
**`123number`** | **kotlin.Int** | | [optional]
|
||||
**`123number`** | **kotlin.Int** | | [optional] [readonly]
|
||||
|
||||
|
||||
|
||||
|
@ -10,12 +10,12 @@ Name | Type | Description | Notes
|
||||
**stringProp** | **kotlin.String** | | [optional]
|
||||
**dateProp** | **kotlin.String** | | [optional]
|
||||
**datetimeProp** | **kotlin.String** | | [optional]
|
||||
**arrayNullableProp** | [**kotlin.Array<kotlin.Any>**](kotlin.Any.md) | | [optional]
|
||||
**arrayAndItemsNullableProp** | [**kotlin.Array<kotlin.Any>**](kotlin.Any.md) | | [optional]
|
||||
**arrayItemsNullable** | [**kotlin.Array<kotlin.Any>**](kotlin.Any.md) | | [optional]
|
||||
**objectNullableProp** | [**kotlin.collections.Map<kotlin.String, kotlin.Any>**](kotlin.Any.md) | | [optional]
|
||||
**objectAndItemsNullableProp** | [**kotlin.collections.Map<kotlin.String, kotlin.Any>**](kotlin.Any.md) | | [optional]
|
||||
**objectItemsNullable** | [**kotlin.collections.Map<kotlin.String, kotlin.Any>**](kotlin.Any.md) | | [optional]
|
||||
**arrayNullableProp** | **kotlin.Array<kotlin.String>** | | [optional]
|
||||
**arrayAndItemsNullableProp** | **kotlin.Array<kotlin.String>** | | [optional]
|
||||
**arrayItemsNullable** | **kotlin.Array<kotlin.String>** | | [optional]
|
||||
**objectNullableProp** | **kotlin.collections.Map<kotlin.String, kotlin.String>** | | [optional]
|
||||
**objectAndItemsNullableProp** | **kotlin.collections.Map<kotlin.String, kotlin.String>** | | [optional]
|
||||
**objectItemsNullable** | **kotlin.collections.Map<kotlin.String, kotlin.String>** | | [optional]
|
||||
|
||||
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**bar** | **kotlin.String** | | [optional]
|
||||
**bar** | **kotlin.String** | | [optional] [readonly]
|
||||
**baz** | **kotlin.String** | | [optional]
|
||||
|
||||
|
||||
|
@ -46,6 +46,8 @@ class AnotherFakeApi @UseExperimental(UnstableDefault::class) constructor(
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
suspend fun call123testSpecialTags(client: Client) : HttpResponse<Client> {
|
||||
|
||||
val localVariableAuthNames = listOf<String>()
|
||||
|
||||
val localVariableBody = client
|
||||
|
||||
val localVariableQuery = mutableMapOf<String, List<String>>()
|
||||
@ -61,7 +63,8 @@ class AnotherFakeApi @UseExperimental(UnstableDefault::class) constructor(
|
||||
|
||||
return jsonRequest(
|
||||
localVariableConfig,
|
||||
localVariableBody
|
||||
localVariableBody,
|
||||
localVariableAuthNames
|
||||
).wrap()
|
||||
}
|
||||
|
||||
|
@ -45,6 +45,8 @@ class DefaultApi @UseExperimental(UnstableDefault::class) constructor(
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
suspend fun fooGet() : HttpResponse<InlineResponseDefault> {
|
||||
|
||||
val localVariableAuthNames = listOf<String>()
|
||||
|
||||
val localVariableBody =
|
||||
io.ktor.client.utils.EmptyContent
|
||||
|
||||
@ -61,7 +63,8 @@ class DefaultApi @UseExperimental(UnstableDefault::class) constructor(
|
||||
|
||||
return request(
|
||||
localVariableConfig,
|
||||
localVariableBody
|
||||
localVariableBody,
|
||||
localVariableAuthNames
|
||||
).wrap()
|
||||
}
|
||||
|
||||
|
@ -49,6 +49,8 @@ class FakeApi @UseExperimental(UnstableDefault::class) constructor(
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
suspend fun fakeHealthGet() : HttpResponse<HealthCheckResult> {
|
||||
|
||||
val localVariableAuthNames = listOf<String>()
|
||||
|
||||
val localVariableBody =
|
||||
io.ktor.client.utils.EmptyContent
|
||||
|
||||
@ -65,7 +67,8 @@ class FakeApi @UseExperimental(UnstableDefault::class) constructor(
|
||||
|
||||
return request(
|
||||
localVariableConfig,
|
||||
localVariableBody
|
||||
localVariableBody,
|
||||
localVariableAuthNames
|
||||
).wrap()
|
||||
}
|
||||
|
||||
@ -79,6 +82,8 @@ class FakeApi @UseExperimental(UnstableDefault::class) constructor(
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
suspend fun fakeOuterBooleanSerialize(body: kotlin.Boolean?) : HttpResponse<kotlin.Boolean> {
|
||||
|
||||
val localVariableAuthNames = listOf<String>()
|
||||
|
||||
val localVariableBody = body
|
||||
|
||||
val localVariableQuery = mutableMapOf<String, List<String>>()
|
||||
@ -94,7 +99,8 @@ class FakeApi @UseExperimental(UnstableDefault::class) constructor(
|
||||
|
||||
return jsonRequest(
|
||||
localVariableConfig,
|
||||
localVariableBody
|
||||
localVariableBody,
|
||||
localVariableAuthNames
|
||||
).wrap()
|
||||
}
|
||||
|
||||
@ -109,6 +115,8 @@ class FakeApi @UseExperimental(UnstableDefault::class) constructor(
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
suspend fun fakeOuterCompositeSerialize(outerComposite: OuterComposite?) : HttpResponse<OuterComposite> {
|
||||
|
||||
val localVariableAuthNames = listOf<String>()
|
||||
|
||||
val localVariableBody = outerComposite
|
||||
|
||||
val localVariableQuery = mutableMapOf<String, List<String>>()
|
||||
@ -124,7 +132,8 @@ class FakeApi @UseExperimental(UnstableDefault::class) constructor(
|
||||
|
||||
return jsonRequest(
|
||||
localVariableConfig,
|
||||
localVariableBody
|
||||
localVariableBody,
|
||||
localVariableAuthNames
|
||||
).wrap()
|
||||
}
|
||||
|
||||
@ -139,6 +148,8 @@ class FakeApi @UseExperimental(UnstableDefault::class) constructor(
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
suspend fun fakeOuterNumberSerialize(body: kotlin.Double?) : HttpResponse<kotlin.Double> {
|
||||
|
||||
val localVariableAuthNames = listOf<String>()
|
||||
|
||||
val localVariableBody = body
|
||||
|
||||
val localVariableQuery = mutableMapOf<String, List<String>>()
|
||||
@ -154,7 +165,8 @@ class FakeApi @UseExperimental(UnstableDefault::class) constructor(
|
||||
|
||||
return jsonRequest(
|
||||
localVariableConfig,
|
||||
localVariableBody
|
||||
localVariableBody,
|
||||
localVariableAuthNames
|
||||
).wrap()
|
||||
}
|
||||
|
||||
@ -169,6 +181,8 @@ class FakeApi @UseExperimental(UnstableDefault::class) constructor(
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
suspend fun fakeOuterStringSerialize(body: kotlin.String?) : HttpResponse<kotlin.String> {
|
||||
|
||||
val localVariableAuthNames = listOf<String>()
|
||||
|
||||
val localVariableBody = body
|
||||
|
||||
val localVariableQuery = mutableMapOf<String, List<String>>()
|
||||
@ -184,7 +198,8 @@ class FakeApi @UseExperimental(UnstableDefault::class) constructor(
|
||||
|
||||
return jsonRequest(
|
||||
localVariableConfig,
|
||||
localVariableBody
|
||||
localVariableBody,
|
||||
localVariableAuthNames
|
||||
).wrap()
|
||||
}
|
||||
|
||||
@ -198,6 +213,8 @@ class FakeApi @UseExperimental(UnstableDefault::class) constructor(
|
||||
*/
|
||||
suspend fun testBodyWithFileSchema(fileSchemaTestClass: FileSchemaTestClass) : HttpResponse<Unit> {
|
||||
|
||||
val localVariableAuthNames = listOf<String>()
|
||||
|
||||
val localVariableBody = fileSchemaTestClass
|
||||
|
||||
val localVariableQuery = mutableMapOf<String, List<String>>()
|
||||
@ -213,7 +230,8 @@ class FakeApi @UseExperimental(UnstableDefault::class) constructor(
|
||||
|
||||
return jsonRequest(
|
||||
localVariableConfig,
|
||||
localVariableBody
|
||||
localVariableBody,
|
||||
localVariableAuthNames
|
||||
).wrap()
|
||||
}
|
||||
|
||||
@ -228,6 +246,8 @@ class FakeApi @UseExperimental(UnstableDefault::class) constructor(
|
||||
*/
|
||||
suspend fun testBodyWithQueryParams(query: kotlin.String, user: User) : HttpResponse<Unit> {
|
||||
|
||||
val localVariableAuthNames = listOf<String>()
|
||||
|
||||
val localVariableBody = user
|
||||
|
||||
val localVariableQuery = mutableMapOf<String, List<String>>()
|
||||
@ -244,7 +264,8 @@ class FakeApi @UseExperimental(UnstableDefault::class) constructor(
|
||||
|
||||
return jsonRequest(
|
||||
localVariableConfig,
|
||||
localVariableBody
|
||||
localVariableBody,
|
||||
localVariableAuthNames
|
||||
).wrap()
|
||||
}
|
||||
|
||||
@ -259,6 +280,8 @@ class FakeApi @UseExperimental(UnstableDefault::class) constructor(
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
suspend fun testClientModel(client: Client) : HttpResponse<Client> {
|
||||
|
||||
val localVariableAuthNames = listOf<String>()
|
||||
|
||||
val localVariableBody = client
|
||||
|
||||
val localVariableQuery = mutableMapOf<String, List<String>>()
|
||||
@ -274,7 +297,8 @@ class FakeApi @UseExperimental(UnstableDefault::class) constructor(
|
||||
|
||||
return jsonRequest(
|
||||
localVariableConfig,
|
||||
localVariableBody
|
||||
localVariableBody,
|
||||
localVariableAuthNames
|
||||
).wrap()
|
||||
}
|
||||
|
||||
@ -299,7 +323,9 @@ class FakeApi @UseExperimental(UnstableDefault::class) constructor(
|
||||
* @param paramCallback None (optional)
|
||||
* @return void
|
||||
*/
|
||||
suspend fun testEndpointParameters(number: kotlin.Double, double: kotlin.Double, patternWithoutDelimiter: kotlin.String, byte: kotlin.ByteArray, integer: kotlin.Int?, int32: kotlin.Int?, int64: kotlin.Long?, float: kotlin.Float?, string: kotlin.String?, binary: io.ktor.client.request.forms.InputProvider?, date: kotlin.String?, dateTime: kotlin.String?, password: kotlin.String?, paramCallback: kotlin.String?) : HttpResponse<Unit> {
|
||||
suspend fun testEndpointParameters(number: kotlin.Double, double: kotlin.Double, patternWithoutDelimiter: kotlin.String, byte: org.openapitools.client.infrastructure.Base64ByteArray, integer: kotlin.Int?, int32: kotlin.Int?, int64: kotlin.Long?, float: kotlin.Float?, string: kotlin.String?, binary: io.ktor.client.request.forms.InputProvider?, date: kotlin.String?, dateTime: kotlin.String?, password: kotlin.String?, paramCallback: kotlin.String?) : HttpResponse<Unit> {
|
||||
|
||||
val localVariableAuthNames = listOf<String>("http_basic_test")
|
||||
|
||||
val localVariableBody =
|
||||
ParametersBuilder().also {
|
||||
@ -332,7 +358,8 @@ class FakeApi @UseExperimental(UnstableDefault::class) constructor(
|
||||
|
||||
return urlEncodedFormRequest(
|
||||
localVariableConfig,
|
||||
localVariableBody
|
||||
localVariableBody,
|
||||
localVariableAuthNames
|
||||
).wrap()
|
||||
}
|
||||
|
||||
@ -352,6 +379,8 @@ class FakeApi @UseExperimental(UnstableDefault::class) constructor(
|
||||
*/
|
||||
suspend fun testEnumParameters(enumHeaderStringArray: kotlin.Array<kotlin.String>?, enumHeaderString: kotlin.String?, enumQueryStringArray: kotlin.Array<kotlin.String>?, enumQueryString: kotlin.String?, enumQueryInteger: kotlin.Int?, enumQueryDouble: kotlin.Double?, enumFormStringArray: kotlin.Array<kotlin.String>?, enumFormString: kotlin.String?) : HttpResponse<Unit> {
|
||||
|
||||
val localVariableAuthNames = listOf<String>()
|
||||
|
||||
val localVariableBody =
|
||||
ParametersBuilder().also {
|
||||
enumFormStringArray?.apply { it.append("enum_form_string_array", enumFormStringArray.toString()) }
|
||||
@ -377,7 +406,8 @@ class FakeApi @UseExperimental(UnstableDefault::class) constructor(
|
||||
|
||||
return urlEncodedFormRequest(
|
||||
localVariableConfig,
|
||||
localVariableBody
|
||||
localVariableBody,
|
||||
localVariableAuthNames
|
||||
).wrap()
|
||||
}
|
||||
|
||||
@ -395,6 +425,8 @@ class FakeApi @UseExperimental(UnstableDefault::class) constructor(
|
||||
*/
|
||||
suspend fun testGroupParameters(requiredStringGroup: kotlin.Int, requiredBooleanGroup: kotlin.Boolean, requiredInt64Group: kotlin.Long, stringGroup: kotlin.Int?, booleanGroup: kotlin.Boolean?, int64Group: kotlin.Long?) : HttpResponse<Unit> {
|
||||
|
||||
val localVariableAuthNames = listOf<String>("bearer_test")
|
||||
|
||||
val localVariableBody =
|
||||
io.ktor.client.utils.EmptyContent
|
||||
|
||||
@ -417,7 +449,8 @@ class FakeApi @UseExperimental(UnstableDefault::class) constructor(
|
||||
|
||||
return request(
|
||||
localVariableConfig,
|
||||
localVariableBody
|
||||
localVariableBody,
|
||||
localVariableAuthNames
|
||||
).wrap()
|
||||
}
|
||||
|
||||
@ -430,6 +463,8 @@ class FakeApi @UseExperimental(UnstableDefault::class) constructor(
|
||||
*/
|
||||
suspend fun testInlineAdditionalProperties(requestBody: kotlin.collections.Map<kotlin.String, kotlin.String>) : HttpResponse<Unit> {
|
||||
|
||||
val localVariableAuthNames = listOf<String>()
|
||||
|
||||
val localVariableBody = TestInlineAdditionalPropertiesRequest(requestBody)
|
||||
|
||||
val localVariableQuery = mutableMapOf<String, List<String>>()
|
||||
@ -445,7 +480,8 @@ class FakeApi @UseExperimental(UnstableDefault::class) constructor(
|
||||
|
||||
return jsonRequest(
|
||||
localVariableConfig,
|
||||
localVariableBody
|
||||
localVariableBody,
|
||||
localVariableAuthNames
|
||||
).wrap()
|
||||
}
|
||||
|
||||
@ -469,6 +505,8 @@ private class TestInlineAdditionalPropertiesRequest(val value: Map<kotlin.String
|
||||
*/
|
||||
suspend fun testJsonFormData(param: kotlin.String, param2: kotlin.String) : HttpResponse<Unit> {
|
||||
|
||||
val localVariableAuthNames = listOf<String>()
|
||||
|
||||
val localVariableBody =
|
||||
ParametersBuilder().also {
|
||||
param?.apply { it.append("param", param.toString()) }
|
||||
@ -488,7 +526,8 @@ private class TestInlineAdditionalPropertiesRequest(val value: Map<kotlin.String
|
||||
|
||||
return urlEncodedFormRequest(
|
||||
localVariableConfig,
|
||||
localVariableBody
|
||||
localVariableBody,
|
||||
localVariableAuthNames
|
||||
).wrap()
|
||||
}
|
||||
|
||||
@ -505,6 +544,8 @@ private class TestInlineAdditionalPropertiesRequest(val value: Map<kotlin.String
|
||||
*/
|
||||
suspend fun testQueryParameterCollectionFormat(pipe: kotlin.Array<kotlin.String>, ioutil: kotlin.Array<kotlin.String>, http: kotlin.Array<kotlin.String>, url: kotlin.Array<kotlin.String>, context: kotlin.Array<kotlin.String>) : HttpResponse<Unit> {
|
||||
|
||||
val localVariableAuthNames = listOf<String>()
|
||||
|
||||
val localVariableBody =
|
||||
io.ktor.client.utils.EmptyContent
|
||||
|
||||
@ -526,7 +567,8 @@ private class TestInlineAdditionalPropertiesRequest(val value: Map<kotlin.String
|
||||
|
||||
return request(
|
||||
localVariableConfig,
|
||||
localVariableBody
|
||||
localVariableBody,
|
||||
localVariableAuthNames
|
||||
).wrap()
|
||||
}
|
||||
|
||||
|
@ -46,6 +46,8 @@ class FakeClassnameTags123Api @UseExperimental(UnstableDefault::class) construct
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
suspend fun testClassname(client: Client) : HttpResponse<Client> {
|
||||
|
||||
val localVariableAuthNames = listOf<String>("api_key_query")
|
||||
|
||||
val localVariableBody = client
|
||||
|
||||
val localVariableQuery = mutableMapOf<String, List<String>>()
|
||||
@ -61,7 +63,8 @@ class FakeClassnameTags123Api @UseExperimental(UnstableDefault::class) construct
|
||||
|
||||
return jsonRequest(
|
||||
localVariableConfig,
|
||||
localVariableBody
|
||||
localVariableBody,
|
||||
localVariableAuthNames
|
||||
).wrap()
|
||||
}
|
||||
|
||||
|
@ -46,6 +46,8 @@ class PetApi @UseExperimental(UnstableDefault::class) constructor(
|
||||
*/
|
||||
suspend fun addPet(pet: Pet) : HttpResponse<Unit> {
|
||||
|
||||
val localVariableAuthNames = listOf<String>("petstore_auth")
|
||||
|
||||
val localVariableBody = pet
|
||||
|
||||
val localVariableQuery = mutableMapOf<String, List<String>>()
|
||||
@ -61,7 +63,8 @@ class PetApi @UseExperimental(UnstableDefault::class) constructor(
|
||||
|
||||
return jsonRequest(
|
||||
localVariableConfig,
|
||||
localVariableBody
|
||||
localVariableBody,
|
||||
localVariableAuthNames
|
||||
).wrap()
|
||||
}
|
||||
|
||||
@ -76,6 +79,8 @@ class PetApi @UseExperimental(UnstableDefault::class) constructor(
|
||||
*/
|
||||
suspend fun deletePet(petId: kotlin.Long, apiKey: kotlin.String?) : HttpResponse<Unit> {
|
||||
|
||||
val localVariableAuthNames = listOf<String>("petstore_auth")
|
||||
|
||||
val localVariableBody =
|
||||
io.ktor.client.utils.EmptyContent
|
||||
|
||||
@ -93,7 +98,8 @@ class PetApi @UseExperimental(UnstableDefault::class) constructor(
|
||||
|
||||
return request(
|
||||
localVariableConfig,
|
||||
localVariableBody
|
||||
localVariableBody,
|
||||
localVariableAuthNames
|
||||
).wrap()
|
||||
}
|
||||
|
||||
@ -107,6 +113,8 @@ class PetApi @UseExperimental(UnstableDefault::class) constructor(
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
suspend fun findPetsByStatus(status: kotlin.Array<kotlin.String>) : HttpResponse<kotlin.Array<Pet>> {
|
||||
|
||||
val localVariableAuthNames = listOf<String>("petstore_auth")
|
||||
|
||||
val localVariableBody =
|
||||
io.ktor.client.utils.EmptyContent
|
||||
|
||||
@ -124,7 +132,8 @@ class PetApi @UseExperimental(UnstableDefault::class) constructor(
|
||||
|
||||
return request(
|
||||
localVariableConfig,
|
||||
localVariableBody
|
||||
localVariableBody,
|
||||
localVariableAuthNames
|
||||
).wrap<FindPetsByStatusResponse>().map { value.toTypedArray() }
|
||||
}
|
||||
|
||||
@ -148,6 +157,8 @@ private class FindPetsByStatusResponse(val value: List<Pet>) {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
suspend fun findPetsByTags(tags: kotlin.Array<kotlin.String>) : HttpResponse<kotlin.Array<Pet>> {
|
||||
|
||||
val localVariableAuthNames = listOf<String>("petstore_auth")
|
||||
|
||||
val localVariableBody =
|
||||
io.ktor.client.utils.EmptyContent
|
||||
|
||||
@ -165,7 +176,8 @@ private class FindPetsByStatusResponse(val value: List<Pet>) {
|
||||
|
||||
return request(
|
||||
localVariableConfig,
|
||||
localVariableBody
|
||||
localVariableBody,
|
||||
localVariableAuthNames
|
||||
).wrap<FindPetsByTagsResponse>().map { value.toTypedArray() }
|
||||
}
|
||||
|
||||
@ -189,6 +201,8 @@ private class FindPetsByTagsResponse(val value: List<Pet>) {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
suspend fun getPetById(petId: kotlin.Long) : HttpResponse<Pet> {
|
||||
|
||||
val localVariableAuthNames = listOf<String>("api_key")
|
||||
|
||||
val localVariableBody =
|
||||
io.ktor.client.utils.EmptyContent
|
||||
|
||||
@ -205,7 +219,8 @@ private class FindPetsByTagsResponse(val value: List<Pet>) {
|
||||
|
||||
return request(
|
||||
localVariableConfig,
|
||||
localVariableBody
|
||||
localVariableBody,
|
||||
localVariableAuthNames
|
||||
).wrap()
|
||||
}
|
||||
|
||||
@ -218,6 +233,8 @@ private class FindPetsByTagsResponse(val value: List<Pet>) {
|
||||
*/
|
||||
suspend fun updatePet(pet: Pet) : HttpResponse<Unit> {
|
||||
|
||||
val localVariableAuthNames = listOf<String>("petstore_auth")
|
||||
|
||||
val localVariableBody = pet
|
||||
|
||||
val localVariableQuery = mutableMapOf<String, List<String>>()
|
||||
@ -233,7 +250,8 @@ private class FindPetsByTagsResponse(val value: List<Pet>) {
|
||||
|
||||
return jsonRequest(
|
||||
localVariableConfig,
|
||||
localVariableBody
|
||||
localVariableBody,
|
||||
localVariableAuthNames
|
||||
).wrap()
|
||||
}
|
||||
|
||||
@ -249,6 +267,8 @@ private class FindPetsByTagsResponse(val value: List<Pet>) {
|
||||
*/
|
||||
suspend fun updatePetWithForm(petId: kotlin.Long, name: kotlin.String?, status: kotlin.String?) : HttpResponse<Unit> {
|
||||
|
||||
val localVariableAuthNames = listOf<String>("petstore_auth")
|
||||
|
||||
val localVariableBody =
|
||||
ParametersBuilder().also {
|
||||
name?.apply { it.append("name", name.toString()) }
|
||||
@ -268,7 +288,8 @@ private class FindPetsByTagsResponse(val value: List<Pet>) {
|
||||
|
||||
return urlEncodedFormRequest(
|
||||
localVariableConfig,
|
||||
localVariableBody
|
||||
localVariableBody,
|
||||
localVariableAuthNames
|
||||
).wrap()
|
||||
}
|
||||
|
||||
@ -284,6 +305,8 @@ private class FindPetsByTagsResponse(val value: List<Pet>) {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
suspend fun uploadFile(petId: kotlin.Long, additionalMetadata: kotlin.String?, file: io.ktor.client.request.forms.InputProvider?) : HttpResponse<ApiResponse> {
|
||||
|
||||
val localVariableAuthNames = listOf<String>("petstore_auth")
|
||||
|
||||
val localVariableBody =
|
||||
formData {
|
||||
additionalMetadata?.apply { append("additionalMetadata", additionalMetadata) }
|
||||
@ -303,7 +326,8 @@ private class FindPetsByTagsResponse(val value: List<Pet>) {
|
||||
|
||||
return multipartFormRequest(
|
||||
localVariableConfig,
|
||||
localVariableBody
|
||||
localVariableBody,
|
||||
localVariableAuthNames
|
||||
).wrap()
|
||||
}
|
||||
|
||||
@ -319,6 +343,8 @@ private class FindPetsByTagsResponse(val value: List<Pet>) {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
suspend fun uploadFileWithRequiredFile(petId: kotlin.Long, requiredFile: io.ktor.client.request.forms.InputProvider, additionalMetadata: kotlin.String?) : HttpResponse<ApiResponse> {
|
||||
|
||||
val localVariableAuthNames = listOf<String>("petstore_auth")
|
||||
|
||||
val localVariableBody =
|
||||
formData {
|
||||
additionalMetadata?.apply { append("additionalMetadata", additionalMetadata) }
|
||||
@ -338,7 +364,8 @@ private class FindPetsByTagsResponse(val value: List<Pet>) {
|
||||
|
||||
return multipartFormRequest(
|
||||
localVariableConfig,
|
||||
localVariableBody
|
||||
localVariableBody,
|
||||
localVariableAuthNames
|
||||
).wrap()
|
||||
}
|
||||
|
||||
|
@ -45,6 +45,8 @@ class StoreApi @UseExperimental(UnstableDefault::class) constructor(
|
||||
*/
|
||||
suspend fun deleteOrder(orderId: kotlin.String) : HttpResponse<Unit> {
|
||||
|
||||
val localVariableAuthNames = listOf<String>()
|
||||
|
||||
val localVariableBody =
|
||||
io.ktor.client.utils.EmptyContent
|
||||
|
||||
@ -61,7 +63,8 @@ class StoreApi @UseExperimental(UnstableDefault::class) constructor(
|
||||
|
||||
return request(
|
||||
localVariableConfig,
|
||||
localVariableBody
|
||||
localVariableBody,
|
||||
localVariableAuthNames
|
||||
).wrap()
|
||||
}
|
||||
|
||||
@ -74,6 +77,8 @@ class StoreApi @UseExperimental(UnstableDefault::class) constructor(
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
suspend fun getInventory() : HttpResponse<kotlin.collections.Map<kotlin.String, kotlin.Int>> {
|
||||
|
||||
val localVariableAuthNames = listOf<String>("api_key")
|
||||
|
||||
val localVariableBody =
|
||||
io.ktor.client.utils.EmptyContent
|
||||
|
||||
@ -90,7 +95,8 @@ class StoreApi @UseExperimental(UnstableDefault::class) constructor(
|
||||
|
||||
return request(
|
||||
localVariableConfig,
|
||||
localVariableBody
|
||||
localVariableBody,
|
||||
localVariableAuthNames
|
||||
).wrap<GetInventoryResponse>().map { value }
|
||||
}
|
||||
|
||||
@ -114,6 +120,8 @@ private class GetInventoryResponse(val value: Map<kotlin.String, kotlin.Int>) {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
suspend fun getOrderById(orderId: kotlin.Long) : HttpResponse<Order> {
|
||||
|
||||
val localVariableAuthNames = listOf<String>()
|
||||
|
||||
val localVariableBody =
|
||||
io.ktor.client.utils.EmptyContent
|
||||
|
||||
@ -130,7 +138,8 @@ private class GetInventoryResponse(val value: Map<kotlin.String, kotlin.Int>) {
|
||||
|
||||
return request(
|
||||
localVariableConfig,
|
||||
localVariableBody
|
||||
localVariableBody,
|
||||
localVariableAuthNames
|
||||
).wrap()
|
||||
}
|
||||
|
||||
@ -144,6 +153,8 @@ private class GetInventoryResponse(val value: Map<kotlin.String, kotlin.Int>) {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
suspend fun placeOrder(order: Order) : HttpResponse<Order> {
|
||||
|
||||
val localVariableAuthNames = listOf<String>()
|
||||
|
||||
val localVariableBody = order
|
||||
|
||||
val localVariableQuery = mutableMapOf<String, List<String>>()
|
||||
@ -159,7 +170,8 @@ private class GetInventoryResponse(val value: Map<kotlin.String, kotlin.Int>) {
|
||||
|
||||
return jsonRequest(
|
||||
localVariableConfig,
|
||||
localVariableBody
|
||||
localVariableBody,
|
||||
localVariableAuthNames
|
||||
).wrap()
|
||||
}
|
||||
|
||||
|
@ -45,6 +45,8 @@ class UserApi @UseExperimental(UnstableDefault::class) constructor(
|
||||
*/
|
||||
suspend fun createUser(user: User) : HttpResponse<Unit> {
|
||||
|
||||
val localVariableAuthNames = listOf<String>()
|
||||
|
||||
val localVariableBody = user
|
||||
|
||||
val localVariableQuery = mutableMapOf<String, List<String>>()
|
||||
@ -60,7 +62,8 @@ class UserApi @UseExperimental(UnstableDefault::class) constructor(
|
||||
|
||||
return jsonRequest(
|
||||
localVariableConfig,
|
||||
localVariableBody
|
||||
localVariableBody,
|
||||
localVariableAuthNames
|
||||
).wrap()
|
||||
}
|
||||
|
||||
@ -74,6 +77,8 @@ class UserApi @UseExperimental(UnstableDefault::class) constructor(
|
||||
*/
|
||||
suspend fun createUsersWithArrayInput(user: kotlin.Array<User>) : HttpResponse<Unit> {
|
||||
|
||||
val localVariableAuthNames = listOf<String>()
|
||||
|
||||
val localVariableBody = CreateUsersWithArrayInputRequest(user.asList())
|
||||
|
||||
val localVariableQuery = mutableMapOf<String, List<String>>()
|
||||
@ -89,7 +94,8 @@ class UserApi @UseExperimental(UnstableDefault::class) constructor(
|
||||
|
||||
return jsonRequest(
|
||||
localVariableConfig,
|
||||
localVariableBody
|
||||
localVariableBody,
|
||||
localVariableAuthNames
|
||||
).wrap()
|
||||
}
|
||||
|
||||
@ -112,6 +118,8 @@ private class CreateUsersWithArrayInputRequest(val value: List<User>) {
|
||||
*/
|
||||
suspend fun createUsersWithListInput(user: kotlin.Array<User>) : HttpResponse<Unit> {
|
||||
|
||||
val localVariableAuthNames = listOf<String>()
|
||||
|
||||
val localVariableBody = CreateUsersWithListInputRequest(user.asList())
|
||||
|
||||
val localVariableQuery = mutableMapOf<String, List<String>>()
|
||||
@ -127,7 +135,8 @@ private class CreateUsersWithArrayInputRequest(val value: List<User>) {
|
||||
|
||||
return jsonRequest(
|
||||
localVariableConfig,
|
||||
localVariableBody
|
||||
localVariableBody,
|
||||
localVariableAuthNames
|
||||
).wrap()
|
||||
}
|
||||
|
||||
@ -150,6 +159,8 @@ private class CreateUsersWithListInputRequest(val value: List<User>) {
|
||||
*/
|
||||
suspend fun deleteUser(username: kotlin.String) : HttpResponse<Unit> {
|
||||
|
||||
val localVariableAuthNames = listOf<String>()
|
||||
|
||||
val localVariableBody =
|
||||
io.ktor.client.utils.EmptyContent
|
||||
|
||||
@ -166,7 +177,8 @@ private class CreateUsersWithListInputRequest(val value: List<User>) {
|
||||
|
||||
return request(
|
||||
localVariableConfig,
|
||||
localVariableBody
|
||||
localVariableBody,
|
||||
localVariableAuthNames
|
||||
).wrap()
|
||||
}
|
||||
|
||||
@ -180,6 +192,8 @@ private class CreateUsersWithListInputRequest(val value: List<User>) {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
suspend fun getUserByName(username: kotlin.String) : HttpResponse<User> {
|
||||
|
||||
val localVariableAuthNames = listOf<String>()
|
||||
|
||||
val localVariableBody =
|
||||
io.ktor.client.utils.EmptyContent
|
||||
|
||||
@ -196,7 +210,8 @@ private class CreateUsersWithListInputRequest(val value: List<User>) {
|
||||
|
||||
return request(
|
||||
localVariableConfig,
|
||||
localVariableBody
|
||||
localVariableBody,
|
||||
localVariableAuthNames
|
||||
).wrap()
|
||||
}
|
||||
|
||||
@ -211,6 +226,8 @@ private class CreateUsersWithListInputRequest(val value: List<User>) {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
suspend fun loginUser(username: kotlin.String, password: kotlin.String) : HttpResponse<kotlin.String> {
|
||||
|
||||
val localVariableAuthNames = listOf<String>()
|
||||
|
||||
val localVariableBody =
|
||||
io.ktor.client.utils.EmptyContent
|
||||
|
||||
@ -229,7 +246,8 @@ private class CreateUsersWithListInputRequest(val value: List<User>) {
|
||||
|
||||
return request(
|
||||
localVariableConfig,
|
||||
localVariableBody
|
||||
localVariableBody,
|
||||
localVariableAuthNames
|
||||
).wrap()
|
||||
}
|
||||
|
||||
@ -241,6 +259,8 @@ private class CreateUsersWithListInputRequest(val value: List<User>) {
|
||||
*/
|
||||
suspend fun logoutUser() : HttpResponse<Unit> {
|
||||
|
||||
val localVariableAuthNames = listOf<String>()
|
||||
|
||||
val localVariableBody =
|
||||
io.ktor.client.utils.EmptyContent
|
||||
|
||||
@ -257,7 +277,8 @@ private class CreateUsersWithListInputRequest(val value: List<User>) {
|
||||
|
||||
return request(
|
||||
localVariableConfig,
|
||||
localVariableBody
|
||||
localVariableBody,
|
||||
localVariableAuthNames
|
||||
).wrap()
|
||||
}
|
||||
|
||||
@ -271,6 +292,8 @@ private class CreateUsersWithListInputRequest(val value: List<User>) {
|
||||
*/
|
||||
suspend fun updateUser(username: kotlin.String, user: User) : HttpResponse<Unit> {
|
||||
|
||||
val localVariableAuthNames = listOf<String>()
|
||||
|
||||
val localVariableBody = user
|
||||
|
||||
val localVariableQuery = mutableMapOf<String, List<String>>()
|
||||
@ -286,7 +309,8 @@ private class CreateUsersWithListInputRequest(val value: List<User>) {
|
||||
|
||||
return jsonRequest(
|
||||
localVariableConfig,
|
||||
localVariableBody
|
||||
localVariableBody,
|
||||
localVariableAuthNames
|
||||
).wrap()
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
}
|
||||
}
|
||||
}
|
@ -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>)
|
||||
|
||||
}
|
@ -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
|
||||
|
||||
@InternalAPI
|
||||
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"
|
||||
}
|
||||
}
|
@ -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
|
||||
}
|
||||
}
|
@ -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"
|
||||
}
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
package org.openapitools.client.infrastructure
|
||||
|
||||
typealias MultiValueMap = Map<String,List<String>>
|
||||
typealias MultiValueMap = MutableMap<String,List<String>>
|
||||
|
||||
fun collectionDelimiter(collectionFormat: String) = when(collectionFormat) {
|
||||
"csv" -> ","
|
||||
|
@ -23,6 +23,7 @@ import kotlinx.serialization.json.JsonConfiguration
|
||||
|
||||
import org.openapitools.client.apis.*
|
||||
import org.openapitools.client.models.*
|
||||
import org.openapitools.client.auth.*
|
||||
|
||||
open class ApiClient(
|
||||
private val baseUrl: String,
|
||||
@ -46,6 +47,15 @@ open class ApiClient(
|
||||
httpClientEngine?.let { HttpClient(it, clientConfig) } ?: HttpClient(clientConfig)
|
||||
}
|
||||
|
||||
private val authentications: kotlin.collections.Map<String, Authentication> by lazy {
|
||||
mapOf(
|
||||
"api_key" to ApiKeyAuth("header", "api_key"),
|
||||
"api_key_query" to ApiKeyAuth("query", "api_key_query"),
|
||||
"bearer_test" to HttpBearerAuth("bearer"),
|
||||
"http_basic_test" to HttpBasicAuth(),
|
||||
"petstore_auth" to OAuth())
|
||||
}
|
||||
|
||||
companion object {
|
||||
protected val UNSAFE_HEADERS = listOf(HttpHeaders.ContentType)
|
||||
|
||||
@ -65,73 +75,142 @@ open class ApiClient(
|
||||
|
||||
UserApi.setMappers(serializer)
|
||||
|
||||
serializer.setMapper(AdditionalPropertiesClass::class, AdditionalPropertiesClass.serializer())
|
||||
serializer.setMapper(Animal::class, Animal.serializer())
|
||||
serializer.setMapper(ApiResponse::class, ApiResponse.serializer())
|
||||
serializer.setMapper(ArrayOfArrayOfNumberOnly::class, ArrayOfArrayOfNumberOnly.serializer())
|
||||
serializer.setMapper(ArrayOfNumberOnly::class, ArrayOfNumberOnly.serializer())
|
||||
serializer.setMapper(ArrayTest::class, ArrayTest.serializer())
|
||||
serializer.setMapper(Capitalization::class, Capitalization.serializer())
|
||||
serializer.setMapper(Cat::class, Cat.serializer())
|
||||
serializer.setMapper(CatAllOf::class, CatAllOf.serializer())
|
||||
serializer.setMapper(Category::class, Category.serializer())
|
||||
serializer.setMapper(ClassModel::class, ClassModel.serializer())
|
||||
serializer.setMapper(Client::class, Client.serializer())
|
||||
serializer.setMapper(Dog::class, Dog.serializer())
|
||||
serializer.setMapper(DogAllOf::class, DogAllOf.serializer())
|
||||
serializer.setMapper(EnumArrays::class, EnumArrays.serializer())
|
||||
serializer.setMapper(EnumClass::class, EnumClass.serializer())
|
||||
serializer.setMapper(EnumTest::class, EnumTest.serializer())
|
||||
serializer.setMapper(FileSchemaTestClass::class, FileSchemaTestClass.serializer())
|
||||
serializer.setMapper(Foo::class, Foo.serializer())
|
||||
serializer.setMapper(FormatTest::class, FormatTest.serializer())
|
||||
serializer.setMapper(HasOnlyReadOnly::class, HasOnlyReadOnly.serializer())
|
||||
serializer.setMapper(HealthCheckResult::class, HealthCheckResult.serializer())
|
||||
serializer.setMapper(InlineObject::class, InlineObject.serializer())
|
||||
serializer.setMapper(InlineObject1::class, InlineObject1.serializer())
|
||||
serializer.setMapper(InlineObject2::class, InlineObject2.serializer())
|
||||
serializer.setMapper(InlineObject3::class, InlineObject3.serializer())
|
||||
serializer.setMapper(InlineObject4::class, InlineObject4.serializer())
|
||||
serializer.setMapper(InlineObject5::class, InlineObject5.serializer())
|
||||
serializer.setMapper(InlineResponseDefault::class, InlineResponseDefault.serializer())
|
||||
serializer.setMapper(List::class, List.serializer())
|
||||
serializer.setMapper(MapTest::class, MapTest.serializer())
|
||||
serializer.setMapper(MixedPropertiesAndAdditionalPropertiesClass::class, MixedPropertiesAndAdditionalPropertiesClass.serializer())
|
||||
serializer.setMapper(Model200Response::class, Model200Response.serializer())
|
||||
serializer.setMapper(Name::class, Name.serializer())
|
||||
serializer.setMapper(NullableClass::class, NullableClass.serializer())
|
||||
serializer.setMapper(NumberOnly::class, NumberOnly.serializer())
|
||||
serializer.setMapper(Order::class, Order.serializer())
|
||||
serializer.setMapper(OuterComposite::class, OuterComposite.serializer())
|
||||
serializer.setMapper(OuterEnum::class, OuterEnum.serializer())
|
||||
serializer.setMapper(OuterEnumDefaultValue::class, OuterEnumDefaultValue.serializer())
|
||||
serializer.setMapper(OuterEnumInteger::class, OuterEnumInteger.serializer())
|
||||
serializer.setMapper(OuterEnumIntegerDefaultValue::class, OuterEnumIntegerDefaultValue.serializer())
|
||||
serializer.setMapper(Pet::class, Pet.serializer())
|
||||
serializer.setMapper(ReadOnlyFirst::class, ReadOnlyFirst.serializer())
|
||||
serializer.setMapper(Return::class, Return.serializer())
|
||||
serializer.setMapper(SpecialModelname::class, SpecialModelname.serializer())
|
||||
serializer.setMapper(Tag::class, Tag.serializer())
|
||||
serializer.setMapper(User::class, User.serializer())
|
||||
serializer.setMapper(org.openapitools.client.models.AdditionalPropertiesClass::class, org.openapitools.client.models.AdditionalPropertiesClass.serializer())
|
||||
serializer.setMapper(org.openapitools.client.models.Animal::class, org.openapitools.client.models.Animal.serializer())
|
||||
serializer.setMapper(org.openapitools.client.models.ApiResponse::class, org.openapitools.client.models.ApiResponse.serializer())
|
||||
serializer.setMapper(org.openapitools.client.models.ArrayOfArrayOfNumberOnly::class, org.openapitools.client.models.ArrayOfArrayOfNumberOnly.serializer())
|
||||
serializer.setMapper(org.openapitools.client.models.ArrayOfNumberOnly::class, org.openapitools.client.models.ArrayOfNumberOnly.serializer())
|
||||
serializer.setMapper(org.openapitools.client.models.ArrayTest::class, org.openapitools.client.models.ArrayTest.serializer())
|
||||
serializer.setMapper(org.openapitools.client.models.Capitalization::class, org.openapitools.client.models.Capitalization.serializer())
|
||||
serializer.setMapper(org.openapitools.client.models.Cat::class, org.openapitools.client.models.Cat.serializer())
|
||||
serializer.setMapper(org.openapitools.client.models.CatAllOf::class, org.openapitools.client.models.CatAllOf.serializer())
|
||||
serializer.setMapper(org.openapitools.client.models.Category::class, org.openapitools.client.models.Category.serializer())
|
||||
serializer.setMapper(org.openapitools.client.models.ClassModel::class, org.openapitools.client.models.ClassModel.serializer())
|
||||
serializer.setMapper(org.openapitools.client.models.Client::class, org.openapitools.client.models.Client.serializer())
|
||||
serializer.setMapper(org.openapitools.client.models.Dog::class, org.openapitools.client.models.Dog.serializer())
|
||||
serializer.setMapper(org.openapitools.client.models.DogAllOf::class, org.openapitools.client.models.DogAllOf.serializer())
|
||||
serializer.setMapper(org.openapitools.client.models.EnumArrays::class, org.openapitools.client.models.EnumArrays.serializer())
|
||||
serializer.setMapper(org.openapitools.client.models.EnumClass::class, org.openapitools.client.models.EnumClass.Serializer)
|
||||
serializer.setMapper(org.openapitools.client.models.EnumTest::class, org.openapitools.client.models.EnumTest.serializer())
|
||||
serializer.setMapper(org.openapitools.client.models.FileSchemaTestClass::class, org.openapitools.client.models.FileSchemaTestClass.serializer())
|
||||
serializer.setMapper(org.openapitools.client.models.Foo::class, org.openapitools.client.models.Foo.serializer())
|
||||
serializer.setMapper(org.openapitools.client.models.FormatTest::class, org.openapitools.client.models.FormatTest.serializer())
|
||||
serializer.setMapper(org.openapitools.client.models.HasOnlyReadOnly::class, org.openapitools.client.models.HasOnlyReadOnly.serializer())
|
||||
serializer.setMapper(org.openapitools.client.models.HealthCheckResult::class, org.openapitools.client.models.HealthCheckResult.serializer())
|
||||
serializer.setMapper(org.openapitools.client.models.InlineObject::class, org.openapitools.client.models.InlineObject.serializer())
|
||||
serializer.setMapper(org.openapitools.client.models.InlineObject1::class, org.openapitools.client.models.InlineObject1.serializer())
|
||||
serializer.setMapper(org.openapitools.client.models.InlineObject2::class, org.openapitools.client.models.InlineObject2.serializer())
|
||||
serializer.setMapper(org.openapitools.client.models.InlineObject3::class, org.openapitools.client.models.InlineObject3.serializer())
|
||||
serializer.setMapper(org.openapitools.client.models.InlineObject4::class, org.openapitools.client.models.InlineObject4.serializer())
|
||||
serializer.setMapper(org.openapitools.client.models.InlineObject5::class, org.openapitools.client.models.InlineObject5.serializer())
|
||||
serializer.setMapper(org.openapitools.client.models.InlineResponseDefault::class, org.openapitools.client.models.InlineResponseDefault.serializer())
|
||||
serializer.setMapper(org.openapitools.client.models.List::class, org.openapitools.client.models.List.serializer())
|
||||
serializer.setMapper(org.openapitools.client.models.MapTest::class, org.openapitools.client.models.MapTest.serializer())
|
||||
serializer.setMapper(org.openapitools.client.models.MixedPropertiesAndAdditionalPropertiesClass::class, org.openapitools.client.models.MixedPropertiesAndAdditionalPropertiesClass.serializer())
|
||||
serializer.setMapper(org.openapitools.client.models.Model200Response::class, org.openapitools.client.models.Model200Response.serializer())
|
||||
serializer.setMapper(org.openapitools.client.models.Name::class, org.openapitools.client.models.Name.serializer())
|
||||
serializer.setMapper(org.openapitools.client.models.NullableClass::class, org.openapitools.client.models.NullableClass.serializer())
|
||||
serializer.setMapper(org.openapitools.client.models.NumberOnly::class, org.openapitools.client.models.NumberOnly.serializer())
|
||||
serializer.setMapper(org.openapitools.client.models.Order::class, org.openapitools.client.models.Order.serializer())
|
||||
serializer.setMapper(org.openapitools.client.models.OuterComposite::class, org.openapitools.client.models.OuterComposite.serializer())
|
||||
serializer.setMapper(org.openapitools.client.models.OuterEnum::class, org.openapitools.client.models.OuterEnum.Serializer)
|
||||
serializer.setMapper(org.openapitools.client.models.OuterEnumDefaultValue::class, org.openapitools.client.models.OuterEnumDefaultValue.Serializer)
|
||||
serializer.setMapper(org.openapitools.client.models.OuterEnumInteger::class, org.openapitools.client.models.OuterEnumInteger.Serializer)
|
||||
serializer.setMapper(org.openapitools.client.models.OuterEnumIntegerDefaultValue::class, org.openapitools.client.models.OuterEnumIntegerDefaultValue.Serializer)
|
||||
serializer.setMapper(org.openapitools.client.models.Pet::class, org.openapitools.client.models.Pet.serializer())
|
||||
serializer.setMapper(org.openapitools.client.models.ReadOnlyFirst::class, org.openapitools.client.models.ReadOnlyFirst.serializer())
|
||||
serializer.setMapper(org.openapitools.client.models.Return::class, org.openapitools.client.models.Return.serializer())
|
||||
serializer.setMapper(org.openapitools.client.models.SpecialModelname::class, org.openapitools.client.models.SpecialModelname.serializer())
|
||||
serializer.setMapper(org.openapitools.client.models.Tag::class, org.openapitools.client.models.Tag.serializer())
|
||||
serializer.setMapper(org.openapitools.client.models.User::class, org.openapitools.client.models.User.serializer())
|
||||
}
|
||||
}
|
||||
|
||||
protected suspend fun multipartFormRequest(requestConfig: RequestConfig, body: List<PartData>?): HttpResponse {
|
||||
return request(requestConfig, MultiPartFormDataContent(body ?: listOf()))
|
||||
/**
|
||||
* Set the username for the first HTTP basic authentication.
|
||||
*
|
||||
* @param username Username
|
||||
*/
|
||||
fun setUsername(username: String) {
|
||||
val auth = authentications.values.firstOrNull { it is HttpBasicAuth } as HttpBasicAuth?
|
||||
?: throw Exception("No HTTP basic authentication configured")
|
||||
auth.username = username
|
||||
}
|
||||
|
||||
protected suspend fun urlEncodedFormRequest(requestConfig: RequestConfig, body: Parameters?): HttpResponse {
|
||||
return request(requestConfig, FormDataContent(body ?: Parameters.Empty))
|
||||
/**
|
||||
* Set the password for the first HTTP basic authentication.
|
||||
*
|
||||
* @param password Password
|
||||
*/
|
||||
fun setPassword(password: String) {
|
||||
val auth = authentications.values.firstOrNull { it is HttpBasicAuth } as HttpBasicAuth?
|
||||
?: throw Exception("No HTTP basic authentication configured")
|
||||
auth.password = password
|
||||
}
|
||||
|
||||
protected suspend fun jsonRequest(requestConfig: RequestConfig, body: Any? = null): HttpResponse {
|
||||
/**
|
||||
* Set the API key value for the first API key authentication.
|
||||
*
|
||||
* @param apiKey API key
|
||||
* @param paramName The name of the API key parameter, or null or set the first key.
|
||||
*/
|
||||
fun setApiKey(apiKey: String, paramName: String? = null) {
|
||||
val auth = authentications.values.firstOrNull { it is ApiKeyAuth && (paramName == null || paramName == it.paramName)} as ApiKeyAuth?
|
||||
?: throw Exception("No API key authentication configured")
|
||||
auth.apiKey = apiKey
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the API key prefix for the first API key authentication.
|
||||
*
|
||||
* @param apiKeyPrefix API key prefix
|
||||
* @param paramName The name of the API key parameter, or null or set the first key.
|
||||
*/
|
||||
fun setApiKeyPrefix(apiKeyPrefix: String, paramName: String? = null) {
|
||||
val auth = authentications.values.firstOrNull { it is ApiKeyAuth && (paramName == null || paramName == it.paramName) } as ApiKeyAuth?
|
||||
?: throw Exception("No API key authentication configured")
|
||||
auth.apiKeyPrefix = apiKeyPrefix
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the access token for the first OAuth2 authentication.
|
||||
*
|
||||
* @param accessToken Access token
|
||||
*/
|
||||
fun setAccessToken(accessToken: String) {
|
||||
val auth = authentications.values.firstOrNull { it is OAuth } as OAuth?
|
||||
?: throw Exception("No OAuth2 authentication configured")
|
||||
auth.accessToken = accessToken
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the access token for the first Bearer authentication.
|
||||
*
|
||||
* @param bearerToken The bearer token.
|
||||
*/
|
||||
fun setBearerToken(bearerToken: String) {
|
||||
val auth = authentications.values.firstOrNull { it is HttpBearerAuth } as HttpBearerAuth?
|
||||
?: throw Exception("No Bearer authentication configured")
|
||||
auth.bearerToken = bearerToken
|
||||
}
|
||||
|
||||
protected suspend fun multipartFormRequest(requestConfig: RequestConfig, body: kotlin.collections.List<PartData>?, authNames: kotlin.collections.List<String>): HttpResponse {
|
||||
return request(requestConfig, MultiPartFormDataContent(body ?: listOf()), authNames)
|
||||
}
|
||||
|
||||
protected suspend fun urlEncodedFormRequest(requestConfig: RequestConfig, body: Parameters?, authNames: kotlin.collections.List<String>): HttpResponse {
|
||||
return request(requestConfig, FormDataContent(body ?: Parameters.Empty), authNames)
|
||||
}
|
||||
|
||||
protected suspend fun jsonRequest(requestConfig: RequestConfig, body: Any? = null, authNames: kotlin.collections.List<String>): HttpResponse {
|
||||
val contentType = (requestConfig.headers[HttpHeaders.ContentType]?.let { ContentType.parse(it) }
|
||||
?: ContentType.Application.Json)
|
||||
return if (body != null) request(requestConfig, serializer.write(body, contentType))
|
||||
else request(requestConfig)
|
||||
return if (body != null) request(requestConfig, serializer.write(body, contentType), authNames)
|
||||
else request(requestConfig, authNames = authNames)
|
||||
}
|
||||
|
||||
protected suspend fun request(requestConfig: RequestConfig, body: OutgoingContent = EmptyContent): HttpResponse {
|
||||
protected suspend fun request(requestConfig: RequestConfig, body: OutgoingContent = EmptyContent, authNames: kotlin.collections.List<String>): HttpResponse {
|
||||
requestConfig.updateForAuth(authNames)
|
||||
val headers = requestConfig.headers
|
||||
|
||||
return client.call {
|
||||
@ -152,7 +231,14 @@ open class ApiClient(
|
||||
}.response
|
||||
}
|
||||
|
||||
private fun URLBuilder.appendPath(components: List<String>): URLBuilder = apply {
|
||||
private fun RequestConfig.updateForAuth(authNames: kotlin.collections.List<String>) {
|
||||
for (authName in authNames) {
|
||||
val auth = authentications[authName] ?: throw Exception("Authentication undefined: $authName")
|
||||
auth.apply(query, headers)
|
||||
}
|
||||
}
|
||||
|
||||
private fun URLBuilder.appendPath(components: kotlin.collections.List<String>): URLBuilder = apply {
|
||||
encodedPath = encodedPath.trimEnd('/') + components.joinToString("/", prefix = "/") { it.encodeURLQueryComponent() }
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,29 @@
|
||||
package org.openapitools.client.infrastructure
|
||||
|
||||
import kotlinx.serialization.*
|
||||
import kotlinx.serialization.internal.StringDescriptor
|
||||
|
||||
@Serializable
|
||||
class Base64ByteArray(val value: ByteArray) {
|
||||
@Serializer(Base64ByteArray::class)
|
||||
companion object : KSerializer<Base64ByteArray> {
|
||||
override val descriptor = StringDescriptor.withName("Base64ByteArray")
|
||||
override fun serialize(encoder: Encoder, obj: Base64ByteArray) = encoder.encodeString(obj.value.encodeBase64())
|
||||
override fun deserialize(decoder: Decoder) = Base64ByteArray(decoder.decodeString().decodeBase64Bytes())
|
||||
}
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (this === other) return true
|
||||
if (other == null || this::class != other::class) return false
|
||||
other as Base64ByteArray
|
||||
return value.contentEquals(other.value)
|
||||
}
|
||||
|
||||
override fun hashCode(): Int {
|
||||
return value.contentHashCode()
|
||||
}
|
||||
|
||||
override fun toString(): String {
|
||||
return "Base64ByteArray(${hex(value)})"
|
||||
}
|
||||
}
|
@ -0,0 +1,102 @@
|
||||
package org.openapitools.client.infrastructure
|
||||
|
||||
import kotlinx.io.core.*
|
||||
import kotlin.experimental.and
|
||||
|
||||
private val digits = "0123456789abcdef".toCharArray()
|
||||
private const val BASE64_ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
|
||||
private const val BASE64_MASK: Byte = 0x3f
|
||||
private const val BASE64_PAD = '='
|
||||
private val BASE64_INVERSE_ALPHABET = IntArray(256) { BASE64_ALPHABET.indexOf(it.toChar()) }
|
||||
|
||||
private fun String.toCharArray(): CharArray = CharArray(length) { get(it) }
|
||||
private fun ByteArray.clearFrom(from: Int) = (from until size).forEach { this[it] = 0 }
|
||||
private fun Int.toBase64(): Char = BASE64_ALPHABET[this]
|
||||
private fun Byte.fromBase64(): Byte = BASE64_INVERSE_ALPHABET[toInt() and 0xff].toByte() and BASE64_MASK
|
||||
internal fun ByteArray.encodeBase64(): String = buildPacket { writeFully(this@encodeBase64) }.encodeBase64()
|
||||
internal fun String.decodeBase64Bytes(): ByteArray = buildPacket { writeStringUtf8(dropLastWhile { it == BASE64_PAD }) }.decodeBase64Bytes().readBytes()
|
||||
|
||||
/**
|
||||
* Encode [bytes] as a HEX string with no spaces, newlines and `0x` prefixes.
|
||||
*
|
||||
* Taken from https://github.com/ktorio/ktor/blob/master/ktor-utils/common/src/io/ktor/util/Crypto.kt
|
||||
*/
|
||||
internal fun hex(bytes: ByteArray): String {
|
||||
val result = CharArray(bytes.size * 2)
|
||||
var resultIndex = 0
|
||||
val digits = digits
|
||||
|
||||
for (element in bytes) {
|
||||
val b = element.toInt() and 0xff
|
||||
result[resultIndex++] = digits[b shr 4]
|
||||
result[resultIndex++] = digits[b and 0x0f]
|
||||
}
|
||||
|
||||
return String(result)
|
||||
}
|
||||
|
||||
/**
|
||||
* Decode bytes from HEX string. It should be no spaces and `0x` prefixes.
|
||||
*
|
||||
* Taken from https://github.com/ktorio/ktor/blob/master/ktor-utils/common/src/io/ktor/util/Crypto.kt
|
||||
*/
|
||||
internal fun hex(s: String): ByteArray {
|
||||
val result = ByteArray(s.length / 2)
|
||||
for (idx in result.indices) {
|
||||
val srcIdx = idx * 2
|
||||
val high = s[srcIdx].toString().toInt(16) shl 4
|
||||
val low = s[srcIdx + 1].toString().toInt(16)
|
||||
result[idx] = (high or low).toByte()
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* Encode [ByteReadPacket] in base64 format.
|
||||
*
|
||||
* Taken from https://github.com/ktorio/ktor/blob/424d1d2cfaa3281302c60af9500f738c8c2fc846/ktor-utils/common/src/io/ktor/util/Base64.kt
|
||||
*/
|
||||
private fun ByteReadPacket.encodeBase64(): String = buildString {
|
||||
val data = ByteArray(3)
|
||||
while (remaining > 0) {
|
||||
val read = readAvailable(data)
|
||||
data.clearFrom(read)
|
||||
|
||||
val padSize = (data.size - read) * 8 / 6
|
||||
val chunk = ((data[0].toInt() and 0xFF) shl 16) or
|
||||
((data[1].toInt() and 0xFF) shl 8) or
|
||||
(data[2].toInt() and 0xFF)
|
||||
|
||||
for (index in data.size downTo padSize) {
|
||||
val char = (chunk shr (6 * index)) and BASE64_MASK.toInt()
|
||||
append(char.toBase64())
|
||||
}
|
||||
|
||||
repeat(padSize) { append(BASE64_PAD) }
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Decode [ByteReadPacket] from base64 format
|
||||
*
|
||||
* Taken from https://github.com/ktorio/ktor/blob/424d1d2cfaa3281302c60af9500f738c8c2fc846/ktor-utils/common/src/io/ktor/util/Base64.kt
|
||||
*/
|
||||
private fun ByteReadPacket.decodeBase64Bytes(): Input = buildPacket {
|
||||
val data = ByteArray(4)
|
||||
|
||||
while (remaining > 0) {
|
||||
val read = readAvailable(data)
|
||||
|
||||
val chunk = data.foldIndexed(0) { index, result, current ->
|
||||
result or (current.fromBase64().toInt() shl ((3 - index) * 6))
|
||||
}
|
||||
|
||||
for (index in data.size - 2 downTo (data.size - read)) {
|
||||
val origin = (chunk shr (8 * index)) and 0xff
|
||||
writeByte(origin.toByte())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,29 @@
|
||||
package org.openapitools.client.infrastructure
|
||||
|
||||
import kotlinx.serialization.*
|
||||
import kotlinx.serialization.internal.StringDescriptor
|
||||
|
||||
@Serializable
|
||||
class OctetByteArray(val value: ByteArray) {
|
||||
@Serializer(OctetByteArray::class)
|
||||
companion object : KSerializer<OctetByteArray> {
|
||||
override val descriptor = StringDescriptor.withName("OctetByteArray")
|
||||
override fun serialize(encoder: Encoder, obj: OctetByteArray) = encoder.encodeString(hex(obj.value))
|
||||
override fun deserialize(decoder: Decoder) = OctetByteArray(hex(decoder.decodeString()))
|
||||
}
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (this === other) return true
|
||||
if (other == null || this::class != other::class) return false
|
||||
other as OctetByteArray
|
||||
return value.contentEquals(other.value)
|
||||
}
|
||||
|
||||
override fun hashCode(): Int {
|
||||
return value.contentHashCode()
|
||||
}
|
||||
|
||||
override fun toString(): String {
|
||||
return "OctetByteArray(${hex(value)})"
|
||||
}
|
||||
}
|
@ -12,5 +12,5 @@ data class RequestConfig(
|
||||
val method: RequestMethod,
|
||||
val path: String,
|
||||
val headers: MutableMap<String, String> = mutableMapOf(),
|
||||
val query: Map<String, List<String>> = mapOf()
|
||||
val query: MutableMap<String, List<String>> = mutableMapOf()
|
||||
)
|
@ -21,7 +21,9 @@ import kotlinx.serialization.internal.CommonEnumSerializer
|
||||
*/
|
||||
@Serializable
|
||||
data class AdditionalPropertiesClass (
|
||||
@SerialName(value = "mapProperty") val mapProperty: kotlin.collections.Map<kotlin.String, kotlin.String>? = null,
|
||||
@SerialName(value = "mapOfMapProperty") val mapOfMapProperty: kotlin.collections.Map<kotlin.String, kotlin.collections.Map<kotlin.String, kotlin.String>>? = null
|
||||
)
|
||||
@SerialName(value = "map_property") val mapProperty: kotlin.collections.Map<kotlin.String, kotlin.String>? = null,
|
||||
@SerialName(value = "map_of_map_property") val mapOfMapProperty: kotlin.collections.Map<kotlin.String, kotlin.collections.Map<kotlin.String, kotlin.String>>? = null
|
||||
)
|
||||
|
||||
|
||||
|
||||
|
@ -23,5 +23,7 @@ import kotlinx.serialization.internal.CommonEnumSerializer
|
||||
data class Animal (
|
||||
@SerialName(value = "className") @Required val className: kotlin.String,
|
||||
@SerialName(value = "color") val color: kotlin.String? = null
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
|
||||
|
@ -25,5 +25,7 @@ data class ApiResponse (
|
||||
@SerialName(value = "code") val code: kotlin.Int? = null,
|
||||
@SerialName(value = "type") val type: kotlin.String? = null,
|
||||
@SerialName(value = "message") val message: kotlin.String? = null
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
|
||||
|
@ -20,6 +20,8 @@ import kotlinx.serialization.internal.CommonEnumSerializer
|
||||
*/
|
||||
@Serializable
|
||||
data class ArrayOfArrayOfNumberOnly (
|
||||
@SerialName(value = "arrayArrayNumber") val arrayArrayNumber: kotlin.Array<kotlin.Array<kotlin.Double>>? = null
|
||||
)
|
||||
@SerialName(value = "ArrayArrayNumber") val arrayArrayNumber: kotlin.Array<kotlin.Array<kotlin.Double>>? = null
|
||||
)
|
||||
|
||||
|
||||
|
||||
|
@ -20,6 +20,8 @@ import kotlinx.serialization.internal.CommonEnumSerializer
|
||||
*/
|
||||
@Serializable
|
||||
data class ArrayOfNumberOnly (
|
||||
@SerialName(value = "arrayNumber") val arrayNumber: kotlin.Array<kotlin.Double>? = null
|
||||
)
|
||||
@SerialName(value = "ArrayNumber") val arrayNumber: kotlin.Array<kotlin.Double>? = null
|
||||
)
|
||||
|
||||
|
||||
|
||||
|
@ -23,8 +23,10 @@ import kotlinx.serialization.internal.CommonEnumSerializer
|
||||
*/
|
||||
@Serializable
|
||||
data class ArrayTest (
|
||||
@SerialName(value = "arrayOfString") val arrayOfString: kotlin.Array<kotlin.String>? = null,
|
||||
@SerialName(value = "arrayArrayOfInteger") val arrayArrayOfInteger: kotlin.Array<kotlin.Array<kotlin.Long>>? = null,
|
||||
@SerialName(value = "arrayArrayOfModel") val arrayArrayOfModel: kotlin.Array<kotlin.Array<ReadOnlyFirst>>? = null
|
||||
)
|
||||
@SerialName(value = "array_of_string") val arrayOfString: kotlin.Array<kotlin.String>? = null,
|
||||
@SerialName(value = "array_array_of_integer") val arrayArrayOfInteger: kotlin.Array<kotlin.Array<kotlin.Long>>? = null,
|
||||
@SerialName(value = "array_array_of_model") val arrayArrayOfModel: kotlin.Array<kotlin.Array<ReadOnlyFirst>>? = null
|
||||
)
|
||||
|
||||
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user