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:
Andrew Emery
2019-10-28 19:03:49 +11:00
committed by William Cheng
parent 0f2272d9a4
commit d92d84bb12
154 changed files with 1858 additions and 533 deletions

View File

@@ -1 +1 @@
4.1.3-SNAPSHOT
4.2.0-SNAPSHOT

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -4,7 +4,7 @@
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**bar** | **kotlin.String** | | [optional]
**bar** | **kotlin.String** | | [optional] [readonly]
**baz** | **kotlin.String** | | [optional]

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -26,11 +26,13 @@ import kotlinx.serialization.internal.CommonEnumSerializer
@Serializable
data class Capitalization (
@SerialName(value = "smallCamel") val smallCamel: kotlin.String? = null,
@SerialName(value = "capitalCamel") val capitalCamel: kotlin.String? = null,
@SerialName(value = "smallSnake") val smallSnake: kotlin.String? = null,
@SerialName(value = "capitalSnake") val capitalSnake: kotlin.String? = null,
@SerialName(value = "scAETHFlowPoints") val scAETHFlowPoints: kotlin.String? = null,
@SerialName(value = "CapitalCamel") val capitalCamel: kotlin.String? = null,
@SerialName(value = "small_Snake") val smallSnake: kotlin.String? = null,
@SerialName(value = "Capital_Snake") val capitalSnake: kotlin.String? = null,
@SerialName(value = "SCA_ETH_Flow_Points") val scAETHFlowPoints: kotlin.String? = null,
/* Name of the pet */
@SerialName(value = "ATT_NAME") val ATT_NAME: kotlin.String? = null
)
)

View File

@@ -25,5 +25,7 @@ data class Cat (
@SerialName(value = "className") @Required val className: kotlin.String,
@SerialName(value = "declawed") val declawed: kotlin.Boolean? = null,
@SerialName(value = "color") val color: kotlin.String? = null
)
)

View File

@@ -21,5 +21,7 @@ import kotlinx.serialization.internal.CommonEnumSerializer
@Serializable
data class CatAllOf (
@SerialName(value = "declawed") val declawed: kotlin.Boolean? = null
)
)

View File

@@ -23,5 +23,7 @@ import kotlinx.serialization.internal.CommonEnumSerializer
data class Category (
@SerialName(value = "name") @Required val name: kotlin.String,
@SerialName(value = "id") val id: kotlin.Long? = null
)
)

View File

@@ -20,6 +20,8 @@ import kotlinx.serialization.internal.CommonEnumSerializer
*/
@Serializable
data class ClassModel (
@SerialName(value = "propertyClass") val propertyClass: kotlin.String? = null
)
@SerialName(value = "_class") val propertyClass: kotlin.String? = null
)

View File

@@ -21,5 +21,7 @@ import kotlinx.serialization.internal.CommonEnumSerializer
@Serializable
data class Client (
@SerialName(value = "client") val client: kotlin.String? = null
)
)

View File

@@ -25,5 +25,7 @@ data class Dog (
@SerialName(value = "className") @Required val className: kotlin.String,
@SerialName(value = "breed") val breed: kotlin.String? = null,
@SerialName(value = "color") val color: kotlin.String? = null
)
)

View File

@@ -21,5 +21,7 @@ import kotlinx.serialization.internal.CommonEnumSerializer
@Serializable
data class DogAllOf (
@SerialName(value = "breed") val breed: kotlin.String? = null
)
)

View File

