forked from loafle/openapi-generator-original
		
	Bugfix Kotlin-client: Can now handle default dataclass values for multiplatform (#12242)
This commit is contained in:
		
							parent
							
								
									5de527e784
								
							
						
					
					
						commit
						074010e124
					
				
							
								
								
									
										7
									
								
								bin/configs/kotlin-bigdecimal-default-multiplatform.yaml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										7
									
								
								bin/configs/kotlin-bigdecimal-default-multiplatform.yaml
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,7 @@
 | 
			
		||||
generatorName: kotlin
 | 
			
		||||
outputDir: samples/client/petstore/kotlin-bigdecimal-default-multiplatform
 | 
			
		||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/issue_10866_bigdecimal_default.yaml
 | 
			
		||||
templateDir: modules/openapi-generator/src/main/resources/kotlin-client
 | 
			
		||||
additionalProperties:
 | 
			
		||||
  artifactId: kotlin-bigdecimal-default-multiplatform
 | 
			
		||||
  library: multiplatform
 | 
			
		||||
@ -1,6 +1,7 @@
 | 
			
		||||
generatorName: kotlin
 | 
			
		||||
outputDir: samples/client/petstore/kotlin-bigdecimal-default
 | 
			
		||||
outputDir: samples/client/petstore/kotlin-bigdecimal-default-okhttp4
 | 
			
		||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/issue_10866_bigdecimal_default.yaml
 | 
			
		||||
templateDir: modules/openapi-generator/src/main/resources/kotlin-client
 | 
			
		||||
additionalProperties:
 | 
			
		||||
  artifactId: kotlin-bigdecimal-default
 | 
			
		||||
  artifactId: kotlin-bigdecimal-default-okhttp4
 | 
			
		||||
  library: jvm-okhttp4
 | 
			
		||||
@ -18,4 +18,4 @@
 | 
			
		||||
    {{#deprecated}}
 | 
			
		||||
    @Deprecated(message = "This property is deprecated.")
 | 
			
		||||
    {{/deprecated}}
 | 
			
		||||
    {{#multiplatform}}@SerialName(value = "{{{vendorExtensions.x-base-name-literal}}}") {{/multiplatform}}{{#isInherited}}override {{/isInherited}}{{>modelMutable}} {{{name}}}: {{#isArray}}{{#isList}}{{#uniqueItems}}kotlin.collections.{{#modelMutable}}Mutable{{/modelMutable}}Set{{/uniqueItems}}{{^uniqueItems}}kotlin.collections.{{#modelMutable}}Mutable{{/modelMutable}}List{{/uniqueItems}}{{/isList}}{{^isList}}kotlin.Array{{/isList}}<{{^items.isEnum}}{{^items.isPrimitiveType}}{{^items.isModel}}{{#kotlinx_serialization}}@Contextual {{/kotlinx_serialization}}{{/items.isModel}}{{/items.isPrimitiveType}}{{{items.dataType}}}{{/items.isEnum}}{{#items.isEnum}}{{classname}}.{{{nameInCamelCase}}}{{/items.isEnum}}>{{/isArray}}{{^isEnum}}{{^isArray}}{{{dataType}}}{{/isArray}}{{/isEnum}}{{#isEnum}}{{^isArray}}{{classname}}.{{{nameInCamelCase}}}{{/isArray}}{{/isEnum}}? = {{^defaultValue}}null{{/defaultValue}}{{#defaultValue}}{{^isNumber}}{{{defaultValue}}}{{/isNumber}}{{#isNumber}}{{{dataType}}}("{{{defaultValue}}}"){{/isNumber}}{{/defaultValue}}
 | 
			
		||||
    {{#multiplatform}}@SerialName(value = "{{{vendorExtensions.x-base-name-literal}}}") {{/multiplatform}}{{#isInherited}}override {{/isInherited}}{{>modelMutable}} {{{name}}}: {{#isArray}}{{#isList}}{{#uniqueItems}}kotlin.collections.{{#modelMutable}}Mutable{{/modelMutable}}Set{{/uniqueItems}}{{^uniqueItems}}kotlin.collections.{{#modelMutable}}Mutable{{/modelMutable}}List{{/uniqueItems}}{{/isList}}{{^isList}}kotlin.Array{{/isList}}<{{^items.isEnum}}{{^items.isPrimitiveType}}{{^items.isModel}}{{#kotlinx_serialization}}@Contextual {{/kotlinx_serialization}}{{/items.isModel}}{{/items.isPrimitiveType}}{{{items.dataType}}}{{/items.isEnum}}{{#items.isEnum}}{{classname}}.{{{nameInCamelCase}}}{{/items.isEnum}}>{{/isArray}}{{^isEnum}}{{^isArray}}{{{dataType}}}{{/isArray}}{{/isEnum}}{{#isEnum}}{{^isArray}}{{classname}}.{{{nameInCamelCase}}}{{/isArray}}{{/isEnum}}? = {{^defaultValue}}null{{/defaultValue}}{{#defaultValue}}{{^isNumber}}{{{defaultValue}}}{{/isNumber}}{{#isNumber}}{{^multiplatform}}{{{dataType}}}("{{{defaultValue}}}"){{/multiplatform}}{{#multiplatform}}({{{defaultValue}}}).toDouble(){{/multiplatform}}{{/isNumber}}{{/defaultValue}}
 | 
			
		||||
@ -18,4 +18,4 @@
 | 
			
		||||
    {{#deprecated}}
 | 
			
		||||
    @Deprecated(message = "This property is deprecated.")
 | 
			
		||||
    {{/deprecated}}
 | 
			
		||||
    {{#multiplatform}}@SerialName(value = "{{{vendorExtensions.x-base-name-literal}}}") @Required {{/multiplatform}}{{#isInherited}}override {{/isInherited}}{{>modelMutable}} {{{name}}}: {{#isArray}}{{#isList}}{{#isUniqueItems}}kotlin.collections.{{#modelMutable}}Mutable{{/modelMutable}}Set{{/isUniqueItems}}{{^isUniqueItems}}kotlin.collections.{{#modelMutable}}Mutable{{/modelMutable}}List{{/isUniqueItems}}{{/isList}}{{^isList}}kotlin.Array{{/isList}}<{{^items.isEnum}}{{^items.isPrimitiveType}}{{^items.isModel}}{{#kotlinx_serialization}}@Contextual {{/kotlinx_serialization}}{{/items.isModel}}{{/items.isPrimitiveType}}{{{items.dataType}}}{{/items.isEnum}}{{#items.isEnum}}{{classname}}.{{{nameInCamelCase}}}{{/items.isEnum}}>{{/isArray}}{{^isEnum}}{{^isArray}}{{{dataType}}}{{/isArray}}{{/isEnum}}{{#isEnum}}{{^isArray}}{{classname}}.{{{nameInCamelCase}}}{{/isArray}}{{/isEnum}}{{#isNullable}}?{{/isNullable}}{{#defaultValue}} = {{^isNumber}}{{{defaultValue}}}{{/isNumber}}{{#isNumber}}{{{dataType}}}("{{{defaultValue}}}"){{/isNumber}}{{/defaultValue}}
 | 
			
		||||
    {{#multiplatform}}@SerialName(value = "{{{vendorExtensions.x-base-name-literal}}}") @Required {{/multiplatform}}{{#isInherited}}override {{/isInherited}}{{>modelMutable}} {{{name}}}: {{#isArray}}{{#isList}}{{#isUniqueItems}}kotlin.collections.{{#modelMutable}}Mutable{{/modelMutable}}Set{{/isUniqueItems}}{{^isUniqueItems}}kotlin.collections.{{#modelMutable}}Mutable{{/modelMutable}}List{{/isUniqueItems}}{{/isList}}{{^isList}}kotlin.Array{{/isList}}<{{^items.isEnum}}{{^items.isPrimitiveType}}{{^items.isModel}}{{#kotlinx_serialization}}@Contextual {{/kotlinx_serialization}}{{/items.isModel}}{{/items.isPrimitiveType}}{{{items.dataType}}}{{/items.isEnum}}{{#items.isEnum}}{{classname}}.{{{nameInCamelCase}}}{{/items.isEnum}}>{{/isArray}}{{^isEnum}}{{^isArray}}{{{dataType}}}{{/isArray}}{{/isEnum}}{{#isEnum}}{{^isArray}}{{classname}}.{{{nameInCamelCase}}}{{/isArray}}{{/isEnum}}{{#isNullable}}?{{/isNullable}}{{#defaultValue}} = {{^isNumber}}{{{defaultValue}}}{{/isNumber}}{{#isNumber}}{{^multiplatform}}{{{dataType}}}("{{{defaultValue}}}"){{/multiplatform}}{{#multiplatform}}({{{defaultValue}}}).toDouble(){{/multiplatform}}{{/isNumber}}{{/defaultValue}}
 | 
			
		||||
@ -0,0 +1,23 @@
 | 
			
		||||
# OpenAPI Generator Ignore
 | 
			
		||||
# Generated by openapi-generator https://github.com/openapitools/openapi-generator
 | 
			
		||||
 | 
			
		||||
# Use this file to prevent files from being overwritten by the generator.
 | 
			
		||||
# The patterns follow closely to .gitignore or .dockerignore.
 | 
			
		||||
 | 
			
		||||
# As an example, the C# client generator defines ApiClient.cs.
 | 
			
		||||
# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line:
 | 
			
		||||
#ApiClient.cs
 | 
			
		||||
 | 
			
		||||
# You can match any string of characters against a directory, file or extension with a single asterisk (*):
 | 
			
		||||
#foo/*/qux
 | 
			
		||||
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux
 | 
			
		||||
 | 
			
		||||
# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
 | 
			
		||||
#foo/**/qux
 | 
			
		||||
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux
 | 
			
		||||
 | 
			
		||||
# You can also negate patterns with an exclamation (!).
 | 
			
		||||
# For example, you can ignore all files in a docs folder with the file extension .md:
 | 
			
		||||
#docs/*.md
 | 
			
		||||
# Then explicitly reverse the ignore rule for a single file:
 | 
			
		||||
#!docs/README.md
 | 
			
		||||
@ -0,0 +1,29 @@
 | 
			
		||||
README.md
 | 
			
		||||
build.gradle.kts
 | 
			
		||||
docs/Apa.md
 | 
			
		||||
docs/DefaultApi.md
 | 
			
		||||
gradle/wrapper/gradle-wrapper.jar
 | 
			
		||||
gradle/wrapper/gradle-wrapper.properties
 | 
			
		||||
gradlew
 | 
			
		||||
gradlew.bat
 | 
			
		||||
settings.gradle.kts
 | 
			
		||||
src/commonTest/kotlin/util/Coroutine.kt
 | 
			
		||||
src/iosTest/kotlin/util/Coroutine.kt
 | 
			
		||||
src/jsTest/kotlin/util/Coroutine.kt
 | 
			
		||||
src/jvmTest/kotlin/util/Coroutine.kt
 | 
			
		||||
src/main/kotlin/org/openapitools/client/apis/DefaultApi.kt
 | 
			
		||||
src/main/kotlin/org/openapitools/client/auth/ApiKeyAuth.kt
 | 
			
		||||
src/main/kotlin/org/openapitools/client/auth/Authentication.kt
 | 
			
		||||
src/main/kotlin/org/openapitools/client/auth/HttpBasicAuth.kt
 | 
			
		||||
src/main/kotlin/org/openapitools/client/auth/HttpBearerAuth.kt
 | 
			
		||||
src/main/kotlin/org/openapitools/client/auth/OAuth.kt
 | 
			
		||||
src/main/kotlin/org/openapitools/client/infrastructure/ApiAbstractions.kt
 | 
			
		||||
src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt
 | 
			
		||||
src/main/kotlin/org/openapitools/client/infrastructure/Base64ByteArray.kt
 | 
			
		||||
src/main/kotlin/org/openapitools/client/infrastructure/Bytes.kt
 | 
			
		||||
src/main/kotlin/org/openapitools/client/infrastructure/HttpResponse.kt
 | 
			
		||||
src/main/kotlin/org/openapitools/client/infrastructure/OctetByteArray.kt
 | 
			
		||||
src/main/kotlin/org/openapitools/client/infrastructure/PartConfig.kt
 | 
			
		||||
src/main/kotlin/org/openapitools/client/infrastructure/RequestConfig.kt
 | 
			
		||||
src/main/kotlin/org/openapitools/client/infrastructure/RequestMethod.kt
 | 
			
		||||
src/main/kotlin/org/openapitools/client/models/Apa.kt
 | 
			
		||||
@ -0,0 +1 @@
 | 
			
		||||
6.0.0-SNAPSHOT
 | 
			
		||||
@ -0,0 +1,41 @@
 | 
			
		||||
# org.openapitools.client - Kotlin client library for Demo
 | 
			
		||||
 | 
			
		||||
## Requires
 | 
			
		||||
 | 
			
		||||
* Kotlin 1.5.10
 | 
			
		||||
 | 
			
		||||
## Build
 | 
			
		||||
 | 
			
		||||
```
 | 
			
		||||
./gradlew check assemble
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
This runs all tests and packages the library.
 | 
			
		||||
 | 
			
		||||
## Features/Implementation Notes
 | 
			
		||||
 | 
			
		||||
* Supports JSON inputs/outputs, File inputs, and Form inputs.
 | 
			
		||||
* Supports collection formats for query parameters: csv, tsv, ssv, pipes.
 | 
			
		||||
* Some Kotlin and Java types are fully qualified to avoid conflicts with types defined in OpenAPI definitions.
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
<a name="documentation-for-api-endpoints"></a>
 | 
			
		||||
## Documentation for API Endpoints
 | 
			
		||||
 | 
			
		||||
All URIs are relative to *http://localhost*
 | 
			
		||||
 | 
			
		||||
Class | Method | HTTP request | Description
 | 
			
		||||
------------ | ------------- | ------------- | -------------
 | 
			
		||||
*DefaultApi* | [**testPost**](docs/DefaultApi.md#testpost) | **POST** /test | 
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
<a name="documentation-for-models"></a>
 | 
			
		||||
## Documentation for Models
 | 
			
		||||
 | 
			
		||||
 - [org.openapitools.client.models.Apa](docs/Apa.md)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
<a name="documentation-for-authorization"></a>
 | 
			
		||||
## Documentation for Authorization
 | 
			
		||||
 | 
			
		||||
All endpoints do not require authorization.
 | 
			
		||||
@ -0,0 +1,99 @@
 | 
			
		||||
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget
 | 
			
		||||
 | 
			
		||||
plugins {
 | 
			
		||||
    kotlin("multiplatform") version "1.6.0" // kotlin_version
 | 
			
		||||
    kotlin("plugin.serialization") version "1.6.0" // kotlin_version
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
group = "org.openapitools"
 | 
			
		||||
version = "1.0.0"
 | 
			
		||||
 | 
			
		||||
val kotlin_version = "1.6.0"
 | 
			
		||||
val coroutines_version = "1.5.2"
 | 
			
		||||
val serialization_version = "1.3.0"
 | 
			
		||||
val ktor_version = "1.6.4"
 | 
			
		||||
 | 
			
		||||
repositories {
 | 
			
		||||
    mavenCentral()
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
kotlin {
 | 
			
		||||
    jvm()
 | 
			
		||||
    ios { binaries { framework { freeCompilerArgs += "-Xobjc-generics" } } }
 | 
			
		||||
    js {
 | 
			
		||||
        browser()
 | 
			
		||||
        nodejs()
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    sourceSets {
 | 
			
		||||
        val commonMain by getting {
 | 
			
		||||
            dependencies {
 | 
			
		||||
                implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version")
 | 
			
		||||
                implementation("org.jetbrains.kotlinx:kotlinx-serialization-core:$serialization_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")
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        val commonTest by getting {
 | 
			
		||||
            dependencies {
 | 
			
		||||
                implementation(kotlin("test"))
 | 
			
		||||
                implementation("io.ktor:ktor-client-mock:$ktor_version")
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        val jvmMain by getting {
 | 
			
		||||
            dependencies {
 | 
			
		||||
                implementation(kotlin("stdlib-jdk7"))
 | 
			
		||||
                implementation("io.ktor:ktor-client-cio-jvm:$ktor_version")
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        val jvmTest by getting {
 | 
			
		||||
            dependencies {
 | 
			
		||||
                implementation(kotlin("test-junit"))
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        val iosMain by getting {
 | 
			
		||||
            dependencies {
 | 
			
		||||
                api("io.ktor:ktor-client-ios:$ktor_version")
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        val iosTest by getting
 | 
			
		||||
 | 
			
		||||
        val jsMain by getting {
 | 
			
		||||
            dependencies {
 | 
			
		||||
                api("io.ktor:ktor-client-js:$ktor_version")
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        val jsTest by getting
 | 
			
		||||
 | 
			
		||||
        all {
 | 
			
		||||
            languageSettings.apply {
 | 
			
		||||
                useExperimentalAnnotation("kotlin.Experimental")
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
tasks {
 | 
			
		||||
    register("iosTest") {
 | 
			
		||||
        val device = project.findProperty("device")?.toString() ?: "iPhone 8"
 | 
			
		||||
        dependsOn("linkDebugTestIosX64")
 | 
			
		||||
        group = JavaBasePlugin.VERIFICATION_GROUP
 | 
			
		||||
        description = "Execute unit tests on ${device} simulator"
 | 
			
		||||
        doLast {
 | 
			
		||||
            val binary = kotlin.targets.getByName<KotlinNativeTarget>("iosX64").binaries.getTest("DEBUG")
 | 
			
		||||
            exec {
 | 
			
		||||
                commandLine("xcrun", "simctl", "spawn", device, binary.outputFile)
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    register("test") {
 | 
			
		||||
        dependsOn("allTests")
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@ -0,0 +1,15 @@
 | 
			
		||||
 | 
			
		||||
# Apa
 | 
			
		||||
 | 
			
		||||
## Properties
 | 
			
		||||
Name | Type | Description | Notes
 | 
			
		||||
------------ | ------------- | ------------- | -------------
 | 
			
		||||
**bepa** | **kotlin.Double** |  | 
 | 
			
		||||
**cepa** | **kotlin.Double** |  | 
 | 
			
		||||
**depa** | **kotlin.Double** |  |  [optional]
 | 
			
		||||
**epa** | **kotlin.Double** |  |  [optional]
 | 
			
		||||
**fepa** | **kotlin.Double** |  |  [optional]
 | 
			
		||||
**gepa** | **kotlin.Double** |  |  [optional]
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -0,0 +1,53 @@
 | 
			
		||||
# DefaultApi
 | 
			
		||||
 | 
			
		||||
All URIs are relative to *http://localhost*
 | 
			
		||||
 | 
			
		||||
Method | HTTP request | Description
 | 
			
		||||
------------- | ------------- | -------------
 | 
			
		||||
[**testPost**](DefaultApi.md#testPost) | **POST** /test | 
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
<a name="testPost"></a>
 | 
			
		||||
# **testPost**
 | 
			
		||||
> testPost(apa)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
### Example
 | 
			
		||||
```kotlin
 | 
			
		||||
// Import classes:
 | 
			
		||||
//import org.openapitools.client.infrastructure.*
 | 
			
		||||
//import org.openapitools.client.models.*
 | 
			
		||||
 | 
			
		||||
val apiInstance = DefaultApi()
 | 
			
		||||
val apa : Apa =  // Apa | 
 | 
			
		||||
try {
 | 
			
		||||
    apiInstance.testPost(apa)
 | 
			
		||||
} catch (e: ClientException) {
 | 
			
		||||
    println("4xx response calling DefaultApi#testPost")
 | 
			
		||||
    e.printStackTrace()
 | 
			
		||||
} catch (e: ServerException) {
 | 
			
		||||
    println("5xx response calling DefaultApi#testPost")
 | 
			
		||||
    e.printStackTrace()
 | 
			
		||||
}
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
### Parameters
 | 
			
		||||
 | 
			
		||||
Name | Type | Description  | Notes
 | 
			
		||||
------------- | ------------- | ------------- | -------------
 | 
			
		||||
 **apa** | [**Apa**](Apa.md)|  |
 | 
			
		||||
 | 
			
		||||
### Return type
 | 
			
		||||
 | 
			
		||||
null (empty response body)
 | 
			
		||||
 | 
			
		||||
### Authorization
 | 
			
		||||
 | 
			
		||||
No authorization required
 | 
			
		||||
 | 
			
		||||
### HTTP request headers
 | 
			
		||||
 | 
			
		||||
 - **Content-Type**: application/json
 | 
			
		||||
 - **Accept**: Not defined
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										
											BIN
										
									
								
								samples/client/petstore/kotlin-bigdecimal-default-multiplatform/gradle/wrapper/gradle-wrapper.jar
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								samples/client/petstore/kotlin-bigdecimal-default-multiplatform/gradle/wrapper/gradle-wrapper.jar
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							@ -0,0 +1,5 @@
 | 
			
		||||
distributionBase=GRADLE_USER_HOME
 | 
			
		||||
distributionPath=wrapper/dists
 | 
			
		||||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.3-all.zip
 | 
			
		||||
zipStoreBase=GRADLE_USER_HOME
 | 
			
		||||
zipStorePath=wrapper/dists
 | 
			
		||||
							
								
								
									
										185
									
								
								samples/client/petstore/kotlin-bigdecimal-default-multiplatform/gradlew
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										185
									
								
								samples/client/petstore/kotlin-bigdecimal-default-multiplatform/gradlew
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@ -0,0 +1,185 @@
 | 
			
		||||
#!/usr/bin/env sh
 | 
			
		||||
 | 
			
		||||
#
 | 
			
		||||
# Copyright 2015 the original author or authors.
 | 
			
		||||
#
 | 
			
		||||
# Licensed under the Apache License, Version 2.0 (the "License");
 | 
			
		||||
# you may not use this file except in compliance with the License.
 | 
			
		||||
# You may obtain a copy of the License at
 | 
			
		||||
#
 | 
			
		||||
#      https://www.apache.org/licenses/LICENSE-2.0
 | 
			
		||||
#
 | 
			
		||||
# Unless required by applicable law or agreed to in writing, software
 | 
			
		||||
# distributed under the License is distributed on an "AS IS" BASIS,
 | 
			
		||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 | 
			
		||||
# See the License for the specific language governing permissions and
 | 
			
		||||
# limitations under the License.
 | 
			
		||||
#
 | 
			
		||||
 | 
			
		||||
##############################################################################
 | 
			
		||||
##
 | 
			
		||||
##  Gradle start up script for UN*X
 | 
			
		||||
##
 | 
			
		||||
##############################################################################
 | 
			
		||||
 | 
			
		||||
# Attempt to set APP_HOME
 | 
			
		||||
# Resolve links: $0 may be a link
 | 
			
		||||
PRG="$0"
 | 
			
		||||
# Need this for relative symlinks.
 | 
			
		||||
while [ -h "$PRG" ] ; do
 | 
			
		||||
    ls=`ls -ld "$PRG"`
 | 
			
		||||
    link=`expr "$ls" : '.*-> \(.*\)$'`
 | 
			
		||||
    if expr "$link" : '/.*' > /dev/null; then
 | 
			
		||||
        PRG="$link"
 | 
			
		||||
    else
 | 
			
		||||
        PRG=`dirname "$PRG"`"/$link"
 | 
			
		||||
    fi
 | 
			
		||||
done
 | 
			
		||||
SAVED="`pwd`"
 | 
			
		||||
cd "`dirname \"$PRG\"`/" >/dev/null
 | 
			
		||||
APP_HOME="`pwd -P`"
 | 
			
		||||
cd "$SAVED" >/dev/null
 | 
			
		||||
 | 
			
		||||
APP_NAME="Gradle"
 | 
			
		||||
APP_BASE_NAME=`basename "$0"`
 | 
			
		||||
 | 
			
		||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
 | 
			
		||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
 | 
			
		||||
 | 
			
		||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
 | 
			
		||||
MAX_FD="maximum"
 | 
			
		||||
 | 
			
		||||
warn () {
 | 
			
		||||
    echo "$*"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
die () {
 | 
			
		||||
    echo
 | 
			
		||||
    echo "$*"
 | 
			
		||||
    echo
 | 
			
		||||
    exit 1
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
# OS specific support (must be 'true' or 'false').
 | 
			
		||||
cygwin=false
 | 
			
		||||
msys=false
 | 
			
		||||
darwin=false
 | 
			
		||||
nonstop=false
 | 
			
		||||
case "`uname`" in
 | 
			
		||||
  CYGWIN* )
 | 
			
		||||
    cygwin=true
 | 
			
		||||
    ;;
 | 
			
		||||
  Darwin* )
 | 
			
		||||
    darwin=true
 | 
			
		||||
    ;;
 | 
			
		||||
  MINGW* )
 | 
			
		||||
    msys=true
 | 
			
		||||
    ;;
 | 
			
		||||
  NONSTOP* )
 | 
			
		||||
    nonstop=true
 | 
			
		||||
    ;;
 | 
			
		||||
esac
 | 
			
		||||
 | 
			
		||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
# Determine the Java command to use to start the JVM.
 | 
			
		||||
if [ -n "$JAVA_HOME" ] ; then
 | 
			
		||||
    if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
 | 
			
		||||
        # IBM's JDK on AIX uses strange locations for the executables
 | 
			
		||||
        JAVACMD="$JAVA_HOME/jre/sh/java"
 | 
			
		||||
    else
 | 
			
		||||
        JAVACMD="$JAVA_HOME/bin/java"
 | 
			
		||||
    fi
 | 
			
		||||
    if [ ! -x "$JAVACMD" ] ; then
 | 
			
		||||
        die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
 | 
			
		||||
 | 
			
		||||
Please set the JAVA_HOME variable in your environment to match the
 | 
			
		||||
location of your Java installation."
 | 
			
		||||
    fi
 | 
			
		||||
else
 | 
			
		||||
    JAVACMD="java"
 | 
			
		||||
    which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
 | 
			
		||||
 | 
			
		||||
Please set the JAVA_HOME variable in your environment to match the
 | 
			
		||||
location of your Java installation."
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
# Increase the maximum file descriptors if we can.
 | 
			
		||||
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
 | 
			
		||||
    MAX_FD_LIMIT=`ulimit -H -n`
 | 
			
		||||
    if [ $? -eq 0 ] ; then
 | 
			
		||||
        if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
 | 
			
		||||
            MAX_FD="$MAX_FD_LIMIT"
 | 
			
		||||
        fi
 | 
			
		||||
        ulimit -n $MAX_FD
 | 
			
		||||
        if [ $? -ne 0 ] ; then
 | 
			
		||||
            warn "Could not set maximum file descriptor limit: $MAX_FD"
 | 
			
		||||
        fi
 | 
			
		||||
    else
 | 
			
		||||
        warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
 | 
			
		||||
    fi
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
# For Darwin, add options to specify how the application appears in the dock
 | 
			
		||||
if $darwin; then
 | 
			
		||||
    GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
# For Cygwin or MSYS, switch paths to Windows format before running java
 | 
			
		||||
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
 | 
			
		||||
    APP_HOME=`cygpath --path --mixed "$APP_HOME"`
 | 
			
		||||
    CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
 | 
			
		||||
 | 
			
		||||
    JAVACMD=`cygpath --unix "$JAVACMD"`
 | 
			
		||||
 | 
			
		||||
    # We build the pattern for arguments to be converted via cygpath
 | 
			
		||||
    ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
 | 
			
		||||
    SEP=""
 | 
			
		||||
    for dir in $ROOTDIRSRAW ; do
 | 
			
		||||
        ROOTDIRS="$ROOTDIRS$SEP$dir"
 | 
			
		||||
        SEP="|"
 | 
			
		||||
    done
 | 
			
		||||
    OURCYGPATTERN="(^($ROOTDIRS))"
 | 
			
		||||
    # Add a user-defined pattern to the cygpath arguments
 | 
			
		||||
    if [ "$GRADLE_CYGPATTERN" != "" ] ; then
 | 
			
		||||
        OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
 | 
			
		||||
    fi
 | 
			
		||||
    # Now convert the arguments - kludge to limit ourselves to /bin/sh
 | 
			
		||||
    i=0
 | 
			
		||||
    for arg in "$@" ; do
 | 
			
		||||
        CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
 | 
			
		||||
        CHECK2=`echo "$arg"|egrep -c "^-"`                                 ### Determine if an option
 | 
			
		||||
 | 
			
		||||
        if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then                    ### Added a condition
 | 
			
		||||
            eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
 | 
			
		||||
        else
 | 
			
		||||
            eval `echo args$i`="\"$arg\""
 | 
			
		||||
        fi
 | 
			
		||||
        i=`expr $i + 1`
 | 
			
		||||
    done
 | 
			
		||||
    case $i in
 | 
			
		||||
        0) set -- ;;
 | 
			
		||||
        1) set -- "$args0" ;;
 | 
			
		||||
        2) set -- "$args0" "$args1" ;;
 | 
			
		||||
        3) set -- "$args0" "$args1" "$args2" ;;
 | 
			
		||||
        4) set -- "$args0" "$args1" "$args2" "$args3" ;;
 | 
			
		||||
        5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
 | 
			
		||||
        6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
 | 
			
		||||
        7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
 | 
			
		||||
        8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
 | 
			
		||||
        9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
 | 
			
		||||
    esac
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
# Escape application args
 | 
			
		||||
save () {
 | 
			
		||||
    for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
 | 
			
		||||
    echo " "
 | 
			
		||||
}
 | 
			
		||||
APP_ARGS=`save "$@"`
 | 
			
		||||
 | 
			
		||||
# Collect all arguments for the java command, following the shell quoting and substitution rules
 | 
			
		||||
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
 | 
			
		||||
 | 
			
		||||
exec "$JAVACMD" "$@"
 | 
			
		||||
							
								
								
									
										89
									
								
								samples/client/petstore/kotlin-bigdecimal-default-multiplatform/gradlew.bat
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										89
									
								
								samples/client/petstore/kotlin-bigdecimal-default-multiplatform/gradlew.bat
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@ -0,0 +1,89 @@
 | 
			
		||||
@rem
 | 
			
		||||
@rem Copyright 2015 the original author or authors.
 | 
			
		||||
@rem
 | 
			
		||||
@rem Licensed under the Apache License, Version 2.0 (the "License");
 | 
			
		||||
@rem you may not use this file except in compliance with the License.
 | 
			
		||||
@rem You may obtain a copy of the License at
 | 
			
		||||
@rem
 | 
			
		||||
@rem      https://www.apache.org/licenses/LICENSE-2.0
 | 
			
		||||
@rem
 | 
			
		||||
@rem Unless required by applicable law or agreed to in writing, software
 | 
			
		||||
@rem distributed under the License is distributed on an "AS IS" BASIS,
 | 
			
		||||
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 | 
			
		||||
@rem See the License for the specific language governing permissions and
 | 
			
		||||
@rem limitations under the License.
 | 
			
		||||
@rem
 | 
			
		||||
 | 
			
		||||
@if "%DEBUG%" == "" @echo off
 | 
			
		||||
@rem ##########################################################################
 | 
			
		||||
@rem
 | 
			
		||||
@rem  Gradle startup script for Windows
 | 
			
		||||
@rem
 | 
			
		||||
@rem ##########################################################################
 | 
			
		||||
 | 
			
		||||
@rem Set local scope for the variables with windows NT shell
 | 
			
		||||
if "%OS%"=="Windows_NT" setlocal
 | 
			
		||||
 | 
			
		||||
set DIRNAME=%~dp0
 | 
			
		||||
if "%DIRNAME%" == "" set DIRNAME=.
 | 
			
		||||
set APP_BASE_NAME=%~n0
 | 
			
		||||
set APP_HOME=%DIRNAME%
 | 
			
		||||
 | 
			
		||||
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
 | 
			
		||||
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
 | 
			
		||||
 | 
			
		||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
 | 
			
		||||
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
 | 
			
		||||
 | 
			
		||||
@rem Find java.exe
 | 
			
		||||
if defined JAVA_HOME goto findJavaFromJavaHome
 | 
			
		||||
 | 
			
		||||
set JAVA_EXE=java.exe
 | 
			
		||||
%JAVA_EXE% -version >NUL 2>&1
 | 
			
		||||
if "%ERRORLEVEL%" == "0" goto execute
 | 
			
		||||
 | 
			
		||||
echo.
 | 
			
		||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
 | 
			
		||||
echo.
 | 
			
		||||
echo Please set the JAVA_HOME variable in your environment to match the
 | 
			
		||||
echo location of your Java installation.
 | 
			
		||||
 | 
			
		||||
goto fail
 | 
			
		||||
 | 
			
		||||
:findJavaFromJavaHome
 | 
			
		||||
set JAVA_HOME=%JAVA_HOME:"=%
 | 
			
		||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
 | 
			
		||||
 | 
			
		||||
if exist "%JAVA_EXE%" goto execute
 | 
			
		||||
 | 
			
		||||
echo.
 | 
			
		||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
 | 
			
		||||
echo.
 | 
			
		||||
echo Please set the JAVA_HOME variable in your environment to match the
 | 
			
		||||
echo location of your Java installation.
 | 
			
		||||
 | 
			
		||||
goto fail
 | 
			
		||||
 | 
			
		||||
:execute
 | 
			
		||||
@rem Setup the command line
 | 
			
		||||
 | 
			
		||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@rem Execute Gradle
 | 
			
		||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
 | 
			
		||||
 | 
			
		||||
:end
 | 
			
		||||
@rem End local scope for the variables with windows NT shell
 | 
			
		||||
if "%ERRORLEVEL%"=="0" goto mainEnd
 | 
			
		||||
 | 
			
		||||
:fail
 | 
			
		||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
 | 
			
		||||
rem the _cmd.exe /c_ return code!
 | 
			
		||||
if  not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
 | 
			
		||||
exit /b 1
 | 
			
		||||
 | 
			
		||||
:mainEnd
 | 
			
		||||
if "%OS%"=="Windows_NT" endlocal
 | 
			
		||||
 | 
			
		||||
:omega
 | 
			
		||||
@ -0,0 +1 @@
 | 
			
		||||
rootProject.name = "kotlin-bigdecimal-default-multiplatform"
 | 
			
		||||
@ -0,0 +1,32 @@
 | 
			
		||||
/**
 | 
			
		||||
 * Demo
 | 
			
		||||
 *
 | 
			
		||||
 * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
 | 
			
		||||
 *
 | 
			
		||||
 * The version of the OpenAPI document: 1.0.0
 | 
			
		||||
 * 
 | 
			
		||||
 *
 | 
			
		||||
 * Please note:
 | 
			
		||||
 * This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
 | 
			
		||||
 * Do not edit this file manually.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
@file:Suppress(
 | 
			
		||||
    "ArrayInDataClass",
 | 
			
		||||
    "EnumEntryName",
 | 
			
		||||
    "RemoveRedundantQualifierName",
 | 
			
		||||
    "UnusedImport"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
package util
 | 
			
		||||
 | 
			
		||||
import kotlinx.coroutines.CoroutineScope
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
* Block the current thread until execution of the given coroutine is complete.
 | 
			
		||||
*
 | 
			
		||||
* @param block The coroutine code.
 | 
			
		||||
* @return The result of the coroutine.
 | 
			
		||||
*/
 | 
			
		||||
internal expect fun <T> runTest(block: suspend CoroutineScope.() -> T): T
 | 
			
		||||
@ -0,0 +1,27 @@
 | 
			
		||||
/**
 | 
			
		||||
 * Demo
 | 
			
		||||
 *
 | 
			
		||||
 * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
 | 
			
		||||
 *
 | 
			
		||||
 * The version of the OpenAPI document: 1.0.0
 | 
			
		||||
 * 
 | 
			
		||||
 *
 | 
			
		||||
 * Please note:
 | 
			
		||||
 * This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
 | 
			
		||||
 * Do not edit this file manually.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
@file:Suppress(
 | 
			
		||||
    "ArrayInDataClass",
 | 
			
		||||
    "EnumEntryName",
 | 
			
		||||
    "RemoveRedundantQualifierName",
 | 
			
		||||
    "UnusedImport"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
package util
 | 
			
		||||
 | 
			
		||||
import kotlinx.coroutines.CoroutineScope
 | 
			
		||||
import kotlin.coroutines.EmptyCoroutineContext
 | 
			
		||||
 | 
			
		||||
internal actual fun <T> runTest(block: suspend CoroutineScope.() -> T): T = kotlinx.coroutines.runBlocking(EmptyCoroutineContext, block)
 | 
			
		||||
@ -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) }
 | 
			
		||||
@ -0,0 +1,27 @@
 | 
			
		||||
/**
 | 
			
		||||
 * Demo
 | 
			
		||||
 *
 | 
			
		||||
 * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
 | 
			
		||||
 *
 | 
			
		||||
 * The version of the OpenAPI document: 1.0.0
 | 
			
		||||
 * 
 | 
			
		||||
 *
 | 
			
		||||
 * Please note:
 | 
			
		||||
 * This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
 | 
			
		||||
 * Do not edit this file manually.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
@file:Suppress(
 | 
			
		||||
    "ArrayInDataClass",
 | 
			
		||||
    "EnumEntryName",
 | 
			
		||||
    "RemoveRedundantQualifierName",
 | 
			
		||||
    "UnusedImport"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
package util
 | 
			
		||||
 | 
			
		||||
import kotlinx.coroutines.CoroutineScope
 | 
			
		||||
import kotlin.coroutines.EmptyCoroutineContext
 | 
			
		||||
 | 
			
		||||
internal actual fun <T> runTest(block: suspend CoroutineScope.() -> T): T = kotlinx.coroutines.runBlocking(EmptyCoroutineContext, block)
 | 
			
		||||
@ -0,0 +1,75 @@
 | 
			
		||||
/**
 | 
			
		||||
 * Demo
 | 
			
		||||
 *
 | 
			
		||||
 * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
 | 
			
		||||
 *
 | 
			
		||||
 * The version of the OpenAPI document: 1.0.0
 | 
			
		||||
 * 
 | 
			
		||||
 *
 | 
			
		||||
 * Please note:
 | 
			
		||||
 * This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
 | 
			
		||||
 * Do not edit this file manually.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
@file:Suppress(
 | 
			
		||||
    "ArrayInDataClass",
 | 
			
		||||
    "EnumEntryName",
 | 
			
		||||
    "RemoveRedundantQualifierName",
 | 
			
		||||
    "UnusedImport"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
package org.openapitools.client.apis
 | 
			
		||||
 | 
			
		||||
import org.openapitools.client.models.Apa
 | 
			
		||||
 | 
			
		||||
import org.openapitools.client.infrastructure.*
 | 
			
		||||
import io.ktor.client.HttpClientConfig
 | 
			
		||||
import io.ktor.client.request.forms.formData
 | 
			
		||||
import io.ktor.client.engine.HttpClientEngine
 | 
			
		||||
import io.ktor.client.features.json.serializer.KotlinxSerializer
 | 
			
		||||
import kotlinx.serialization.json.Json
 | 
			
		||||
import io.ktor.http.ParametersBuilder
 | 
			
		||||
import kotlinx.serialization.*
 | 
			
		||||
import kotlinx.serialization.descriptors.*
 | 
			
		||||
import kotlinx.serialization.encoding.*
 | 
			
		||||
 | 
			
		||||
open class DefaultApi(
 | 
			
		||||
    baseUrl: String = ApiClient.BASE_URL,
 | 
			
		||||
    httpClientEngine: HttpClientEngine? = null,
 | 
			
		||||
    httpClientConfig: ((HttpClientConfig<*>) -> Unit)? = null,
 | 
			
		||||
    jsonSerializer: Json = ApiClient.JSON_DEFAULT
 | 
			
		||||
) : ApiClient(baseUrl, httpClientEngine, httpClientConfig, jsonSerializer) {
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 
 | 
			
		||||
     * 
 | 
			
		||||
     * @param apa  
 | 
			
		||||
     * @return void
 | 
			
		||||
     */
 | 
			
		||||
    open suspend fun testPost(apa: Apa): HttpResponse<Unit> {
 | 
			
		||||
 | 
			
		||||
        val localVariableAuthNames = listOf<String>()
 | 
			
		||||
 | 
			
		||||
        val localVariableBody = apa
 | 
			
		||||
 | 
			
		||||
        val localVariableQuery = mutableMapOf<String, List<String>>()
 | 
			
		||||
 | 
			
		||||
        val localVariableHeaders = mutableMapOf<String, String>()
 | 
			
		||||
 | 
			
		||||
        val localVariableConfig = RequestConfig<kotlin.Any?>(
 | 
			
		||||
            RequestMethod.POST,
 | 
			
		||||
            "/test",
 | 
			
		||||
            query = localVariableQuery,
 | 
			
		||||
            headers = localVariableHeaders
 | 
			
		||||
        )
 | 
			
		||||
 | 
			
		||||
        return jsonRequest(
 | 
			
		||||
            localVariableConfig,
 | 
			
		||||
            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
 | 
			
		||||
 | 
			
		||||
    @OptIn(InternalAPI::class)
 | 
			
		||||
    override fun apply(query: MutableMap<String, List<String>>, headers: MutableMap<String, String>) {
 | 
			
		||||
        if (username == null && password == null) return
 | 
			
		||||
        val str = (username ?: "") + ":" + (password ?: "")
 | 
			
		||||
        val auth = str.encodeBase64()
 | 
			
		||||
        headers["Authorization"] = "Basic $auth"
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@ -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"
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@ -0,0 +1,23 @@
 | 
			
		||||
package org.openapitools.client.infrastructure
 | 
			
		||||
 | 
			
		||||
typealias MultiValueMap = MutableMap<String,List<String>>
 | 
			
		||||
 | 
			
		||||
fun collectionDelimiter(collectionFormat: String) = when(collectionFormat) {
 | 
			
		||||
    "csv" -> ","
 | 
			
		||||
    "tsv" -> "\t"
 | 
			
		||||
    "pipe" -> "|"
 | 
			
		||||
    "space" -> " "
 | 
			
		||||
    else -> ""
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
val defaultMultiValueConverter: (item: Any?) -> String = { item -> "$item" }
 | 
			
		||||
 | 
			
		||||
fun <T : Any?> toMultiValue(items: Array<T>, collectionFormat: String, map: (item: T) -> String = defaultMultiValueConverter)
 | 
			
		||||
        = toMultiValue(items.asIterable(), collectionFormat, map)
 | 
			
		||||
 | 
			
		||||
fun <T : Any?> toMultiValue(items: Iterable<T>, collectionFormat: String, map: (item: T) -> String = defaultMultiValueConverter): List<String> {
 | 
			
		||||
    return when(collectionFormat) {
 | 
			
		||||
        "multi" -> items.map(map)
 | 
			
		||||
        else -> listOf(items.joinToString(separator = collectionDelimiter(collectionFormat), transform = map))
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@ -0,0 +1,195 @@
 | 
			
		||||
package org.openapitools.client.infrastructure
 | 
			
		||||
 | 
			
		||||
import io.ktor.client.HttpClient
 | 
			
		||||
import io.ktor.client.HttpClientConfig
 | 
			
		||||
import io.ktor.client.engine.HttpClientEngine
 | 
			
		||||
import io.ktor.client.features.json.JsonFeature
 | 
			
		||||
import io.ktor.client.features.json.JsonSerializer
 | 
			
		||||
import io.ktor.client.features.json.serializer.KotlinxSerializer
 | 
			
		||||
import io.ktor.client.request.*
 | 
			
		||||
import io.ktor.client.request.forms.FormDataContent
 | 
			
		||||
import io.ktor.client.request.forms.MultiPartFormDataContent
 | 
			
		||||
import io.ktor.client.request.header
 | 
			
		||||
import io.ktor.client.request.parameter
 | 
			
		||||
import io.ktor.client.statement.HttpResponse
 | 
			
		||||
import io.ktor.client.utils.EmptyContent
 | 
			
		||||
import io.ktor.http.*
 | 
			
		||||
import io.ktor.http.content.OutgoingContent
 | 
			
		||||
import io.ktor.http.content.PartData
 | 
			
		||||
import kotlin.Unit
 | 
			
		||||
import kotlinx.serialization.json.Json
 | 
			
		||||
 | 
			
		||||
import org.openapitools.client.apis.*
 | 
			
		||||
import org.openapitools.client.models.*
 | 
			
		||||
import org.openapitools.client.auth.*
 | 
			
		||||
 | 
			
		||||
open class ApiClient(
 | 
			
		||||
        private val baseUrl: String,
 | 
			
		||||
        httpClientEngine: HttpClientEngine?,
 | 
			
		||||
        httpClientConfig: ((HttpClientConfig<*>) -> Unit)? = null,
 | 
			
		||||
        private val json: Json
 | 
			
		||||
) {
 | 
			
		||||
 | 
			
		||||
    private val serializer: JsonSerializer by lazy {
 | 
			
		||||
        KotlinxSerializer(json).ignoreOutgoingContent()
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private val clientConfig: (HttpClientConfig<*>) -> Unit by lazy {
 | 
			
		||||
        {
 | 
			
		||||
            // Hold a reference to the serializer to avoid freezing the entire ApiClient instance
 | 
			
		||||
            // when the JsonFeature is configured.
 | 
			
		||||
            val serializerReference = serializer
 | 
			
		||||
            it.install(JsonFeature) { serializer = serializerReference }
 | 
			
		||||
            httpClientConfig?.invoke(it)
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private val client: HttpClient by lazy {
 | 
			
		||||
        httpClientEngine?.let { HttpClient(it, clientConfig) } ?: HttpClient(clientConfig)
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private val authentications: kotlin.collections.Map<String, Authentication>? = null
 | 
			
		||||
 | 
			
		||||
    companion object {
 | 
			
		||||
        const val BASE_URL = "http://localhost"
 | 
			
		||||
        val JSON_DEFAULT = Json { ignoreUnknownKeys = true }
 | 
			
		||||
        protected val UNSAFE_HEADERS = listOf(HttpHeaders.ContentType)
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 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
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 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
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 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 <T: Any?> multipartFormRequest(requestConfig: RequestConfig<T>, body: kotlin.collections.List<PartData>?, authNames: kotlin.collections.List<String>): HttpResponse {
 | 
			
		||||
        return request(requestConfig, MultiPartFormDataContent(body ?: listOf()), authNames)
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    protected suspend fun <T: Any?> urlEncodedFormRequest(requestConfig: RequestConfig<T>, body: Parameters?, authNames: kotlin.collections.List<String>): HttpResponse {
 | 
			
		||||
        return request(requestConfig, FormDataContent(body ?: Parameters.Empty), authNames)
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    protected suspend fun <T: Any?> jsonRequest(requestConfig: RequestConfig<T>, 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), authNames)
 | 
			
		||||
        else request(requestConfig, authNames = authNames)
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    protected suspend fun <T: Any?> request(requestConfig: RequestConfig<T>, body: OutgoingContent = EmptyContent, authNames: kotlin.collections.List<String>): HttpResponse {
 | 
			
		||||
        requestConfig.updateForAuth<T>(authNames)
 | 
			
		||||
        val headers = requestConfig.headers
 | 
			
		||||
 | 
			
		||||
        return client.request<HttpResponse> {
 | 
			
		||||
            this.url {
 | 
			
		||||
                this.takeFrom(URLBuilder(baseUrl))
 | 
			
		||||
                appendPath(requestConfig.path.trimStart('/').split('/'))
 | 
			
		||||
                requestConfig.query.forEach { query ->
 | 
			
		||||
                    query.value.forEach { value ->
 | 
			
		||||
                        parameter(query.key, value)
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            this.method = requestConfig.method.httpMethod
 | 
			
		||||
            headers.filter { header -> !UNSAFE_HEADERS.contains(header.key) }.forEach { header -> this.header(header.key, header.value) }
 | 
			
		||||
            if (requestConfig.method in listOf(RequestMethod.PUT, RequestMethod.POST, RequestMethod.PATCH))
 | 
			
		||||
                this.body = body
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private fun <T: Any?> RequestConfig<T>.updateForAuth(authNames: kotlin.collections.List<String>) {
 | 
			
		||||
        for (authName in authNames) {
 | 
			
		||||
            val auth = authentications?.get(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() }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private val RequestMethod.httpMethod: HttpMethod
 | 
			
		||||
        get() = when (this) {
 | 
			
		||||
            RequestMethod.DELETE -> HttpMethod.Delete
 | 
			
		||||
            RequestMethod.GET -> HttpMethod.Get
 | 
			
		||||
            RequestMethod.HEAD -> HttpMethod.Head
 | 
			
		||||
            RequestMethod.PATCH -> HttpMethod.Patch
 | 
			
		||||
            RequestMethod.PUT -> HttpMethod.Put
 | 
			
		||||
            RequestMethod.POST -> HttpMethod.Post
 | 
			
		||||
            RequestMethod.OPTIONS -> HttpMethod.Options
 | 
			
		||||
        }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// https://github.com/ktorio/ktor/issues/851
 | 
			
		||||
private fun JsonSerializer.ignoreOutgoingContent() = IgnoreOutgoingContentJsonSerializer(this)
 | 
			
		||||
 | 
			
		||||
private class IgnoreOutgoingContentJsonSerializer(private val delegate: JsonSerializer) : JsonSerializer by delegate {
 | 
			
		||||
    override fun write(data: Any): OutgoingContent {
 | 
			
		||||
        if (data is OutgoingContent) return data
 | 
			
		||||
        return delegate.write(data)
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@ -0,0 +1,30 @@
 | 
			
		||||
package org.openapitools.client.infrastructure
 | 
			
		||||
 | 
			
		||||
import kotlinx.serialization.*
 | 
			
		||||
import kotlinx.serialization.descriptors.*
 | 
			
		||||
import kotlinx.serialization.encoding.*
 | 
			
		||||
 | 
			
		||||
@Serializable
 | 
			
		||||
class Base64ByteArray(val value: ByteArray) {
 | 
			
		||||
    @Serializer(Base64ByteArray::class)
 | 
			
		||||
    companion object : KSerializer<Base64ByteArray> {
 | 
			
		||||
        override val descriptor = PrimitiveSerialDescriptor("Base64ByteArray", PrimitiveKind.STRING)
 | 
			
		||||
        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,100 @@
 | 
			
		||||
package org.openapitools.client.infrastructure
 | 
			
		||||
 | 
			
		||||
import io.ktor.utils.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 result.concatToString()
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * 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,51 @@
 | 
			
		||||
package org.openapitools.client.infrastructure
 | 
			
		||||
 | 
			
		||||
import io.ktor.client.call.TypeInfo
 | 
			
		||||
import io.ktor.client.call.typeInfo
 | 
			
		||||
import io.ktor.http.Headers
 | 
			
		||||
import io.ktor.http.isSuccess
 | 
			
		||||
 | 
			
		||||
open class HttpResponse<T : Any>(val response: io.ktor.client.statement.HttpResponse, val provider: BodyProvider<T>) {
 | 
			
		||||
    val status: Int = response.status.value
 | 
			
		||||
    val success: Boolean = response.status.isSuccess()
 | 
			
		||||
    val headers: Map<String, List<String>> = response.headers.mapEntries()
 | 
			
		||||
    suspend fun body(): T = provider.body(response)
 | 
			
		||||
    suspend fun <V : Any> typedBody(type: TypeInfo): V = provider.typedBody(response, type)
 | 
			
		||||
 | 
			
		||||
    companion object {
 | 
			
		||||
        private fun Headers.mapEntries(): Map<String, List<String>> {
 | 
			
		||||
            val result = mutableMapOf<String, List<String>>()
 | 
			
		||||
            entries().forEach { result[it.key] = it.value }
 | 
			
		||||
            return result
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
interface BodyProvider<T : Any> {
 | 
			
		||||
    suspend fun body(response: io.ktor.client.statement.HttpResponse): T
 | 
			
		||||
    suspend fun <V : Any> typedBody(response: io.ktor.client.statement.HttpResponse, type: TypeInfo): V
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
class TypedBodyProvider<T : Any>(private val type: TypeInfo) : BodyProvider<T> {
 | 
			
		||||
    @Suppress("UNCHECKED_CAST")
 | 
			
		||||
    override suspend fun body(response: io.ktor.client.statement.HttpResponse): T =
 | 
			
		||||
            response.call.receive(type) as T
 | 
			
		||||
 | 
			
		||||
    @Suppress("UNCHECKED_CAST")
 | 
			
		||||
    override suspend fun <V : Any> typedBody(response: io.ktor.client.statement.HttpResponse, type: TypeInfo): V =
 | 
			
		||||
            response.call.receive(type) as V
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
class MappedBodyProvider<S : Any, T : Any>(private val provider: BodyProvider<S>, private val block: S.() -> T) : BodyProvider<T> {
 | 
			
		||||
    override suspend fun body(response: io.ktor.client.statement.HttpResponse): T =
 | 
			
		||||
            block(provider.body(response))
 | 
			
		||||
 | 
			
		||||
    override suspend fun <V : Any> typedBody(response: io.ktor.client.statement.HttpResponse, type: TypeInfo): V =
 | 
			
		||||
            provider.typedBody(response, type)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
inline fun <reified T : Any> io.ktor.client.statement.HttpResponse.wrap(): HttpResponse<T> =
 | 
			
		||||
        HttpResponse(this, TypedBodyProvider(typeInfo<T>()))
 | 
			
		||||
 | 
			
		||||
fun <T : Any, V : Any> HttpResponse<T>.map(block: T.() -> V): HttpResponse<V> =
 | 
			
		||||
        HttpResponse(response, MappedBodyProvider(provider, block))
 | 
			
		||||
@ -0,0 +1,30 @@
 | 
			
		||||
package org.openapitools.client.infrastructure
 | 
			
		||||
 | 
			
		||||
import kotlinx.serialization.*
 | 
			
		||||
import kotlinx.serialization.descriptors.*
 | 
			
		||||
import kotlinx.serialization.encoding.*
 | 
			
		||||
 | 
			
		||||
@Serializable
 | 
			
		||||
class OctetByteArray(val value: ByteArray) {
 | 
			
		||||
    @Serializer(OctetByteArray::class)
 | 
			
		||||
    companion object : KSerializer<OctetByteArray> {
 | 
			
		||||
        override val descriptor = PrimitiveSerialDescriptor("OctetByteArray", PrimitiveKind.STRING)
 | 
			
		||||
        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,11 @@
 | 
			
		||||
package org.openapitools.client.infrastructure
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Defines a config object for a given part of a multi-part request.
 | 
			
		||||
 * NOTE: Headers is a Map<String,String> because rfc2616 defines
 | 
			
		||||
 *       multi-valued headers as csv-only.
 | 
			
		||||
 */
 | 
			
		||||
data class PartConfig<T>(
 | 
			
		||||
    val headers: MutableMap<String, String> = mutableMapOf(),
 | 
			
		||||
    val body: T? = null
 | 
			
		||||
)
 | 
			
		||||
@ -0,0 +1,17 @@
 | 
			
		||||
package org.openapitools.client.infrastructure
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Defines a config object for a given request.
 | 
			
		||||
 * NOTE: This object doesn't include 'body' because it
 | 
			
		||||
 *       allows for caching of the constructed object
 | 
			
		||||
 *       for many request definitions.
 | 
			
		||||
 * NOTE: Headers is a Map<String,String> because rfc2616 defines
 | 
			
		||||
 *       multi-valued headers as csv-only.
 | 
			
		||||
 */
 | 
			
		||||
data class RequestConfig<T>(
 | 
			
		||||
    val method: RequestMethod,
 | 
			
		||||
    val path: String,
 | 
			
		||||
    val headers: MutableMap<String, String> = mutableMapOf(),
 | 
			
		||||
    val query: MutableMap<String, List<String>> = mutableMapOf(),
 | 
			
		||||
    val body: T? = null
 | 
			
		||||
)
 | 
			
		||||
@ -0,0 +1,8 @@
 | 
			
		||||
package org.openapitools.client.infrastructure
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Provides enumerated HTTP verbs
 | 
			
		||||
 */
 | 
			
		||||
enum class RequestMethod {
 | 
			
		||||
    GET, DELETE, HEAD, OPTIONS, PATCH, POST, PUT
 | 
			
		||||
}
 | 
			
		||||
@ -0,0 +1,55 @@
 | 
			
		||||
/**
 | 
			
		||||
 * Demo
 | 
			
		||||
 *
 | 
			
		||||
 * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
 | 
			
		||||
 *
 | 
			
		||||
 * The version of the OpenAPI document: 1.0.0
 | 
			
		||||
 * 
 | 
			
		||||
 *
 | 
			
		||||
 * Please note:
 | 
			
		||||
 * This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
 | 
			
		||||
 * Do not edit this file manually.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
@file:Suppress(
 | 
			
		||||
    "ArrayInDataClass",
 | 
			
		||||
    "EnumEntryName",
 | 
			
		||||
    "RemoveRedundantQualifierName",
 | 
			
		||||
    "UnusedImport"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
package org.openapitools.client.models
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
import kotlinx.serialization.*
 | 
			
		||||
import kotlinx.serialization.descriptors.*
 | 
			
		||||
import kotlinx.serialization.encoding.*
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * 
 | 
			
		||||
 *
 | 
			
		||||
 * @param bepa 
 | 
			
		||||
 * @param cepa 
 | 
			
		||||
 * @param depa 
 | 
			
		||||
 * @param epa 
 | 
			
		||||
 * @param fepa 
 | 
			
		||||
 * @param gepa 
 | 
			
		||||
 */
 | 
			
		||||
@Serializable
 | 
			
		||||
data class Apa (
 | 
			
		||||
 | 
			
		||||
    @SerialName(value = "bepa") @Required val bepa: kotlin.Double = (0).toDouble(),
 | 
			
		||||
 | 
			
		||||
    @SerialName(value = "cepa") @Required val cepa: kotlin.Double = (6.28318).toDouble(),
 | 
			
		||||
 | 
			
		||||
    @SerialName(value = "depa") val depa: kotlin.Double? = (71).toDouble(),
 | 
			
		||||
 | 
			
		||||
    @SerialName(value = "epa") val epa: kotlin.Double? = (-71).toDouble(),
 | 
			
		||||
 | 
			
		||||
    @Deprecated(message = "This property is deprecated.")
 | 
			
		||||
    @SerialName(value = "fepa") val fepa: kotlin.Double? = (100).toDouble(),
 | 
			
		||||
 | 
			
		||||
    @SerialName(value = "gepa") val gepa: kotlin.Double? = null
 | 
			
		||||
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
@ -0,0 +1,23 @@
 | 
			
		||||
# OpenAPI Generator Ignore
 | 
			
		||||
# Generated by openapi-generator https://github.com/openapitools/openapi-generator
 | 
			
		||||
 | 
			
		||||
# Use this file to prevent files from being overwritten by the generator.
 | 
			
		||||
# The patterns follow closely to .gitignore or .dockerignore.
 | 
			
		||||
 | 
			
		||||
# As an example, the C# client generator defines ApiClient.cs.
 | 
			
		||||
# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line:
 | 
			
		||||
#ApiClient.cs
 | 
			
		||||
 | 
			
		||||
# You can match any string of characters against a directory, file or extension with a single asterisk (*):
 | 
			
		||||
#foo/*/qux
 | 
			
		||||
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux
 | 
			
		||||
 | 
			
		||||
# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
 | 
			
		||||
#foo/**/qux
 | 
			
		||||
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux
 | 
			
		||||
 | 
			
		||||
# You can also negate patterns with an exclamation (!).
 | 
			
		||||
# For example, you can ignore all files in a docs folder with the file extension .md:
 | 
			
		||||
#docs/*.md
 | 
			
		||||
# Then explicitly reverse the ignore rule for a single file:
 | 
			
		||||
#!docs/README.md
 | 
			
		||||
@ -0,0 +1,28 @@
 | 
			
		||||
README.md
 | 
			
		||||
build.gradle
 | 
			
		||||
docs/Apa.md
 | 
			
		||||
docs/DefaultApi.md
 | 
			
		||||
gradle/wrapper/gradle-wrapper.jar
 | 
			
		||||
gradle/wrapper/gradle-wrapper.properties
 | 
			
		||||
gradlew
 | 
			
		||||
gradlew.bat
 | 
			
		||||
settings.gradle
 | 
			
		||||
src/main/kotlin/org/openapitools/client/apis/DefaultApi.kt
 | 
			
		||||
src/main/kotlin/org/openapitools/client/infrastructure/ApiAbstractions.kt
 | 
			
		||||
src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt
 | 
			
		||||
src/main/kotlin/org/openapitools/client/infrastructure/ApiResponse.kt
 | 
			
		||||
src/main/kotlin/org/openapitools/client/infrastructure/BigDecimalAdapter.kt
 | 
			
		||||
src/main/kotlin/org/openapitools/client/infrastructure/BigIntegerAdapter.kt
 | 
			
		||||
src/main/kotlin/org/openapitools/client/infrastructure/ByteArrayAdapter.kt
 | 
			
		||||
src/main/kotlin/org/openapitools/client/infrastructure/Errors.kt
 | 
			
		||||
src/main/kotlin/org/openapitools/client/infrastructure/LocalDateAdapter.kt
 | 
			
		||||
src/main/kotlin/org/openapitools/client/infrastructure/LocalDateTimeAdapter.kt
 | 
			
		||||
src/main/kotlin/org/openapitools/client/infrastructure/OffsetDateTimeAdapter.kt
 | 
			
		||||
src/main/kotlin/org/openapitools/client/infrastructure/PartConfig.kt
 | 
			
		||||
src/main/kotlin/org/openapitools/client/infrastructure/RequestConfig.kt
 | 
			
		||||
src/main/kotlin/org/openapitools/client/infrastructure/RequestMethod.kt
 | 
			
		||||
src/main/kotlin/org/openapitools/client/infrastructure/ResponseExtensions.kt
 | 
			
		||||
src/main/kotlin/org/openapitools/client/infrastructure/Serializer.kt
 | 
			
		||||
src/main/kotlin/org/openapitools/client/infrastructure/URIAdapter.kt
 | 
			
		||||
src/main/kotlin/org/openapitools/client/infrastructure/UUIDAdapter.kt
 | 
			
		||||
src/main/kotlin/org/openapitools/client/models/Apa.kt
 | 
			
		||||
@ -0,0 +1 @@
 | 
			
		||||
6.0.0-SNAPSHOT
 | 
			
		||||
@ -0,0 +1,50 @@
 | 
			
		||||
# org.openapitools.client - Kotlin client library for Demo
 | 
			
		||||
 | 
			
		||||
## Requires
 | 
			
		||||
 | 
			
		||||
* Kotlin 1.4.30
 | 
			
		||||
* Gradle 6.8.3
 | 
			
		||||
 | 
			
		||||
## Build
 | 
			
		||||
 | 
			
		||||
First, create the gradle wrapper script:
 | 
			
		||||
 | 
			
		||||
```
 | 
			
		||||
gradle wrapper
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
Then, run:
 | 
			
		||||
 | 
			
		||||
```
 | 
			
		||||
./gradlew check assemble
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
This runs all tests and packages the library.
 | 
			
		||||
 | 
			
		||||
## Features/Implementation Notes
 | 
			
		||||
 | 
			
		||||
* Supports JSON inputs/outputs, File inputs, and Form inputs.
 | 
			
		||||
* Supports collection formats for query parameters: csv, tsv, ssv, pipes.
 | 
			
		||||
* Some Kotlin and Java types are fully qualified to avoid conflicts with types defined in OpenAPI definitions.
 | 
			
		||||
* Implementation of ApiClient is intended to reduce method counts, specifically to benefit Android targets.
 | 
			
		||||
 | 
			
		||||
<a name="documentation-for-api-endpoints"></a>
 | 
			
		||||
## Documentation for API Endpoints
 | 
			
		||||
 | 
			
		||||
All URIs are relative to *http://localhost*
 | 
			
		||||
 | 
			
		||||
Class | Method | HTTP request | Description
 | 
			
		||||
------------ | ------------- | ------------- | -------------
 | 
			
		||||
*DefaultApi* | [**testPost**](docs/DefaultApi.md#testpost) | **POST** /test | 
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
<a name="documentation-for-models"></a>
 | 
			
		||||
## Documentation for Models
 | 
			
		||||
 | 
			
		||||
 - [org.openapitools.client.models.Apa](docs/Apa.md)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
<a name="documentation-for-authorization"></a>
 | 
			
		||||
## Documentation for Authorization
 | 
			
		||||
 | 
			
		||||
All endpoints do not require authorization.
 | 
			
		||||
@ -0,0 +1,37 @@
 | 
			
		||||
group 'org.openapitools'
 | 
			
		||||
version '1.0.0'
 | 
			
		||||
 | 
			
		||||
wrapper {
 | 
			
		||||
    gradleVersion = '6.8.3'
 | 
			
		||||
    distributionUrl = "https://services.gradle.org/distributions/gradle-$gradleVersion-all.zip"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
buildscript {
 | 
			
		||||
    ext.kotlin_version = '1.5.10'
 | 
			
		||||
 | 
			
		||||
    repositories {
 | 
			
		||||
        maven { url "https://repo1.maven.org/maven2" }
 | 
			
		||||
    }
 | 
			
		||||
    dependencies {
 | 
			
		||||
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
apply plugin: 'kotlin'
 | 
			
		||||
 | 
			
		||||
repositories {
 | 
			
		||||
    maven { url "https://repo1.maven.org/maven2" }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
test {
 | 
			
		||||
    useJUnitPlatform()
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
dependencies {
 | 
			
		||||
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
 | 
			
		||||
    implementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
 | 
			
		||||
    implementation "com.squareup.moshi:moshi-kotlin:1.12.0"
 | 
			
		||||
    implementation "com.squareup.moshi:moshi-adapters:1.12.0"
 | 
			
		||||
    implementation "com.squareup.okhttp3:okhttp:4.9.1"
 | 
			
		||||
    testImplementation "io.kotlintest:kotlintest-runner-junit5:3.4.2"
 | 
			
		||||
}
 | 
			
		||||
@ -0,0 +1,15 @@
 | 
			
		||||
 | 
			
		||||
# Apa
 | 
			
		||||
 | 
			
		||||
## Properties
 | 
			
		||||
Name | Type | Description | Notes
 | 
			
		||||
------------ | ------------- | ------------- | -------------
 | 
			
		||||
**bepa** | [**java.math.BigDecimal**](java.math.BigDecimal.md) |  | 
 | 
			
		||||
**cepa** | [**java.math.BigDecimal**](java.math.BigDecimal.md) |  | 
 | 
			
		||||
**depa** | [**java.math.BigDecimal**](java.math.BigDecimal.md) |  |  [optional]
 | 
			
		||||
**epa** | [**java.math.BigDecimal**](java.math.BigDecimal.md) |  |  [optional]
 | 
			
		||||
**fepa** | [**java.math.BigDecimal**](java.math.BigDecimal.md) |  |  [optional]
 | 
			
		||||
**gepa** | [**java.math.BigDecimal**](java.math.BigDecimal.md) |  |  [optional]
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -0,0 +1,53 @@
 | 
			
		||||
# DefaultApi
 | 
			
		||||
 | 
			
		||||
All URIs are relative to *http://localhost*
 | 
			
		||||
 | 
			
		||||
Method | HTTP request | Description
 | 
			
		||||
------------- | ------------- | -------------
 | 
			
		||||
[**testPost**](DefaultApi.md#testPost) | **POST** /test | 
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
<a name="testPost"></a>
 | 
			
		||||
# **testPost**
 | 
			
		||||
> testPost(apa)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
### Example
 | 
			
		||||
```kotlin
 | 
			
		||||
// Import classes:
 | 
			
		||||
//import org.openapitools.client.infrastructure.*
 | 
			
		||||
//import org.openapitools.client.models.*
 | 
			
		||||
 | 
			
		||||
val apiInstance = DefaultApi()
 | 
			
		||||
val apa : Apa =  // Apa | 
 | 
			
		||||
try {
 | 
			
		||||
    apiInstance.testPost(apa)
 | 
			
		||||
} catch (e: ClientException) {
 | 
			
		||||
    println("4xx response calling DefaultApi#testPost")
 | 
			
		||||
    e.printStackTrace()
 | 
			
		||||
} catch (e: ServerException) {
 | 
			
		||||
    println("5xx response calling DefaultApi#testPost")
 | 
			
		||||
    e.printStackTrace()
 | 
			
		||||
}
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
### Parameters
 | 
			
		||||
 | 
			
		||||
Name | Type | Description  | Notes
 | 
			
		||||
------------- | ------------- | ------------- | -------------
 | 
			
		||||
 **apa** | [**Apa**](Apa.md)|  |
 | 
			
		||||
 | 
			
		||||
### Return type
 | 
			
		||||
 | 
			
		||||
null (empty response body)
 | 
			
		||||
 | 
			
		||||
### Authorization
 | 
			
		||||
 | 
			
		||||
No authorization required
 | 
			
		||||
 | 
			
		||||
### HTTP request headers
 | 
			
		||||
 | 
			
		||||
 - **Content-Type**: application/json
 | 
			
		||||
 - **Accept**: Not defined
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										
											BIN
										
									
								
								samples/client/petstore/kotlin-bigdecimal-default-okhttp4/gradle/wrapper/gradle-wrapper.jar
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								samples/client/petstore/kotlin-bigdecimal-default-okhttp4/gradle/wrapper/gradle-wrapper.jar
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							@ -0,0 +1,5 @@
 | 
			
		||||
distributionBase=GRADLE_USER_HOME
 | 
			
		||||
distributionPath=wrapper/dists
 | 
			
		||||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.3-all.zip
 | 
			
		||||
zipStoreBase=GRADLE_USER_HOME
 | 
			
		||||
zipStorePath=wrapper/dists
 | 
			
		||||
							
								
								
									
										185
									
								
								samples/client/petstore/kotlin-bigdecimal-default-okhttp4/gradlew
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										185
									
								
								samples/client/petstore/kotlin-bigdecimal-default-okhttp4/gradlew
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@ -0,0 +1,185 @@
 | 
			
		||||
#!/usr/bin/env sh
 | 
			
		||||
 | 
			
		||||
#
 | 
			
		||||
# Copyright 2015 the original author or authors.
 | 
			
		||||
#
 | 
			
		||||
# Licensed under the Apache License, Version 2.0 (the "License");
 | 
			
		||||
# you may not use this file except in compliance with the License.
 | 
			
		||||
# You may obtain a copy of the License at
 | 
			
		||||
#
 | 
			
		||||
#      https://www.apache.org/licenses/LICENSE-2.0
 | 
			
		||||
#
 | 
			
		||||
# Unless required by applicable law or agreed to in writing, software
 | 
			
		||||
# distributed under the License is distributed on an "AS IS" BASIS,
 | 
			
		||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 | 
			
		||||
# See the License for the specific language governing permissions and
 | 
			
		||||
# limitations under the License.
 | 
			
		||||
#
 | 
			
		||||
 | 
			
		||||
##############################################################################
 | 
			
		||||
##
 | 
			
		||||
##  Gradle start up script for UN*X
 | 
			
		||||
##
 | 
			
		||||
##############################################################################
 | 
			
		||||
 | 
			
		||||
# Attempt to set APP_HOME
 | 
			
		||||
# Resolve links: $0 may be a link
 | 
			
		||||
PRG="$0"
 | 
			
		||||
# Need this for relative symlinks.
 | 
			
		||||
while [ -h "$PRG" ] ; do
 | 
			
		||||
    ls=`ls -ld "$PRG"`
 | 
			
		||||
    link=`expr "$ls" : '.*-> \(.*\)$'`
 | 
			
		||||
    if expr "$link" : '/.*' > /dev/null; then
 | 
			
		||||
        PRG="$link"
 | 
			
		||||
    else
 | 
			
		||||
        PRG=`dirname "$PRG"`"/$link"
 | 
			
		||||
    fi
 | 
			
		||||
done
 | 
			
		||||
SAVED="`pwd`"
 | 
			
		||||
cd "`dirname \"$PRG\"`/" >/dev/null
 | 
			
		||||
APP_HOME="`pwd -P`"
 | 
			
		||||
cd "$SAVED" >/dev/null
 | 
			
		||||
 | 
			
		||||
APP_NAME="Gradle"
 | 
			
		||||
APP_BASE_NAME=`basename "$0"`
 | 
			
		||||
 | 
			
		||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
 | 
			
		||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
 | 
			
		||||
 | 
			
		||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
 | 
			
		||||
MAX_FD="maximum"
 | 
			
		||||
 | 
			
		||||
warn () {
 | 
			
		||||
    echo "$*"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
die () {
 | 
			
		||||
    echo
 | 
			
		||||
    echo "$*"
 | 
			
		||||
    echo
 | 
			
		||||
    exit 1
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
# OS specific support (must be 'true' or 'false').
 | 
			
		||||
cygwin=false
 | 
			
		||||
msys=false
 | 
			
		||||
darwin=false
 | 
			
		||||
nonstop=false
 | 
			
		||||
case "`uname`" in
 | 
			
		||||
  CYGWIN* )
 | 
			
		||||
    cygwin=true
 | 
			
		||||
    ;;
 | 
			
		||||
  Darwin* )
 | 
			
		||||
    darwin=true
 | 
			
		||||
    ;;
 | 
			
		||||
  MINGW* )
 | 
			
		||||
    msys=true
 | 
			
		||||
    ;;
 | 
			
		||||
  NONSTOP* )
 | 
			
		||||
    nonstop=true
 | 
			
		||||
    ;;
 | 
			
		||||
esac
 | 
			
		||||
 | 
			
		||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
# Determine the Java command to use to start the JVM.
 | 
			
		||||
if [ -n "$JAVA_HOME" ] ; then
 | 
			
		||||
    if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
 | 
			
		||||
        # IBM's JDK on AIX uses strange locations for the executables
 | 
			
		||||
        JAVACMD="$JAVA_HOME/jre/sh/java"
 | 
			
		||||
    else
 | 
			
		||||
        JAVACMD="$JAVA_HOME/bin/java"
 | 
			
		||||
    fi
 | 
			
		||||
    if [ ! -x "$JAVACMD" ] ; then
 | 
			
		||||
        die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
 | 
			
		||||
 | 
			
		||||
Please set the JAVA_HOME variable in your environment to match the
 | 
			
		||||
location of your Java installation."
 | 
			
		||||
    fi
 | 
			
		||||
else
 | 
			
		||||
    JAVACMD="java"
 | 
			
		||||
    which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
 | 
			
		||||
 | 
			
		||||
Please set the JAVA_HOME variable in your environment to match the
 | 
			
		||||
location of your Java installation."
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
# Increase the maximum file descriptors if we can.
 | 
			
		||||
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
 | 
			
		||||
    MAX_FD_LIMIT=`ulimit -H -n`
 | 
			
		||||
    if [ $? -eq 0 ] ; then
 | 
			
		||||
        if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
 | 
			
		||||
            MAX_FD="$MAX_FD_LIMIT"
 | 
			
		||||
        fi
 | 
			
		||||
        ulimit -n $MAX_FD
 | 
			
		||||
        if [ $? -ne 0 ] ; then
 | 
			
		||||
            warn "Could not set maximum file descriptor limit: $MAX_FD"
 | 
			
		||||
        fi
 | 
			
		||||
    else
 | 
			
		||||
        warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
 | 
			
		||||
    fi
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
# For Darwin, add options to specify how the application appears in the dock
 | 
			
		||||
if $darwin; then
 | 
			
		||||
    GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
# For Cygwin or MSYS, switch paths to Windows format before running java
 | 
			
		||||
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
 | 
			
		||||
    APP_HOME=`cygpath --path --mixed "$APP_HOME"`
 | 
			
		||||
    CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
 | 
			
		||||
 | 
			
		||||
    JAVACMD=`cygpath --unix "$JAVACMD"`
 | 
			
		||||
 | 
			
		||||
    # We build the pattern for arguments to be converted via cygpath
 | 
			
		||||
    ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
 | 
			
		||||
    SEP=""
 | 
			
		||||
    for dir in $ROOTDIRSRAW ; do
 | 
			
		||||
        ROOTDIRS="$ROOTDIRS$SEP$dir"
 | 
			
		||||
        SEP="|"
 | 
			
		||||
    done
 | 
			
		||||
    OURCYGPATTERN="(^($ROOTDIRS))"
 | 
			
		||||
    # Add a user-defined pattern to the cygpath arguments
 | 
			
		||||
    if [ "$GRADLE_CYGPATTERN" != "" ] ; then
 | 
			
		||||
        OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
 | 
			
		||||
    fi
 | 
			
		||||
    # Now convert the arguments - kludge to limit ourselves to /bin/sh
 | 
			
		||||
    i=0
 | 
			
		||||
    for arg in "$@" ; do
 | 
			
		||||
        CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
 | 
			
		||||
        CHECK2=`echo "$arg"|egrep -c "^-"`                                 ### Determine if an option
 | 
			
		||||
 | 
			
		||||
        if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then                    ### Added a condition
 | 
			
		||||
            eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
 | 
			
		||||
        else
 | 
			
		||||
            eval `echo args$i`="\"$arg\""
 | 
			
		||||
        fi
 | 
			
		||||
        i=`expr $i + 1`
 | 
			
		||||
    done
 | 
			
		||||
    case $i in
 | 
			
		||||
        0) set -- ;;
 | 
			
		||||
        1) set -- "$args0" ;;
 | 
			
		||||
        2) set -- "$args0" "$args1" ;;
 | 
			
		||||
        3) set -- "$args0" "$args1" "$args2" ;;
 | 
			
		||||
        4) set -- "$args0" "$args1" "$args2" "$args3" ;;
 | 
			
		||||
        5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
 | 
			
		||||
        6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
 | 
			
		||||
        7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
 | 
			
		||||
        8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
 | 
			
		||||
        9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
 | 
			
		||||
    esac
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
# Escape application args
 | 
			
		||||
save () {
 | 
			
		||||
    for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
 | 
			
		||||
    echo " "
 | 
			
		||||
}
 | 
			
		||||
APP_ARGS=`save "$@"`
 | 
			
		||||
 | 
			
		||||
# Collect all arguments for the java command, following the shell quoting and substitution rules
 | 
			
		||||
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
 | 
			
		||||
 | 
			
		||||
exec "$JAVACMD" "$@"
 | 
			
		||||
							
								
								
									
										89
									
								
								samples/client/petstore/kotlin-bigdecimal-default-okhttp4/gradlew.bat
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										89
									
								
								samples/client/petstore/kotlin-bigdecimal-default-okhttp4/gradlew.bat
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@ -0,0 +1,89 @@
 | 
			
		||||
@rem
 | 
			
		||||
@rem Copyright 2015 the original author or authors.
 | 
			
		||||
@rem
 | 
			
		||||
@rem Licensed under the Apache License, Version 2.0 (the "License");
 | 
			
		||||
@rem you may not use this file except in compliance with the License.
 | 
			
		||||
@rem You may obtain a copy of the License at
 | 
			
		||||
@rem
 | 
			
		||||
@rem      https://www.apache.org/licenses/LICENSE-2.0
 | 
			
		||||
@rem
 | 
			
		||||
@rem Unless required by applicable law or agreed to in writing, software
 | 
			
		||||
@rem distributed under the License is distributed on an "AS IS" BASIS,
 | 
			
		||||
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 | 
			
		||||
@rem See the License for the specific language governing permissions and
 | 
			
		||||
@rem limitations under the License.
 | 
			
		||||
@rem
 | 
			
		||||
 | 
			
		||||
@if "%DEBUG%" == "" @echo off
 | 
			
		||||
@rem ##########################################################################
 | 
			
		||||
@rem
 | 
			
		||||
@rem  Gradle startup script for Windows
 | 
			
		||||
@rem
 | 
			
		||||
@rem ##########################################################################
 | 
			
		||||
 | 
			
		||||
@rem Set local scope for the variables with windows NT shell
 | 
			
		||||
if "%OS%"=="Windows_NT" setlocal
 | 
			
		||||
 | 
			
		||||
set DIRNAME=%~dp0
 | 
			
		||||
if "%DIRNAME%" == "" set DIRNAME=.
 | 
			
		||||
set APP_BASE_NAME=%~n0
 | 
			
		||||
set APP_HOME=%DIRNAME%
 | 
			
		||||
 | 
			
		||||
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
 | 
			
		||||
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
 | 
			
		||||
 | 
			
		||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
 | 
			
		||||
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
 | 
			
		||||
 | 
			
		||||
@rem Find java.exe
 | 
			
		||||
if defined JAVA_HOME goto findJavaFromJavaHome
 | 
			
		||||
 | 
			
		||||
set JAVA_EXE=java.exe
 | 
			
		||||
%JAVA_EXE% -version >NUL 2>&1
 | 
			
		||||
if "%ERRORLEVEL%" == "0" goto execute
 | 
			
		||||
 | 
			
		||||
echo.
 | 
			
		||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
 | 
			
		||||
echo.
 | 
			
		||||
echo Please set the JAVA_HOME variable in your environment to match the
 | 
			
		||||
echo location of your Java installation.
 | 
			
		||||
 | 
			
		||||
goto fail
 | 
			
		||||
 | 
			
		||||
:findJavaFromJavaHome
 | 
			
		||||
set JAVA_HOME=%JAVA_HOME:"=%
 | 
			
		||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
 | 
			
		||||
 | 
			
		||||
if exist "%JAVA_EXE%" goto execute
 | 
			
		||||
 | 
			
		||||
echo.
 | 
			
		||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
 | 
			
		||||
echo.
 | 
			
		||||
echo Please set the JAVA_HOME variable in your environment to match the
 | 
			
		||||
echo location of your Java installation.
 | 
			
		||||
 | 
			
		||||
goto fail
 | 
			
		||||
 | 
			
		||||
:execute
 | 
			
		||||
@rem Setup the command line
 | 
			
		||||
 | 
			
		||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@rem Execute Gradle
 | 
			
		||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
 | 
			
		||||
 | 
			
		||||
:end
 | 
			
		||||
@rem End local scope for the variables with windows NT shell
 | 
			
		||||
if "%ERRORLEVEL%"=="0" goto mainEnd
 | 
			
		||||
 | 
			
		||||
:fail
 | 
			
		||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
 | 
			
		||||
rem the _cmd.exe /c_ return code!
 | 
			
		||||
if  not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
 | 
			
		||||
exit /b 1
 | 
			
		||||
 | 
			
		||||
:mainEnd
 | 
			
		||||
if "%OS%"=="Windows_NT" endlocal
 | 
			
		||||
 | 
			
		||||
:omega
 | 
			
		||||
@ -0,0 +1,2 @@
 | 
			
		||||
 | 
			
		||||
rootProject.name = 'kotlin-bigdecimal-default-okhttp4'
 | 
			
		||||
@ -0,0 +1,119 @@
 | 
			
		||||
/**
 | 
			
		||||
 * Demo
 | 
			
		||||
 *
 | 
			
		||||
 * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
 | 
			
		||||
 *
 | 
			
		||||
 * The version of the OpenAPI document: 1.0.0
 | 
			
		||||
 * 
 | 
			
		||||
 *
 | 
			
		||||
 * Please note:
 | 
			
		||||
 * This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
 | 
			
		||||
 * Do not edit this file manually.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
@file:Suppress(
 | 
			
		||||
    "ArrayInDataClass",
 | 
			
		||||
    "EnumEntryName",
 | 
			
		||||
    "RemoveRedundantQualifierName",
 | 
			
		||||
    "UnusedImport"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
package org.openapitools.client.apis
 | 
			
		||||
 | 
			
		||||
import java.io.IOException
 | 
			
		||||
 | 
			
		||||
import org.openapitools.client.models.Apa
 | 
			
		||||
 | 
			
		||||
import com.squareup.moshi.Json
 | 
			
		||||
 | 
			
		||||
import org.openapitools.client.infrastructure.ApiClient
 | 
			
		||||
import org.openapitools.client.infrastructure.ApiResponse
 | 
			
		||||
import org.openapitools.client.infrastructure.ClientException
 | 
			
		||||
import org.openapitools.client.infrastructure.ClientError
 | 
			
		||||
import org.openapitools.client.infrastructure.ServerException
 | 
			
		||||
import org.openapitools.client.infrastructure.ServerError
 | 
			
		||||
import org.openapitools.client.infrastructure.MultiValueMap
 | 
			
		||||
import org.openapitools.client.infrastructure.PartConfig
 | 
			
		||||
import org.openapitools.client.infrastructure.RequestConfig
 | 
			
		||||
import org.openapitools.client.infrastructure.RequestMethod
 | 
			
		||||
import org.openapitools.client.infrastructure.ResponseType
 | 
			
		||||
import org.openapitools.client.infrastructure.Success
 | 
			
		||||
import org.openapitools.client.infrastructure.toMultiValue
 | 
			
		||||
 | 
			
		||||
class DefaultApi(basePath: kotlin.String = defaultBasePath) : ApiClient(basePath) {
 | 
			
		||||
    companion object {
 | 
			
		||||
        @JvmStatic
 | 
			
		||||
        val defaultBasePath: String by lazy {
 | 
			
		||||
            System.getProperties().getProperty(ApiClient.baseUrlKey, "http://localhost")
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
    * 
 | 
			
		||||
    * 
 | 
			
		||||
    * @param apa  
 | 
			
		||||
    * @return void
 | 
			
		||||
    * @throws IllegalStateException If the request is not correctly configured
 | 
			
		||||
    * @throws IOException Rethrows the OkHttp execute method exception
 | 
			
		||||
    * @throws UnsupportedOperationException If the API returns an informational or redirection response
 | 
			
		||||
    * @throws ClientException If the API returns a client error response
 | 
			
		||||
    * @throws ServerException If the API returns a server error response
 | 
			
		||||
    */
 | 
			
		||||
    @Throws(IllegalStateException::class, IOException::class, UnsupportedOperationException::class, ClientException::class, ServerException::class)
 | 
			
		||||
    fun testPost(apa: Apa) : Unit {
 | 
			
		||||
        val localVarResponse = testPostWithHttpInfo(apa = apa)
 | 
			
		||||
 | 
			
		||||
        return when (localVarResponse.responseType) {
 | 
			
		||||
            ResponseType.Success -> Unit
 | 
			
		||||
            ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.")
 | 
			
		||||
            ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.")
 | 
			
		||||
            ResponseType.ClientError -> {
 | 
			
		||||
                val localVarError = localVarResponse as ClientError<*>
 | 
			
		||||
                throw ClientException("Client error : ${localVarError.statusCode} ${localVarError.message.orEmpty()}", localVarError.statusCode, localVarResponse)
 | 
			
		||||
            }
 | 
			
		||||
            ResponseType.ServerError -> {
 | 
			
		||||
                val localVarError = localVarResponse as ServerError<*>
 | 
			
		||||
                throw ServerException("Server error : ${localVarError.statusCode} ${localVarError.message.orEmpty()}", localVarError.statusCode, localVarResponse)
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
    * 
 | 
			
		||||
    * 
 | 
			
		||||
    * @param apa  
 | 
			
		||||
    * @return ApiResponse<Unit?>
 | 
			
		||||
    * @throws IllegalStateException If the request is not correctly configured
 | 
			
		||||
    * @throws IOException Rethrows the OkHttp execute method exception
 | 
			
		||||
    */
 | 
			
		||||
    @Throws(IllegalStateException::class, IOException::class)
 | 
			
		||||
    fun testPostWithHttpInfo(apa: Apa) : ApiResponse<Unit?> {
 | 
			
		||||
        val localVariableConfig = testPostRequestConfig(apa = apa)
 | 
			
		||||
 | 
			
		||||
        return request<Apa, Unit>(
 | 
			
		||||
            localVariableConfig
 | 
			
		||||
        )
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
    * To obtain the request config of the operation testPost
 | 
			
		||||
    *
 | 
			
		||||
    * @param apa  
 | 
			
		||||
    * @return RequestConfig
 | 
			
		||||
    */
 | 
			
		||||
    fun testPostRequestConfig(apa: Apa) : RequestConfig<Apa> {
 | 
			
		||||
        val localVariableBody = apa
 | 
			
		||||
        val localVariableQuery: MultiValueMap = mutableMapOf()
 | 
			
		||||
        val localVariableHeaders: MutableMap<String, String> = mutableMapOf()
 | 
			
		||||
        localVariableHeaders["Content-Type"] = "application/json"
 | 
			
		||||
        
 | 
			
		||||
        return RequestConfig(
 | 
			
		||||
            method = RequestMethod.POST,
 | 
			
		||||
            path = "/test",
 | 
			
		||||
            query = localVariableQuery,
 | 
			
		||||
            headers = localVariableHeaders,
 | 
			
		||||
            body = localVariableBody
 | 
			
		||||
        )
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@ -0,0 +1,23 @@
 | 
			
		||||
package org.openapitools.client.infrastructure
 | 
			
		||||
 | 
			
		||||
typealias MultiValueMap = MutableMap<String,List<String>>
 | 
			
		||||
 | 
			
		||||
fun collectionDelimiter(collectionFormat: String) = when(collectionFormat) {
 | 
			
		||||
    "csv" -> ","
 | 
			
		||||
    "tsv" -> "\t"
 | 
			
		||||
    "pipe" -> "|"
 | 
			
		||||
    "space" -> " "
 | 
			
		||||
    else -> ""
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
val defaultMultiValueConverter: (item: Any?) -> String = { item -> "$item" }
 | 
			
		||||
 | 
			
		||||
fun <T : Any?> toMultiValue(items: Array<T>, collectionFormat: String, map: (item: T) -> String = defaultMultiValueConverter)
 | 
			
		||||
        = toMultiValue(items.asIterable(), collectionFormat, map)
 | 
			
		||||
 | 
			
		||||
fun <T : Any?> toMultiValue(items: Iterable<T>, collectionFormat: String, map: (item: T) -> String = defaultMultiValueConverter): List<String> {
 | 
			
		||||
    return when(collectionFormat) {
 | 
			
		||||
        "multi" -> items.map(map)
 | 
			
		||||
        else -> listOf(items.joinToString(separator = collectionDelimiter(collectionFormat), transform = map))
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@ -0,0 +1,238 @@
 | 
			
		||||
package org.openapitools.client.infrastructure
 | 
			
		||||
 | 
			
		||||
import okhttp3.OkHttpClient
 | 
			
		||||
import okhttp3.RequestBody
 | 
			
		||||
import okhttp3.RequestBody.Companion.asRequestBody
 | 
			
		||||
import okhttp3.RequestBody.Companion.toRequestBody
 | 
			
		||||
import okhttp3.FormBody
 | 
			
		||||
import okhttp3.HttpUrl.Companion.toHttpUrlOrNull
 | 
			
		||||
import okhttp3.ResponseBody
 | 
			
		||||
import okhttp3.MediaType.Companion.toMediaTypeOrNull
 | 
			
		||||
import okhttp3.Request
 | 
			
		||||
import okhttp3.Headers
 | 
			
		||||
import okhttp3.Headers.Companion.toHeaders
 | 
			
		||||
import okhttp3.MultipartBody
 | 
			
		||||
import okhttp3.Call
 | 
			
		||||
import okhttp3.Callback
 | 
			
		||||
import okhttp3.Response
 | 
			
		||||
import okhttp3.internal.EMPTY_REQUEST
 | 
			
		||||
import java.io.BufferedWriter
 | 
			
		||||
import java.io.File
 | 
			
		||||
import java.io.FileWriter
 | 
			
		||||
import java.io.IOException
 | 
			
		||||
import java.net.URLConnection
 | 
			
		||||
import java.time.LocalDate
 | 
			
		||||
import java.time.LocalDateTime
 | 
			
		||||
import java.time.LocalTime
 | 
			
		||||
import java.time.OffsetDateTime
 | 
			
		||||
import java.time.OffsetTime
 | 
			
		||||
import java.util.Locale
 | 
			
		||||
import com.squareup.moshi.adapter
 | 
			
		||||
 | 
			
		||||
open class ApiClient(val baseUrl: String) {
 | 
			
		||||
    companion object {
 | 
			
		||||
        protected const val ContentType = "Content-Type"
 | 
			
		||||
        protected const val Accept = "Accept"
 | 
			
		||||
        protected const val Authorization = "Authorization"
 | 
			
		||||
        protected const val JsonMediaType = "application/json"
 | 
			
		||||
        protected const val FormDataMediaType = "multipart/form-data"
 | 
			
		||||
        protected const val FormUrlEncMediaType = "application/x-www-form-urlencoded"
 | 
			
		||||
        protected const val XmlMediaType = "application/xml"
 | 
			
		||||
 | 
			
		||||
        val apiKey: MutableMap<String, String> = mutableMapOf()
 | 
			
		||||
        val apiKeyPrefix: MutableMap<String, String> = mutableMapOf()
 | 
			
		||||
        var username: String? = null
 | 
			
		||||
        var password: String? = null
 | 
			
		||||
        var accessToken: String? = null
 | 
			
		||||
        const val baseUrlKey = "org.openapitools.client.baseUrl"
 | 
			
		||||
 | 
			
		||||
        @JvmStatic
 | 
			
		||||
        val client: OkHttpClient by lazy {
 | 
			
		||||
            builder.build()
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        @JvmStatic
 | 
			
		||||
        val builder: OkHttpClient.Builder = OkHttpClient.Builder()
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Guess Content-Type header from the given file (defaults to "application/octet-stream").
 | 
			
		||||
     *
 | 
			
		||||
     * @param file The given file
 | 
			
		||||
     * @return The guessed Content-Type
 | 
			
		||||
     */
 | 
			
		||||
    protected fun guessContentTypeFromFile(file: File): String {
 | 
			
		||||
        val contentType = URLConnection.guessContentTypeFromName(file.name)
 | 
			
		||||
        return contentType ?: "application/octet-stream"
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    protected inline fun <reified T> requestBody(content: T, mediaType: String?): RequestBody =
 | 
			
		||||
        when {
 | 
			
		||||
            mediaType == FormDataMediaType ->
 | 
			
		||||
                MultipartBody.Builder()
 | 
			
		||||
                    .setType(MultipartBody.FORM)
 | 
			
		||||
                    .apply {
 | 
			
		||||
                        // content's type *must* be Map<String, PartConfig<*>>
 | 
			
		||||
                        @Suppress("UNCHECKED_CAST")
 | 
			
		||||
                        (content as Map<String, PartConfig<*>>).forEach { (name, part) ->
 | 
			
		||||
                            val contentType = part.headers.remove("Content-Type")
 | 
			
		||||
                            val bodies = if (part.body is Iterable<*>) part.body else listOf(part.body)
 | 
			
		||||
                            bodies.forEach { body ->
 | 
			
		||||
                                val headers = part.headers.toMutableMap() +
 | 
			
		||||
                                    ("Content-Disposition" to "form-data; name=\"$name\"" + if (body is File) "; filename=\"${body.name}\"" else "")
 | 
			
		||||
                                addPart(headers.toHeaders(),
 | 
			
		||||
                                    requestSingleBody(body, contentType))
 | 
			
		||||
                            }
 | 
			
		||||
                        }
 | 
			
		||||
                    }.build()
 | 
			
		||||
            else -> requestSingleBody(content, mediaType)
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
    protected inline fun <reified T> requestSingleBody(content: T, mediaType: String?): RequestBody =
 | 
			
		||||
        when {
 | 
			
		||||
            content is File -> content.asRequestBody((mediaType ?: guessContentTypeFromFile(content)).toMediaTypeOrNull())
 | 
			
		||||
            mediaType == FormUrlEncMediaType -> {
 | 
			
		||||
                FormBody.Builder().apply {
 | 
			
		||||
                    // content's type *must* be Map<String, PartConfig<*>>
 | 
			
		||||
                    @Suppress("UNCHECKED_CAST")
 | 
			
		||||
                    (content as Map<String, PartConfig<*>>).forEach { (name, part) ->
 | 
			
		||||
                        add(name, parameterToString(part.body))
 | 
			
		||||
                    }
 | 
			
		||||
                }.build()
 | 
			
		||||
            }
 | 
			
		||||
            mediaType == null || mediaType.startsWith("application/") && mediaType.endsWith("json") ->
 | 
			
		||||
                if (content == null) {
 | 
			
		||||
                    EMPTY_REQUEST
 | 
			
		||||
                } else {
 | 
			
		||||
                    Serializer.moshi.adapter(T::class.java).toJson(content)
 | 
			
		||||
                        .toRequestBody((mediaType ?: JsonMediaType).toMediaTypeOrNull())
 | 
			
		||||
                }
 | 
			
		||||
            mediaType == XmlMediaType -> throw UnsupportedOperationException("xml not currently supported.")
 | 
			
		||||
            // TODO: this should be extended with other serializers
 | 
			
		||||
            else -> throw UnsupportedOperationException("requestBody currently only supports JSON body and File body.")
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
    @OptIn(ExperimentalStdlibApi::class)
 | 
			
		||||
    protected inline fun <reified T: Any?> responseBody(body: ResponseBody?, mediaType: String? = JsonMediaType): T? {
 | 
			
		||||
        if(body == null) {
 | 
			
		||||
            return null
 | 
			
		||||
        }
 | 
			
		||||
        if (T::class.java == File::class.java) {
 | 
			
		||||
            // return tempfile
 | 
			
		||||
            // Attention: if you are developing an android app that supports API Level 25 and bellow, please check flag supportAndroidApiLevel25AndBelow in https://openapi-generator.tech/docs/generators/kotlin#config-options
 | 
			
		||||
            val f = java.nio.file.Files.createTempFile("tmp.org.openapitools.client", null).toFile()
 | 
			
		||||
            f.deleteOnExit()
 | 
			
		||||
            body.byteStream().use { java.nio.file.Files.copy(it, f.toPath(), java.nio.file.StandardCopyOption.REPLACE_EXISTING) }
 | 
			
		||||
            return f as T
 | 
			
		||||
        }
 | 
			
		||||
        val bodyContent = body.string()
 | 
			
		||||
        if (bodyContent.isEmpty()) {
 | 
			
		||||
            return null
 | 
			
		||||
        }
 | 
			
		||||
        return when {
 | 
			
		||||
            mediaType==null || (mediaType.startsWith("application/") && mediaType.endsWith("json")) ->
 | 
			
		||||
                Serializer.moshi.adapter<T>().fromJson(bodyContent)
 | 
			
		||||
            else ->  throw UnsupportedOperationException("responseBody currently only supports JSON body.")
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    protected inline fun <reified I, reified T: Any?> request(requestConfig: RequestConfig<I>): ApiResponse<T?> {
 | 
			
		||||
        val httpUrl = baseUrl.toHttpUrlOrNull() ?: throw IllegalStateException("baseUrl is invalid.")
 | 
			
		||||
 | 
			
		||||
        val url = httpUrl.newBuilder()
 | 
			
		||||
            .addPathSegments(requestConfig.path.trimStart('/'))
 | 
			
		||||
            .apply {
 | 
			
		||||
                requestConfig.query.forEach { query ->
 | 
			
		||||
                    query.value.forEach { queryValue ->
 | 
			
		||||
                        addQueryParameter(query.key, queryValue)
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
            }.build()
 | 
			
		||||
 | 
			
		||||
        // take content-type/accept from spec or set to default (application/json) if not defined
 | 
			
		||||
        if (requestConfig.headers[ContentType].isNullOrEmpty()) {
 | 
			
		||||
            requestConfig.headers[ContentType] = JsonMediaType
 | 
			
		||||
        }
 | 
			
		||||
        if (requestConfig.headers[Accept].isNullOrEmpty()) {
 | 
			
		||||
            requestConfig.headers[Accept] = JsonMediaType
 | 
			
		||||
        }
 | 
			
		||||
        val headers = requestConfig.headers
 | 
			
		||||
 | 
			
		||||
        if(headers[ContentType].isNullOrEmpty()) {
 | 
			
		||||
            throw kotlin.IllegalStateException("Missing Content-Type header. This is required.")
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if(headers[Accept].isNullOrEmpty()) {
 | 
			
		||||
            throw kotlin.IllegalStateException("Missing Accept header. This is required.")
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // TODO: support multiple contentType options here.
 | 
			
		||||
        val contentType = (headers[ContentType] as String).substringBefore(";").lowercase(Locale.getDefault())
 | 
			
		||||
 | 
			
		||||
        val request = when (requestConfig.method) {
 | 
			
		||||
            RequestMethod.DELETE -> Request.Builder().url(url).delete(requestBody(requestConfig.body, contentType))
 | 
			
		||||
            RequestMethod.GET -> Request.Builder().url(url)
 | 
			
		||||
            RequestMethod.HEAD -> Request.Builder().url(url).head()
 | 
			
		||||
            RequestMethod.PATCH -> Request.Builder().url(url).patch(requestBody(requestConfig.body, contentType))
 | 
			
		||||
            RequestMethod.PUT -> Request.Builder().url(url).put(requestBody(requestConfig.body, contentType))
 | 
			
		||||
            RequestMethod.POST -> Request.Builder().url(url).post(requestBody(requestConfig.body, contentType))
 | 
			
		||||
            RequestMethod.OPTIONS -> Request.Builder().url(url).method("OPTIONS", null)
 | 
			
		||||
        }.apply {
 | 
			
		||||
            headers.forEach { header -> addHeader(header.key, header.value) }
 | 
			
		||||
        }.build()
 | 
			
		||||
 | 
			
		||||
        val response = client.newCall(request).execute()
 | 
			
		||||
 | 
			
		||||
        val accept = response.header(ContentType)?.substringBefore(";")?.lowercase(Locale.getDefault())
 | 
			
		||||
 | 
			
		||||
        // TODO: handle specific mapping types. e.g. Map<int, Class<?>>
 | 
			
		||||
        return when {
 | 
			
		||||
            response.isRedirect -> Redirection(
 | 
			
		||||
                response.code,
 | 
			
		||||
                response.headers.toMultimap()
 | 
			
		||||
            )
 | 
			
		||||
            response.isInformational -> Informational(
 | 
			
		||||
                response.message,
 | 
			
		||||
                response.code,
 | 
			
		||||
                response.headers.toMultimap()
 | 
			
		||||
            )
 | 
			
		||||
            response.isSuccessful -> Success(
 | 
			
		||||
                responseBody(response.body, accept),
 | 
			
		||||
                response.code,
 | 
			
		||||
                response.headers.toMultimap()
 | 
			
		||||
            )
 | 
			
		||||
            response.isClientError -> ClientError(
 | 
			
		||||
                response.message,
 | 
			
		||||
                response.body?.string(),
 | 
			
		||||
                response.code,
 | 
			
		||||
                response.headers.toMultimap()
 | 
			
		||||
            )
 | 
			
		||||
            else -> ServerError(
 | 
			
		||||
                response.message,
 | 
			
		||||
                response.body?.string(),
 | 
			
		||||
                response.code,
 | 
			
		||||
                response.headers.toMultimap()
 | 
			
		||||
            )
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    protected fun parameterToString(value: Any?): String = when (value) {
 | 
			
		||||
        null -> ""
 | 
			
		||||
        is Array<*> -> toMultiValue(value, "csv").toString()
 | 
			
		||||
        is Iterable<*> -> toMultiValue(value, "csv").toString()
 | 
			
		||||
        is OffsetDateTime, is OffsetTime, is LocalDateTime, is LocalDate, is LocalTime ->
 | 
			
		||||
            parseDateToQueryString(value)
 | 
			
		||||
        else -> value.toString()
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    protected inline fun <reified T: Any> parseDateToQueryString(value : T): String {
 | 
			
		||||
        /*
 | 
			
		||||
        .replace("\"", "") converts the json object string to an actual string for the query parameter.
 | 
			
		||||
        The moshi or gson adapter allows a more generic solution instead of trying to use a native
 | 
			
		||||
        formatter. It also easily allows to provide a simple way to define a custom date format pattern
 | 
			
		||||
        inside a gson/moshi adapter.
 | 
			
		||||
        */
 | 
			
		||||
        return Serializer.moshi.adapter(T::class.java).toJson(value).replace("\"", "")
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@ -0,0 +1,43 @@
 | 
			
		||||
package org.openapitools.client.infrastructure
 | 
			
		||||
 | 
			
		||||
enum class ResponseType {
 | 
			
		||||
    Success, Informational, Redirection, ClientError, ServerError
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
interface Response
 | 
			
		||||
 | 
			
		||||
abstract class ApiResponse<T>(val responseType: ResponseType): Response {
 | 
			
		||||
    abstract val statusCode: Int
 | 
			
		||||
    abstract val headers: Map<String,List<String>>
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
class Success<T>(
 | 
			
		||||
    val data: T,
 | 
			
		||||
    override val statusCode: Int = -1,
 | 
			
		||||
    override val headers: Map<String, List<String>> = mapOf()
 | 
			
		||||
): ApiResponse<T>(ResponseType.Success)
 | 
			
		||||
 | 
			
		||||
class Informational<T>(
 | 
			
		||||
    val statusText: String,
 | 
			
		||||
    override val statusCode: Int = -1,
 | 
			
		||||
    override val headers: Map<String, List<String>> = mapOf()
 | 
			
		||||
) : ApiResponse<T>(ResponseType.Informational)
 | 
			
		||||
 | 
			
		||||
class Redirection<T>(
 | 
			
		||||
    override val statusCode: Int = -1,
 | 
			
		||||
    override val headers: Map<String, List<String>> = mapOf()
 | 
			
		||||
) : ApiResponse<T>(ResponseType.Redirection)
 | 
			
		||||
 | 
			
		||||
class ClientError<T>(
 | 
			
		||||
    val message: String? = null,
 | 
			
		||||
    val body: Any? = null,
 | 
			
		||||
    override val statusCode: Int = -1,
 | 
			
		||||
    override val headers: Map<String, List<String>> = mapOf()
 | 
			
		||||
) : ApiResponse<T>(ResponseType.ClientError)
 | 
			
		||||
 | 
			
		||||
class ServerError<T>(
 | 
			
		||||
    val message: String? = null,
 | 
			
		||||
    val body: Any? = null,
 | 
			
		||||
    override val statusCode: Int = -1,
 | 
			
		||||
    override val headers: Map<String, List<String>>
 | 
			
		||||
): ApiResponse<T>(ResponseType.ServerError)
 | 
			
		||||
@ -0,0 +1,17 @@
 | 
			
		||||
package org.openapitools.client.infrastructure
 | 
			
		||||
 | 
			
		||||
import com.squareup.moshi.FromJson
 | 
			
		||||
import com.squareup.moshi.ToJson
 | 
			
		||||
import java.math.BigDecimal
 | 
			
		||||
 | 
			
		||||
class BigDecimalAdapter {
 | 
			
		||||
    @ToJson
 | 
			
		||||
    fun toJson(value: BigDecimal): String {
 | 
			
		||||
        return value.toPlainString()
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @FromJson
 | 
			
		||||
    fun fromJson(value: String): BigDecimal {
 | 
			
		||||
        return BigDecimal(value)
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@ -0,0 +1,17 @@
 | 
			
		||||
package org.openapitools.client.infrastructure
 | 
			
		||||
 | 
			
		||||
import com.squareup.moshi.FromJson
 | 
			
		||||
import com.squareup.moshi.ToJson
 | 
			
		||||
import java.math.BigInteger
 | 
			
		||||
 | 
			
		||||
class BigIntegerAdapter {
 | 
			
		||||
    @ToJson
 | 
			
		||||
    fun toJson(value: BigInteger): String {
 | 
			
		||||
        return value.toString()
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @FromJson
 | 
			
		||||
    fun fromJson(value: String): BigInteger {
 | 
			
		||||
        return BigInteger(value)
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@ -0,0 +1,12 @@
 | 
			
		||||
package org.openapitools.client.infrastructure
 | 
			
		||||
 | 
			
		||||
import com.squareup.moshi.FromJson
 | 
			
		||||
import com.squareup.moshi.ToJson
 | 
			
		||||
 | 
			
		||||
class ByteArrayAdapter {
 | 
			
		||||
    @ToJson
 | 
			
		||||
    fun toJson(data: ByteArray): String = String(data)
 | 
			
		||||
 | 
			
		||||
    @FromJson
 | 
			
		||||
    fun fromJson(data: String): ByteArray = data.toByteArray()
 | 
			
		||||
}
 | 
			
		||||
@ -0,0 +1,18 @@
 | 
			
		||||
@file:Suppress("unused")
 | 
			
		||||
package org.openapitools.client.infrastructure
 | 
			
		||||
 | 
			
		||||
import java.lang.RuntimeException
 | 
			
		||||
 | 
			
		||||
open class ClientException(message: kotlin.String? = null, val statusCode: Int = -1, val response: Response? = null) : RuntimeException(message) {
 | 
			
		||||
 | 
			
		||||
    companion object {
 | 
			
		||||
        private const val serialVersionUID: Long = 123L
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
open class ServerException(message: kotlin.String? = null, val statusCode: Int = -1, val response: Response? = null) : RuntimeException(message) {
 | 
			
		||||
 | 
			
		||||
    companion object {
 | 
			
		||||
        private const val serialVersionUID: Long = 456L
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@ -0,0 +1,19 @@
 | 
			
		||||
package org.openapitools.client.infrastructure
 | 
			
		||||
 | 
			
		||||
import com.squareup.moshi.FromJson
 | 
			
		||||
import com.squareup.moshi.ToJson
 | 
			
		||||
import java.time.LocalDate
 | 
			
		||||
import java.time.format.DateTimeFormatter
 | 
			
		||||
 | 
			
		||||
class LocalDateAdapter {
 | 
			
		||||
    @ToJson
 | 
			
		||||
    fun toJson(value: LocalDate): String {
 | 
			
		||||
        return DateTimeFormatter.ISO_LOCAL_DATE.format(value)
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @FromJson
 | 
			
		||||
    fun fromJson(value: String): LocalDate {
 | 
			
		||||
        return LocalDate.parse(value, DateTimeFormatter.ISO_LOCAL_DATE)
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@ -0,0 +1,19 @@
 | 
			
		||||
package org.openapitools.client.infrastructure
 | 
			
		||||
 | 
			
		||||
import com.squareup.moshi.FromJson
 | 
			
		||||
import com.squareup.moshi.ToJson
 | 
			
		||||
import java.time.LocalDateTime
 | 
			
		||||
import java.time.format.DateTimeFormatter
 | 
			
		||||
 | 
			
		||||
class LocalDateTimeAdapter {
 | 
			
		||||
    @ToJson
 | 
			
		||||
    fun toJson(value: LocalDateTime): String {
 | 
			
		||||
        return DateTimeFormatter.ISO_LOCAL_DATE_TIME.format(value)
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @FromJson
 | 
			
		||||
    fun fromJson(value: String): LocalDateTime {
 | 
			
		||||
        return LocalDateTime.parse(value, DateTimeFormatter.ISO_LOCAL_DATE_TIME)
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@ -0,0 +1,19 @@
 | 
			
		||||
package org.openapitools.client.infrastructure
 | 
			
		||||
 | 
			
		||||
import com.squareup.moshi.FromJson
 | 
			
		||||
import com.squareup.moshi.ToJson
 | 
			
		||||
import java.time.OffsetDateTime
 | 
			
		||||
import java.time.format.DateTimeFormatter
 | 
			
		||||
 | 
			
		||||
class OffsetDateTimeAdapter {
 | 
			
		||||
    @ToJson
 | 
			
		||||
    fun toJson(value: OffsetDateTime): String {
 | 
			
		||||
        return DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(value)
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @FromJson
 | 
			
		||||
    fun fromJson(value: String): OffsetDateTime {
 | 
			
		||||
        return OffsetDateTime.parse(value, DateTimeFormatter.ISO_OFFSET_DATE_TIME)
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@ -0,0 +1,11 @@
 | 
			
		||||
package org.openapitools.client.infrastructure
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Defines a config object for a given part of a multi-part request.
 | 
			
		||||
 * NOTE: Headers is a Map<String,String> because rfc2616 defines
 | 
			
		||||
 *       multi-valued headers as csv-only.
 | 
			
		||||
 */
 | 
			
		||||
data class PartConfig<T>(
 | 
			
		||||
    val headers: MutableMap<String, String> = mutableMapOf(),
 | 
			
		||||
    val body: T? = null
 | 
			
		||||
)
 | 
			
		||||
@ -0,0 +1,17 @@
 | 
			
		||||
package org.openapitools.client.infrastructure
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Defines a config object for a given request.
 | 
			
		||||
 * NOTE: This object doesn't include 'body' because it
 | 
			
		||||
 *       allows for caching of the constructed object
 | 
			
		||||
 *       for many request definitions.
 | 
			
		||||
 * NOTE: Headers is a Map<String,String> because rfc2616 defines
 | 
			
		||||
 *       multi-valued headers as csv-only.
 | 
			
		||||
 */
 | 
			
		||||
data class RequestConfig<T>(
 | 
			
		||||
    val method: RequestMethod,
 | 
			
		||||
    val path: String,
 | 
			
		||||
    val headers: MutableMap<String, String> = mutableMapOf(),
 | 
			
		||||
    val query: MutableMap<String, List<String>> = mutableMapOf(),
 | 
			
		||||
    val body: T? = null
 | 
			
		||||
)
 | 
			
		||||
@ -0,0 +1,8 @@
 | 
			
		||||
package org.openapitools.client.infrastructure
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Provides enumerated HTTP verbs
 | 
			
		||||
 */
 | 
			
		||||
enum class RequestMethod {
 | 
			
		||||
    GET, DELETE, HEAD, OPTIONS, PATCH, POST, PUT
 | 
			
		||||
}
 | 
			
		||||
@ -0,0 +1,24 @@
 | 
			
		||||
package org.openapitools.client.infrastructure
 | 
			
		||||
 | 
			
		||||
import okhttp3.Response
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Provides an extension to evaluation whether the response is a 1xx code
 | 
			
		||||
 */
 | 
			
		||||
val Response.isInformational : Boolean get() = this.code in 100..199
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Provides an extension to evaluation whether the response is a 3xx code
 | 
			
		||||
 */
 | 
			
		||||
@Suppress("EXTENSION_SHADOWED_BY_MEMBER")
 | 
			
		||||
val Response.isRedirect : Boolean get() = this.code in 300..399
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Provides an extension to evaluation whether the response is a 4xx code
 | 
			
		||||
 */
 | 
			
		||||
val Response.isClientError : Boolean get() = this.code in 400..499
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Provides an extension to evaluation whether the response is a 5xx (Standard) through 999 (non-standard) code
 | 
			
		||||
 */
 | 
			
		||||
val Response.isServerError : Boolean get() = this.code in 500..999
 | 
			
		||||
@ -0,0 +1,23 @@
 | 
			
		||||
package org.openapitools.client.infrastructure
 | 
			
		||||
 | 
			
		||||
import com.squareup.moshi.Moshi
 | 
			
		||||
import com.squareup.moshi.kotlin.reflect.KotlinJsonAdapterFactory
 | 
			
		||||
 | 
			
		||||
object Serializer {
 | 
			
		||||
    @JvmStatic
 | 
			
		||||
    val moshiBuilder: Moshi.Builder = Moshi.Builder()
 | 
			
		||||
        .add(OffsetDateTimeAdapter())
 | 
			
		||||
        .add(LocalDateTimeAdapter())
 | 
			
		||||
        .add(LocalDateAdapter())
 | 
			
		||||
        .add(UUIDAdapter())
 | 
			
		||||
        .add(ByteArrayAdapter())
 | 
			
		||||
        .add(URIAdapter())
 | 
			
		||||
        .add(KotlinJsonAdapterFactory())
 | 
			
		||||
        .add(BigDecimalAdapter())
 | 
			
		||||
        .add(BigIntegerAdapter())
 | 
			
		||||
 | 
			
		||||
    @JvmStatic
 | 
			
		||||
    val moshi: Moshi by lazy {
 | 
			
		||||
        moshiBuilder.build()
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@ -0,0 +1,13 @@
 | 
			
		||||
package org.openapitools.client.infrastructure
 | 
			
		||||
 | 
			
		||||
import com.squareup.moshi.FromJson
 | 
			
		||||
import com.squareup.moshi.ToJson
 | 
			
		||||
import java.net.URI
 | 
			
		||||
 | 
			
		||||
class URIAdapter {
 | 
			
		||||
    @ToJson
 | 
			
		||||
    fun toJson(uri: URI) = uri.toString()
 | 
			
		||||
 | 
			
		||||
    @FromJson
 | 
			
		||||
    fun fromJson(s: String): URI = URI.create(s)
 | 
			
		||||
}
 | 
			
		||||
@ -0,0 +1,13 @@
 | 
			
		||||
package org.openapitools.client.infrastructure
 | 
			
		||||
 | 
			
		||||
import com.squareup.moshi.FromJson
 | 
			
		||||
import com.squareup.moshi.ToJson
 | 
			
		||||
import java.util.UUID
 | 
			
		||||
 | 
			
		||||
class UUIDAdapter {
 | 
			
		||||
    @ToJson
 | 
			
		||||
    fun toJson(uuid: UUID) = uuid.toString()
 | 
			
		||||
 | 
			
		||||
    @FromJson
 | 
			
		||||
    fun fromJson(s: String): UUID = UUID.fromString(s)
 | 
			
		||||
}
 | 
			
		||||
@ -0,0 +1,59 @@
 | 
			
		||||
/**
 | 
			
		||||
 * Demo
 | 
			
		||||
 *
 | 
			
		||||
 * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
 | 
			
		||||
 *
 | 
			
		||||
 * The version of the OpenAPI document: 1.0.0
 | 
			
		||||
 * 
 | 
			
		||||
 *
 | 
			
		||||
 * Please note:
 | 
			
		||||
 * This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
 | 
			
		||||
 * Do not edit this file manually.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
@file:Suppress(
 | 
			
		||||
    "ArrayInDataClass",
 | 
			
		||||
    "EnumEntryName",
 | 
			
		||||
    "RemoveRedundantQualifierName",
 | 
			
		||||
    "UnusedImport"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
package org.openapitools.client.models
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
import com.squareup.moshi.Json
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * 
 | 
			
		||||
 *
 | 
			
		||||
 * @param bepa 
 | 
			
		||||
 * @param cepa 
 | 
			
		||||
 * @param depa 
 | 
			
		||||
 * @param epa 
 | 
			
		||||
 * @param fepa 
 | 
			
		||||
 * @param gepa 
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
data class Apa (
 | 
			
		||||
 | 
			
		||||
    @Json(name = "bepa")
 | 
			
		||||
    val bepa: java.math.BigDecimal = java.math.BigDecimal("0"),
 | 
			
		||||
 | 
			
		||||
    @Json(name = "cepa")
 | 
			
		||||
    val cepa: java.math.BigDecimal = java.math.BigDecimal("6.28318"),
 | 
			
		||||
 | 
			
		||||
    @Json(name = "depa")
 | 
			
		||||
    val depa: java.math.BigDecimal? = java.math.BigDecimal("71"),
 | 
			
		||||
 | 
			
		||||
    @Json(name = "epa")
 | 
			
		||||
    val epa: java.math.BigDecimal? = java.math.BigDecimal("-71"),
 | 
			
		||||
 | 
			
		||||
    @Json(name = "fepa")
 | 
			
		||||
    @Deprecated(message = "This property is deprecated.")
 | 
			
		||||
    val fepa: java.math.BigDecimal? = java.math.BigDecimal("100"),
 | 
			
		||||
 | 
			
		||||
    @Json(name = "gepa")
 | 
			
		||||
    val gepa: java.math.BigDecimal? = null
 | 
			
		||||
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user