@@ -21,40 +21,33 @@ import kotlinx.serialization.internal.CommonEnumSerializer
*/
@Serializable
data class EnumArrays (
@SerialName(value = "justSymbol") val justSymbol: EnumArrays.JustSymbol? = null,
@SerialName(value = "arrayEnum") val arrayEnum: kotlin.Array<EnumArrays.ArrayEnum>? = null
)
{
@SerialName(value = "just_symbol") val justSymbol: EnumArrays.JustSymbol? = null,
@SerialName(value = "array_enum") val arrayEnum: kotlin.Array<EnumArrays.ArrayEnum>? = null
)
{
/**
*
* Values: greaterThanEqual,dollar
*/
@Serializable(with = JustSymbol.Serializer::class)
enum class JustSymbol(val value: kotlin.String){
greaterThanEqual(">="),
dollar("$");
object Serializer : CommonEnumSerializer<JustSymbol>("JustSymbol", values(), values().map { it.value }.toTypedArray())
object Serializer : CommonEnumSerializer<JustSymbol>("JustSymbol", values(), values().map { it.value.toString() }.toTypedArray())
}
/**
*
* Values: fish,crab
*/
@Serializable(with = ArrayEnum.Serializer::class)
enum class ArrayEnum(val value: kotlin.String){
fish("fish"),
crab("crab");
object Serializer : CommonEnumSerializer<ArrayEnum>("ArrayEnum", values(), values().map { it.value }.toTypedArray())
object Serializer : CommonEnumSerializer<ArrayEnum>("ArrayEnum", values(), values().map { it.value.toString() }.toTypedArray())
}
}

View File

@@ -33,6 +33,6 @@ enum class EnumClass(val value: kotlin.String){
object Serializer : CommonEnumSerializer<EnumClass>("EnumClass", values(), values().map { it.value }.toTypedArray())
object Serializer : CommonEnumSerializer<EnumClass>("EnumClass", values(), values().map { it.value.toString() }.toTypedArray())
}

View File

@@ -31,80 +31,63 @@ import kotlinx.serialization.internal.CommonEnumSerializer
*/
@Serializable
data class EnumTest (
@SerialName(value = "enumStringRequired") @Required val enumStringRequired: EnumTest.EnumStringRequired,
@SerialName(value = "enumString") val enumString: EnumTest.EnumString? = null,
@SerialName(value = "enumInteger") val enumInteger: EnumTest.EnumInteger? = null,
@SerialName(value = "enumNumber") val enumNumber: EnumTest.EnumNumber? = null,
@SerialName(value = "enum_string_required") @Required val enumStringRequired: EnumTest.EnumStringRequired,
@SerialName(value = "enum_string") val enumString: EnumTest.EnumString? = null,
@SerialName(value = "enum_integer") val enumInteger: EnumTest.EnumInteger? = null,
@SerialName(value = "enum_number") val enumNumber: EnumTest.EnumNumber? = null,
@SerialName(value = "outerEnum") val outerEnum: OuterEnum? = null,
@SerialName(value = "outerEnumInteger") val outerEnumInteger: OuterEnumInteger? = null,
@SerialName(value = "outerEnumDefaultValue") val outerEnumDefaultValue: OuterEnumDefaultValue? = null,
@SerialName(value = "outerEnumIntegerDefaultValue") val outerEnumIntegerDefaultValue: OuterEnumIntegerDefaultValue? = null
)
{
)
{
/**
*
* Values: uPPER,lower,eMPTY
*/
@Serializable(with = EnumString.Serializer::class)
enum class EnumString(val value: kotlin.String){
uPPER("UPPER"),
lower("lower"),
eMPTY("");
object Serializer : CommonEnumSerializer<EnumString>("EnumString", values(), values().map { it.value }.toTypedArray())
object Serializer : CommonEnumSerializer<EnumString>("EnumString", values(), values().map { it.value.toString() }.toTypedArray())
}
/**
*
* Values: uPPER,lower,eMPTY
*/
@Serializable(with = EnumStringRequired.Serializer::class)
enum class EnumStringRequired(val value: kotlin.String){
uPPER("UPPER"),
lower("lower"),
eMPTY("");
object Serializer : CommonEnumSerializer<EnumStringRequired>("EnumStringRequired", values(), values().map { it.value }.toTypedArray())
object Serializer : CommonEnumSerializer<EnumStringRequired>("EnumStringRequired", values(), values().map { it.value.toString() }.toTypedArray())
}
/**
*
* Values: _1,minus1
*/
@Serializable(with = EnumInteger.Serializer::class)
enum class EnumInteger(val value: kotlin.Int){
_1(1),
minus1(-1);
object Serializer : CommonEnumSerializer<EnumInteger>("EnumInteger", values(), values().map { it.value }.toTypedArray())
object Serializer : CommonEnumSerializer<EnumInteger>("EnumInteger", values(), values().map { it.value.toString() }.toTypedArray())
}
/**
*
* Values: _1period1,minus1Period2
*/
@Serializable(with = EnumNumber.Serializer::class)
enum class EnumNumber(val value: kotlin.Double){
_1period1(1.1),
minus1Period2(-1.2);
object Serializer : CommonEnumSerializer<EnumNumber>("EnumNumber", values(), values().map { it.value }.toTypedArray())
object Serializer : CommonEnumSerializer<EnumNumber>("EnumNumber", values(), values().map { it.value.toString() }.toTypedArray())
}
}

View File

@@ -21,7 +21,9 @@ import kotlinx.serialization.internal.CommonEnumSerializer
*/
@Serializable
data class FileSchemaTestClass (
@SerialName(value = "file") val file: io.ktor.client.request.forms.InputProvider? = null,
@SerialName(value = "files") val files: kotlin.Array<io.ktor.client.request.forms.InputProvider>? = null
)
@SerialName(value = "file") val file: org.openapitools.client.infrastructure.OctetByteArray? = null,
@SerialName(value = "files") val files: kotlin.Array<org.openapitools.client.infrastructure.OctetByteArray>? = null
)

View File

@@ -21,5 +21,7 @@ import kotlinx.serialization.internal.CommonEnumSerializer
@Serializable
data class Foo (
@SerialName(value = "bar") val bar: kotlin.String? = null
)
)

View File

@@ -35,7 +35,7 @@ import kotlinx.serialization.internal.CommonEnumSerializer
@Serializable
data class FormatTest (
@SerialName(value = "number") @Required val number: kotlin.Double,
@SerialName(value = "byte") @Required val byte: kotlin.ByteArray,
@SerialName(value = "byte") @Required val byte: org.openapitools.client.infrastructure.Base64ByteArray,
@SerialName(value = "date") @Required val date: kotlin.String,
@SerialName(value = "password") @Required val password: kotlin.String,
@SerialName(value = "integer") val integer: kotlin.Int? = null,
@@ -44,12 +44,14 @@ data class FormatTest (
@SerialName(value = "float") val float: kotlin.Float? = null,
@SerialName(value = "double") val double: kotlin.Double? = null,
@SerialName(value = "string") val string: kotlin.String? = null,
@SerialName(value = "binary") val binary: io.ktor.client.request.forms.InputProvider? = null,
@SerialName(value = "binary") val binary: org.openapitools.client.infrastructure.OctetByteArray? = null,
@SerialName(value = "dateTime") val dateTime: kotlin.String? = null,
@SerialName(value = "uuid") val uuid: kotlin.String? = null,
/* A string that is a 10 digit number. Can have leading zeros. */
@SerialName(value = "patternWithDigits") val patternWithDigits: kotlin.String? = null,
@SerialName(value = "pattern_with_digits") val patternWithDigits: kotlin.String? = null,
/* A string starting with 'image_' (case insensitive) and one to three digits following i.e. Image_01. */
@SerialName(value = "patternWithDigitsAndDelimiter") val patternWithDigitsAndDelimiter: kotlin.String? = null
)
@SerialName(value = "pattern_with_digits_and_delimiter") val patternWithDigitsAndDelimiter: kotlin.String? = null
)

View File

@@ -23,5 +23,7 @@ import kotlinx.serialization.internal.CommonEnumSerializer
data class HasOnlyReadOnly (
@SerialName(value = "bar") val bar: kotlin.String? = null,
@SerialName(value = "foo") val foo: kotlin.String? = null
)
)

View File

@@ -20,6 +20,8 @@ import kotlinx.serialization.internal.CommonEnumSerializer
*/
@Serializable
data class HealthCheckResult (
@SerialName(value = "nullableMessage") val nullableMessage: kotlin.String? = null
)
@SerialName(value = "NullableMessage") val nullableMessage: kotlin.String? = null
)

View File

@@ -25,5 +25,7 @@ data class InlineObject (
@SerialName(value = "name") val name: kotlin.String? = null,
/* Updated status of the pet */
@SerialName(value = "status") val status: kotlin.String? = null
)
)

View File

@@ -24,6 +24,8 @@ data class InlineObject1 (
/* Additional data to pass to server */
@SerialName(value = "additionalMetadata") val additionalMetadata: kotlin.String? = null,
/* file to upload */
@SerialName(value = "file") val file: io.ktor.client.request.forms.InputProvider? = null
)
@SerialName(value = "file") val file: org.openapitools.client.infrastructure.OctetByteArray? = null
)

View File

@@ -22,43 +22,35 @@ import kotlinx.serialization.internal.CommonEnumSerializer
@Serializable
data class InlineObject2 (
/* Form parameter enum test (string array) */
@SerialName(value = "enumFormStringArray") val enumFormStringArray: kotlin.Array<InlineObject2.EnumFormStringArray>? = null,
@SerialName(value = "enum_form_string_array") val enumFormStringArray: kotlin.Array<InlineObject2.EnumFormStringArray>? = null,
/* Form parameter enum test (string) */
@SerialName(value = "enumFormString") val enumFormString: InlineObject2.EnumFormString? = null
)
{
@SerialName(value = "enum_form_string") val enumFormString: InlineObject2.EnumFormString? = null
)
{
/**
* Form parameter enum test (string array)
* Values: greaterThan,dollar
*/
@Serializable(with = EnumFormStringArray.Serializer::class)
enum class EnumFormStringArray(val value: kotlin.String){
greaterThan(">"),
dollar("$");
object Serializer : CommonEnumSerializer<EnumFormStringArray>("EnumFormStringArray", values(), values().map { it.value }.toTypedArray())
object Serializer : CommonEnumSerializer<EnumFormStringArray>("EnumFormStringArray", values(), values().map { it.value.toString() }.toTypedArray())
}
/**
* Form parameter enum test (string)
* Values: abc,minusEfg,leftParenthesisXyzRightParenthesis
*/
@Serializable(with = EnumFormString.Serializer::class)
enum class EnumFormString(val value: kotlin.String){
abc("_abc"),
minusEfg("-efg"),
leftParenthesisXyzRightParenthesis("(xyz)");
object Serializer : CommonEnumSerializer<EnumFormString>("EnumFormString", values(), values().map { it.value }.toTypedArray())
object Serializer : CommonEnumSerializer<EnumFormString>("EnumFormString", values(), values().map { it.value.toString() }.toTypedArray())
}
}

View File

@@ -38,9 +38,9 @@ data class InlineObject3 (
/* None */
@SerialName(value = "double") @Required val double: kotlin.Double,
/* None */
@SerialName(value = "patternWithoutDelimiter") @Required val patternWithoutDelimiter: kotlin.String,
@SerialName(value = "pattern_without_delimiter") @Required val patternWithoutDelimiter: kotlin.String,
/* None */
@SerialName(value = "byte") @Required val byte: kotlin.ByteArray,
@SerialName(value = "byte") @Required val byte: org.openapitools.client.infrastructure.Base64ByteArray,
/* None */
@SerialName(value = "integer") val integer: kotlin.Int? = null,
/* None */
@@ -52,7 +52,7 @@ data class InlineObject3 (
/* None */
@SerialName(value = "string") val string: kotlin.String? = null,
/* None */
@SerialName(value = "binary") val binary: io.ktor.client.request.forms.InputProvider? = null,
@SerialName(value = "binary") val binary: org.openapitools.client.infrastructure.OctetByteArray? = null,
/* None */
@SerialName(value = "date") val date: kotlin.String? = null,
/* None */
@@ -61,5 +61,7 @@ data class InlineObject3 (
@SerialName(value = "password") val password: kotlin.String? = null,
/* None */
@SerialName(value = "callback") val callback: kotlin.String? = null
)
)

View File

@@ -25,5 +25,7 @@ data class InlineObject4 (
@SerialName(value = "param") @Required val param: kotlin.String,
/* field2 */
@SerialName(value = "param2") @Required val param2: kotlin.String
)
)

View File

@@ -22,8 +22,10 @@ import kotlinx.serialization.internal.CommonEnumSerializer
@Serializable
data class InlineObject5 (
/* file to upload */
@SerialName(value = "requiredFile") @Required val requiredFile: io.ktor.client.request.forms.InputProvider,
@SerialName(value = "requiredFile") @Required val requiredFile: org.openapitools.client.infrastructure.OctetByteArray,
/* Additional data to pass to server */
@SerialName(value = "additionalMetadata") val additionalMetadata: kotlin.String? = null
)
)

View File

@@ -22,5 +22,7 @@ import kotlinx.serialization.internal.CommonEnumSerializer
@Serializable
data class InlineResponseDefault (
@SerialName(value = "string") val string: Foo? = null
)
)

View File

@@ -16,10 +16,12 @@ import kotlinx.serialization.*
import kotlinx.serialization.internal.CommonEnumSerializer
/**
*
* @param ``123minusList``
* @param `123minusList`
*/
@Serializable
data class List (
@SerialName(value = "&#x60;123minusList&#x60;") val ``123minusList``: kotlin.String? = null
)
@SerialName(value = "123-list") val `123minusList`: kotlin.String? = null
)

View File

@@ -23,27 +23,24 @@ import kotlinx.serialization.internal.CommonEnumSerializer
*/
@Serializable
data class MapTest (
@SerialName(value = "mapMapOfString") val mapMapOfString: kotlin.collections.Map<kotlin.String, kotlin.collections.Map<kotlin.String, kotlin.String>>? = null,
@SerialName(value = "mapOfEnumString") val mapOfEnumString: MapTest.MapOfEnumString? = null,
@SerialName(value = "directMap") val directMap: kotlin.collections.Map<kotlin.String, kotlin.Boolean>? = null,
@SerialName(value = "indirectMap") val indirectMap: kotlin.collections.Map<kotlin.String, kotlin.Boolean>? = null
)
{
@SerialName(value = "map_map_of_string") val mapMapOfString: kotlin.collections.Map<kotlin.String, kotlin.collections.Map<kotlin.String, kotlin.String>>? = null,
@SerialName(value = "map_of_enum_string") val mapOfEnumString: MapTest.MapOfEnumString? = null,
@SerialName(value = "direct_map") val directMap: kotlin.collections.Map<kotlin.String, kotlin.Boolean>? = null,
@SerialName(value = "indirect_map") val indirectMap: kotlin.collections.Map<kotlin.String, kotlin.Boolean>? = null
)
{
/**
*
* Values: uPPER,lower
*/
@Serializable(with = MapOfEnumString.Serializer::class)
enum class MapOfEnumString(val value: kotlin.collections.Map<kotlin.String, kotlin.String>){
uPPER("UPPER"),
lower("lower");
object Serializer : CommonEnumSerializer<MapOfEnumString>("MapOfEnumString", values(), values().map { it.value }.toTypedArray())
object Serializer : CommonEnumSerializer<MapOfEnumString>("MapOfEnumString", values(), values().map { it.value.toString() }.toTypedArray())
}
}

View File

@@ -26,5 +26,7 @@ data class MixedPropertiesAndAdditionalPropertiesClass (
@SerialName(value = "uuid") val uuid: kotlin.String? = null,
@SerialName(value = "dateTime") val dateTime: kotlin.String? = null,
@SerialName(value = "map") val map: kotlin.collections.Map<kotlin.String, Animal>? = null
)
)

View File

@@ -22,6 +22,8 @@ import kotlinx.serialization.internal.CommonEnumSerializer
@Serializable
data class Model200Response (
@SerialName(value = "name") val name: kotlin.Int? = null,
@SerialName(value = "propertyClass") val propertyClass: kotlin.String? = null
)
@SerialName(value = "class") val propertyClass: kotlin.String? = null
)

View File

@@ -19,13 +19,15 @@ import kotlinx.serialization.internal.CommonEnumSerializer
* @param name
* @param snakeCase
* @param property
* @param ``123number``
* @param `123number`
*/
@Serializable
data class Name (
@SerialName(value = "name") @Required val name: kotlin.Int,
@SerialName(value = "snakeCase") val snakeCase: kotlin.Int? = null,
@SerialName(value = "snake_case") val snakeCase: kotlin.Int? = null,
@SerialName(value = "property") val property: kotlin.String? = null,
@SerialName(value = "&#x60;123number&#x60;") val ``123number``: kotlin.Int? = null
)
@SerialName(value = "123Number") val `123number`: kotlin.Int? = null
)

View File

@@ -31,17 +31,19 @@ import kotlinx.serialization.internal.CommonEnumSerializer
*/
@Serializable
data class NullableClass (
@SerialName(value = "integerProp") val integerProp: kotlin.Int? = null,
@SerialName(value = "numberProp") val numberProp: kotlin.Double? = null,
@SerialName(value = "booleanProp") val booleanProp: kotlin.Boolean? = null,
@SerialName(value = "stringProp") val stringProp: kotlin.String? = null,
@SerialName(value = "dateProp") val dateProp: kotlin.String? = null,
@SerialName(value = "datetimeProp") val datetimeProp: kotlin.String? = null,
@SerialName(value = "arrayNullableProp") val arrayNullableProp: kotlin.Array<kotlin.Any>? = null,
@SerialName(value = "arrayAndItemsNullableProp") val arrayAndItemsNullableProp: kotlin.Array<kotlin.Any>? = null,
@SerialName(value = "arrayItemsNullable") val arrayItemsNullable: kotlin.Array<kotlin.Any>? = null,
@SerialName(value = "objectNullableProp") val objectNullableProp: kotlin.collections.Map<kotlin.String, kotlin.Any>? = null,
@SerialName(value = "objectAndItemsNullableProp") val objectAndItemsNullableProp: kotlin.collections.Map<kotlin.String, kotlin.Any>? = null,
@SerialName(value = "objectItemsNullable") val objectItemsNullable: kotlin.collections.Map<kotlin.String, kotlin.Any>? = null
)
@SerialName(value = "integer_prop") val integerProp: kotlin.Int? = null,
@SerialName(value = "number_prop") val numberProp: kotlin.Double? = null,
@SerialName(value = "boolean_prop") val booleanProp: kotlin.Boolean? = null,
@SerialName(value = "string_prop") val stringProp: kotlin.String? = null,
@SerialName(value = "date_prop") val dateProp: kotlin.String? = null,
@SerialName(value = "datetime_prop") val datetimeProp: kotlin.String? = null,
@SerialName(value = "array_nullable_prop") val arrayNullableProp: kotlin.Array<kotlin.String>? = null,
@SerialName(value = "array_and_items_nullable_prop") val arrayAndItemsNullableProp: kotlin.Array<kotlin.String>? = null,
@SerialName(value = "array_items_nullable") val arrayItemsNullable: kotlin.Array<kotlin.String>? = null,
@SerialName(value = "object_nullable_prop") val objectNullableProp: kotlin.collections.Map<kotlin.String, kotlin.String>? = null,
@SerialName(value = "object_and_items_nullable_prop") val objectAndItemsNullableProp: kotlin.collections.Map<kotlin.String, kotlin.String>? = null,
@SerialName(value = "object_items_nullable") val objectItemsNullable: kotlin.collections.Map<kotlin.String, kotlin.String>? = null
)

View File

@@ -20,6 +20,8 @@ import kotlinx.serialization.internal.CommonEnumSerializer
*/
@Serializable
data class NumberOnly (
@SerialName(value = "justNumber") val justNumber: kotlin.Double? = null
)
@SerialName(value = "JustNumber") val justNumber: kotlin.Double? = null
)

View File

@@ -32,25 +32,21 @@ data class Order (
/* Order Status */
@SerialName(value = "status") val status: Order.Status? = null,
@SerialName(value = "complete") val complete: kotlin.Boolean? = null
)
{
)
{
/**
* Order Status
* Values: placed,approved,delivered
*/
@Serializable(with = Status.Serializer::class)
enum class Status(val value: kotlin.String){
placed("placed"),
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())
}
}

View File

@@ -22,8 +22,10 @@ import kotlinx.serialization.internal.CommonEnumSerializer
*/
@Serializable
data class OuterComposite (
@SerialName(value = "myNumber") val myNumber: kotlin.Double? = null,
@SerialName(value = "myString") val myString: kotlin.String? = null,
@SerialName(value = "myBoolean") val myBoolean: kotlin.Boolean? = null
)
@SerialName(value = "my_number") val myNumber: kotlin.Double? = null,
@SerialName(value = "my_string") val myString: kotlin.String? = null,
@SerialName(value = "my_boolean") val myBoolean: kotlin.Boolean? = null
)

View File

@@ -33,6 +33,6 @@ enum class OuterEnum(val value: kotlin.String){
object Serializer : CommonEnumSerializer<OuterEnum>("OuterEnum", values(), values().map { it.value }.toTypedArray())
object Serializer : CommonEnumSerializer<OuterEnum>("OuterEnum", values(), values().map { it.value.toString() }.toTypedArray())
}

View File

@@ -33,6 +33,6 @@ enum class OuterEnumDefaultValue(val value: kotlin.String){
object Serializer : CommonEnumSerializer<OuterEnumDefaultValue>("OuterEnumDefaultValue", values(), values().map { it.value }.toTypedArray())
object Serializer : CommonEnumSerializer<OuterEnumDefaultValue>("OuterEnumDefaultValue", values(), values().map { it.value.toString() }.toTypedArray())
}

View File

@@ -33,6 +33,6 @@ enum class OuterEnumInteger(val value: kotlin.Int){
object Serializer : CommonEnumSerializer<OuterEnumInteger>("OuterEnumInteger", values(), values().map { it.value }.toTypedArray())
object Serializer : CommonEnumSerializer<OuterEnumInteger>("OuterEnumInteger", values(), values().map { it.value.toString() }.toTypedArray())
}

View File

@@ -33,6 +33,6 @@ enum class OuterEnumIntegerDefaultValue(val value: kotlin.Int){
object Serializer : CommonEnumSerializer<OuterEnumIntegerDefaultValue>("OuterEnumIntegerDefaultValue", values(), values().map { it.value }.toTypedArray())
object Serializer : CommonEnumSerializer<OuterEnumIntegerDefaultValue>("OuterEnumIntegerDefaultValue", values(), values().map { it.value.toString() }.toTypedArray())
}

View File

@@ -34,25 +34,21 @@ data class Pet (
@SerialName(value = "tags") val tags: kotlin.Array<Tag>? = null,
/* pet status in the store */
@SerialName(value = "status") val status: Pet.Status? = null
)
{
)
{
/**
* pet status in the store
* Values: available,pending,sold
*/
@Serializable(with = Status.Serializer::class)
enum class Status(val value: kotlin.String){
available("available"),
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())
}
}

View File

@@ -23,5 +23,7 @@ import kotlinx.serialization.internal.CommonEnumSerializer
data class ReadOnlyFirst (
@SerialName(value = "bar") val bar: kotlin.String? = null,
@SerialName(value = "baz") val baz: kotlin.String? = null
)
)

View File

@@ -16,10 +16,12 @@ import kotlinx.serialization.*
import kotlinx.serialization.internal.CommonEnumSerializer
/**
* Model for testing reserved words
* @param ``return``
* @param `return`
*/
@Serializable
data class Return (
@SerialName(value = "&#x60;return&#x60;") val ``return``: kotlin.Int? = null
)
@SerialName(value = "return") val `return`: kotlin.Int? = null
)

View File

@@ -20,6 +20,8 @@ import kotlinx.serialization.internal.CommonEnumSerializer
*/
@Serializable
data class SpecialModelname (
@SerialName(value = "dollarSpecialLeftSquareBracketPropertyPeriodNameRightSquareBracket") val dollarSpecialLeftSquareBracketPropertyPeriodNameRightSquareBracket: kotlin.Long? = null
)
@SerialName(value = "\$special[property.name]") val dollarSpecialLeftSquareBracketPropertyPeriodNameRightSquareBracket: kotlin.Long? = null
)

View File

@@ -23,5 +23,7 @@ import kotlinx.serialization.internal.CommonEnumSerializer
data class Tag (
@SerialName(value = "id") val id: kotlin.Long? = null,
@SerialName(value = "name") val name: kotlin.String? = null
)
)

View File

@@ -36,5 +36,7 @@ data class User (
@SerialName(value = "phone") val phone: kotlin.String? = null,
/* User Status */
@SerialName(value = "userStatus") val userStatus: kotlin.Int? = null
)
)

View File

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