Kotlin multiplatform client (#3900)

* Includes Kotlin multiplatform client

Kotlin multiplatform allows Kotlin code to be shared across various target platforms.
This implementation generates Swagger clients for JVM and iOS platforms.

* Includes Kotlin Multiplatform sample scripts

* Updates existing Kotlin samples

* Includes Kotlin Multiplatform samples

* Fixes incorrect Windows sample resource location

* Updates Kotlin client documentation

* Removes unnecessary workaround to remove duplicate entries

* Includes additional multiplatform type and import mappings

* Fixes Kotlin client definitions with multiple enums

https://github.com/OpenAPITools/openapi-generator/issues/3917

* Updates Kotlin samples
This commit is contained in:
Andrew Emery 2019-09-21 23:48:41 +10:00 committed by William Cheng
parent 0ea1ead59e
commit 21e0e0d5d5
223 changed files with 11192 additions and 58 deletions

View File

@ -0,0 +1,32 @@
#!/bin/sh
SCRIPT="$0"
echo "# START SCRIPT: $SCRIPT"
while [ -h "$SCRIPT" ] ; do
ls=$(ls -ld "$SCRIPT")
link=$(expr "$ls" : '.*-> \(.*\)$')
if expr "$link" : '/.*' > /dev/null; then
SCRIPT="$link"
else
SCRIPT=$(dirname "$SCRIPT")/"$link"
fi
done
if [ ! -d "${APP_DIR}" ]; then
APP_DIR=$(dirname "$SCRIPT")/..
APP_DIR=$(cd "${APP_DIR}"; pwd)
fi
executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar"
if [ ! -f "$executable" ]
then
mvn -B clean package
fi
# if you've executed sbt assembly previously it will use that instead.
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
ags="generate -t modules/openapi-generator/src/main/resources/kotlin-client -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g kotlin --artifact-id kotlin-client-petstore-multiplatform --library multiplatform -o samples/client/petstore/kotlin-multiplatform $@"
java ${JAVA_OPTS} -jar ${executable} ${ags}

View File

@ -0,0 +1,35 @@
#!/bin/sh
SCRIPT="$0"
echo "# START SCRIPT: $SCRIPT"
while [ -h "$SCRIPT" ] ; do
ls=$(ls -ld "$SCRIPT")
link=$(expr "$ls" : '.*-> \(.*\)$')
if expr "$link" : '/.*' > /dev/null; then
SCRIPT="$link"
else
SCRIPT=$(dirname "$SCRIPT")/"$link"
fi
done
if [ ! -d "${APP_DIR}" ]; then
APP_DIR=$(dirname "$SCRIPT")/..
APP_DIR=$(cd "${APP_DIR}"; pwd)
fi
executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar"
if [ ! -f "$executable" ]
then
mvn clean package
fi
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
ags="generate -i modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml -t modules/openapi-generator/src/main/resources/kotlin-client -g kotlin --artifact-id kotlin-client-petstore-multiplatform --library multiplatform -o samples/openapi3/client/petstore/kotlin-multiplatform $@"
echo "Cleaning previously generated files if any from samples/openapi3/client/petstore/kotlin-multiplatform"
rm -rf samples/openapi3/client/petstore/kotlin-multiplatform
echo "Generating Kotling client..."
java $JAVA_OPTS -jar $executable $ags

View File

@ -0,0 +1,10 @@
set executable=.\modules\openapi-generator-cli\target\openapi-generator-cli.jar
If Not Exist %executable% (
mvn clean package
)
REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M -DloggerPath=conf/log4j.properties
set ags=generate --artifact-id "kotlin-client-petstore-multiplatform" -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -g kotlin --library multiplatform -o samples\client\petstore\kotlin-multiplatform
java %JAVA_OPTS% -jar %executable% %ags%

View File

@ -16,5 +16,6 @@ sidebar_label: kotlin
|enumPropertyNaming|Naming convention for enum properties: 'camelCase', 'PascalCase', 'snake_case', 'UPPERCASE', and 'original'| |camelCase|
|serializationLibrary|What serialization library to use: 'moshi' (default), or 'gson'| |moshi|
|parcelizeModels|toggle "@Parcelize" for generated models| |null|
|dateLibrary|Option. Date library to use|<dl><dt>**string**</dt><dd>String</dd><dt>**java8**</dt><dd>Java 8 native JSR310</dd><dt>**threetenbp**</dt><dd>Threetenbp</dd><dl>|java8|
|dateLibrary|Option. Date library to use|<dl><dt>**string**</dt><dd>String</dd><dt>**java8**</dt><dd>Java 8 native JSR310 (jvm only)</dd><dt>**threetenbp**</dt><dd>Threetenbp (jvm only)</dd><dl>|java8|
|collectionType|Option. Collection type to use|<dl><dt>**array**</dt><dd>kotlin.Array</dd><dt>**list**</dt><dd>kotlin.collections.List</dd><dl>|array|
|library|Library template (sub-template) to use|<dl><dt>**jvm**</dt><dd>Platform: Java Virtual Machine. HTTP client: OkHttp 2.7.5. JSON processing: Gson 2.8.1.</dd><dt>**multiplatform**</dt><dd>Platform: Kotlin multiplatform. HTTP client: Ktor 1.2.4. JSON processing: Kotlinx Serialization: 0.12.0.</dd><dl>|jvm|

View File

@ -19,21 +19,42 @@ package org.openapitools.codegen.languages;
import org.openapitools.codegen.CliOption;
import org.openapitools.codegen.CodegenConstants;
import org.openapitools.codegen.CodegenModel;
import org.openapitools.codegen.CodegenOperation;
import org.openapitools.codegen.CodegenProperty;
import org.openapitools.codegen.CodegenType;
import org.openapitools.codegen.SupportingFile;
import java.io.File;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.regex.Pattern;
public class KotlinClientCodegen extends AbstractKotlinCodegen {
protected static final String VENDOR_EXTENSION_ESCAPED_NAME = "x-escapedName";
protected static final String JVM = "jvm";
protected static final String MULTIPLATFORM = "multiplatform";
public static final String DATE_LIBRARY = "dateLibrary";
public static final String COLLECTION_TYPE = "collectionType";
protected String dateLibrary = DateLibrary.JAVA8.value;
protected String collectionType = CollectionType.ARRAY.value;
// https://kotlinlang.org/docs/reference/grammar.html#Identifier
protected static final Pattern IDENTIFIER_PATTERN =
Pattern.compile("[\\p{Ll}\\p{Lm}\\p{Lo}\\p{Lt}\\p{Lu}\\p{Nl}_][\\p{Ll}\\p{Lm}\\p{Lo}\\p{Lt}\\p{Lu}\\p{Nl}\\p{Nd}_]*");
// https://kotlinlang.org/docs/reference/grammar.html#Identifier
protected static final String IDENTIFIER_REPLACEMENTS =
"[.;:/\\[\\]<>]";
public enum DateLibrary {
STRING("string"),
THREETENBP("threetenbp"),
@ -81,9 +102,9 @@ public class KotlinClientCodegen extends AbstractKotlinCodegen {
CliOption dateLibrary = new CliOption(DATE_LIBRARY, "Option. Date library to use");
Map<String, String> dateOptions = new HashMap<>();
dateOptions.put(DateLibrary.THREETENBP.value, "Threetenbp");
dateOptions.put(DateLibrary.THREETENBP.value, "Threetenbp (jvm only)");
dateOptions.put(DateLibrary.STRING.value, "String");
dateOptions.put(DateLibrary.JAVA8.value, "Java 8 native JSR310");
dateOptions.put(DateLibrary.JAVA8.value, "Java 8 native JSR310 (jvm only)");
dateLibrary.setEnum(dateOptions);
dateLibrary.setDefault(this.dateLibrary);
cliOptions.add(dateLibrary);
@ -95,6 +116,15 @@ public class KotlinClientCodegen extends AbstractKotlinCodegen {
collectionType.setEnum(collectionOptions);
collectionType.setDefault(this.collectionType);
cliOptions.add(collectionType);
supportedLibraries.put(JVM, "Platform: Java Virtual Machine. HTTP client: OkHttp 2.7.5. JSON processing: Gson 2.8.1.");
supportedLibraries.put(MULTIPLATFORM, "Platform: Kotlin multiplatform. HTTP client: Ktor 1.2.4. JSON processing: Kotlinx Serialization: 0.12.0.");
CliOption libraryOption = new CliOption(CodegenConstants.LIBRARY, "Library template (sub-template) to use");
libraryOption.setEnum(supportedLibraries);
libraryOption.setDefault(JVM);
cliOptions.add(libraryOption);
setLibrary(JVM);
}
public CodegenType getTag() {
@ -121,10 +151,80 @@ public class KotlinClientCodegen extends AbstractKotlinCodegen {
public void processOpts() {
super.processOpts();
if (MULTIPLATFORM.equals(getLibrary())) {
sourceFolder = "src/commonMain/kotlin";
}
// infrastructure destination folder
final String infrastructureFolder = (sourceFolder + File.separator + packageName + File.separator + "infrastructure").replace(".", "/");
// additional properties
if (additionalProperties.containsKey(DATE_LIBRARY)) {
setDateLibrary(additionalProperties.get(DATE_LIBRARY).toString());
}
// common (jvm/multiplatform) supporting files
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
supportingFiles.add(new SupportingFile("build.gradle.mustache", "", "build.gradle"));
supportingFiles.add(new SupportingFile("settings.gradle.mustache", "", "settings.gradle"));
supportingFiles.add(new SupportingFile("infrastructure/ApiClient.kt.mustache", infrastructureFolder, "ApiClient.kt"));
supportingFiles.add(new SupportingFile("infrastructure/ApiAbstractions.kt.mustache", infrastructureFolder, "ApiAbstractions.kt"));
supportingFiles.add(new SupportingFile("infrastructure/RequestConfig.kt.mustache", infrastructureFolder, "RequestConfig.kt"));
supportingFiles.add(new SupportingFile("infrastructure/RequestMethod.kt.mustache", infrastructureFolder, "RequestMethod.kt"));
if (JVM.equals(getLibrary())) {
additionalProperties.put(JVM, true);
// jvm specific supporting files
supportingFiles.add(new SupportingFile("infrastructure/ApplicationDelegates.kt.mustache", infrastructureFolder, "ApplicationDelegates.kt"));
supportingFiles.add(new SupportingFile("infrastructure/Errors.kt.mustache", infrastructureFolder, "Errors.kt"));
supportingFiles.add(new SupportingFile("infrastructure/ResponseExtensions.kt.mustache", infrastructureFolder, "ResponseExtensions.kt"));
supportingFiles.add(new SupportingFile("infrastructure/Serializer.kt.mustache", infrastructureFolder, "Serializer.kt"));
supportingFiles.add(new SupportingFile("infrastructure/ApiInfrastructureResponse.kt.mustache", infrastructureFolder, "ApiInfrastructureResponse.kt"));
supportingFiles.add(new SupportingFile("infrastructure/ByteArrayAdapter.kt.mustache", infrastructureFolder, "ByteArrayAdapter.kt"));
supportingFiles.add(new SupportingFile("infrastructure/LocalDateAdapter.kt.mustache", infrastructureFolder, "LocalDateAdapter.kt"));
supportingFiles.add(new SupportingFile("infrastructure/LocalDateTimeAdapter.kt.mustache", infrastructureFolder, "LocalDateTimeAdapter.kt"));
supportingFiles.add(new SupportingFile("infrastructure/UUIDAdapter.kt.mustache", infrastructureFolder, "UUIDAdapter.kt"));
} else if (MULTIPLATFORM.equals(getLibrary())) {
additionalProperties.put(MULTIPLATFORM, true);
setDateLibrary(DateLibrary.STRING.value);
// multiplatform default includes
defaultIncludes.add("io.ktor.client.request.forms.InputProvider");
// multiplatform type mapping
typeMapping.put("number", "kotlin.Double");
typeMapping.put("file", "InputProvider");
// multiplatform import mapping
importMapping.put("BigDecimal", "kotlin.Double");
importMapping.put("UUID", "kotlin.String");
importMapping.put("URI", "kotlin.String");
importMapping.put("InputProvider", "io.ktor.client.request.forms.InputProvider");
importMapping.put("File", "io.ktor.client.request.forms.InputProvider");
importMapping.put("Timestamp", "kotlin.String");
importMapping.put("LocalDateTime", "kotlin.String");
importMapping.put("LocalDate", "kotlin.String");
importMapping.put("LocalTime", "kotlin.String");
// multiplatform specific supporting files
supportingFiles.add(new SupportingFile("infrastructure/HttpResponse.kt.mustache", infrastructureFolder, "HttpResponse.kt"));
// multiplatform specific testing files
final String testFolder = (sourceFolder + File.separator + packageName + File.separator + "infrastructure").replace(".", "/");
supportingFiles.add(new SupportingFile("commonTest/coroutine.mustache", "src/commonTest/kotlin/util", "Coroutine.kt"));
supportingFiles.add(new SupportingFile("iosTest/coroutine.mustache", "src/iosTest/kotlin/util", "Coroutine.kt"));
supportingFiles.add(new SupportingFile("jvmTest/coroutine.mustache", "src/jvmTest/kotlin/util", "Coroutine.kt"));
// gradle wrapper supporting files
supportingFiles.add(new SupportingFile("gradlew.mustache", "", "gradlew"));
supportingFiles.add(new SupportingFile("gradlew.bat.mustache", "", "gradlew.bat"));
supportingFiles.add(new SupportingFile("gradle-wrapper.properties.mustache", "gradle.wrapper".replace(".", File.separator), "gradle-wrapper.properties"));
supportingFiles.add(new SupportingFile("gradle-wrapper.jar", "gradle.wrapper".replace(".", File.separator), "gradle-wrapper.jar"));
}
// date library processing
if (DateLibrary.THREETENBP.value.equals(dateLibrary)) {
additionalProperties.put(DateLibrary.THREETENBP.value, true);
typeMapping.put("date", "LocalDate");
@ -151,25 +251,83 @@ public class KotlinClientCodegen extends AbstractKotlinCodegen {
typeMapping.put("list", "kotlin.collections.List");
additionalProperties.put("isList", true);
}
}
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
supportingFiles.add(new SupportingFile("build.gradle.mustache", "", "build.gradle"));
supportingFiles.add(new SupportingFile("settings.gradle.mustache", "", "settings.gradle"));
@Override
public Map<String, Object> postProcessModels(Map<String, Object> objs) {
objs = super.postProcessModels(objs);
return postProcessModelsEscapeNames(objs);
}
final String infrastructureFolder = (sourceFolder + File.separator + packageName + File.separator + "infrastructure").replace(".", "/");
@SuppressWarnings("unchecked")
private static Map<String, Object> postProcessModelsEscapeNames(Map<String, Object> objs) {
List<Object> models = (List<Object>) objs.get("models");
for (Object _mo : models) {
Map<String, Object> mo = (Map<String, Object>) _mo;
CodegenModel cm = (CodegenModel) mo.get("model");
supportingFiles.add(new SupportingFile("infrastructure/ApiClient.kt.mustache", infrastructureFolder, "ApiClient.kt"));
supportingFiles.add(new SupportingFile("infrastructure/ApiAbstractions.kt.mustache", infrastructureFolder, "ApiAbstractions.kt"));
supportingFiles.add(new SupportingFile("infrastructure/ApiInfrastructureResponse.kt.mustache", infrastructureFolder, "ApiInfrastructureResponse.kt"));
supportingFiles.add(new SupportingFile("infrastructure/ApplicationDelegates.kt.mustache", infrastructureFolder, "ApplicationDelegates.kt"));
supportingFiles.add(new SupportingFile("infrastructure/RequestConfig.kt.mustache", infrastructureFolder, "RequestConfig.kt"));
supportingFiles.add(new SupportingFile("infrastructure/RequestMethod.kt.mustache", infrastructureFolder, "RequestMethod.kt"));
supportingFiles.add(new SupportingFile("infrastructure/ResponseExtensions.kt.mustache", infrastructureFolder, "ResponseExtensions.kt"));
supportingFiles.add(new SupportingFile("infrastructure/Serializer.kt.mustache", infrastructureFolder, "Serializer.kt"));
supportingFiles.add(new SupportingFile("infrastructure/Errors.kt.mustache", infrastructureFolder, "Errors.kt"));
supportingFiles.add(new SupportingFile("infrastructure/ByteArrayAdapter.kt.mustache", infrastructureFolder, "ByteArrayAdapter.kt"));
supportingFiles.add(new SupportingFile("infrastructure/LocalDateAdapter.kt.mustache", infrastructureFolder, "LocalDateAdapter.kt"));
supportingFiles.add(new SupportingFile("infrastructure/LocalDateTimeAdapter.kt.mustache", infrastructureFolder, "LocalDateTimeAdapter.kt"));
supportingFiles.add(new SupportingFile("infrastructure/UUIDAdapter.kt.mustache", infrastructureFolder, "UUIDAdapter.kt"));
if (cm.vars != null) {
for (CodegenProperty var : cm.vars) {
var.vendorExtensions.put(VENDOR_EXTENSION_ESCAPED_NAME, escapeIdentifier(var.name));
}
}
if (cm.requiredVars != null) {
for (CodegenProperty var : cm.requiredVars) {
var.vendorExtensions.put(VENDOR_EXTENSION_ESCAPED_NAME, escapeIdentifier(var.name));
}
}
if (cm.optionalVars != null) {
for (CodegenProperty var : cm.optionalVars) {
var.vendorExtensions.put(VENDOR_EXTENSION_ESCAPED_NAME, escapeIdentifier(var.name));
}
}
}
return objs;
}
private static String escapeIdentifier(String identifier) {
// the kotlin grammar permits a wider set of characters in their identifiers that all target
// platforms permit (namely jvm). in order to remain compatible with target platforms, we
// initially replace all illegal target characters before escaping the identifier if required.
identifier = identifier.replaceAll(IDENTIFIER_REPLACEMENTS, "_");
if (IDENTIFIER_PATTERN.matcher(identifier).matches()) return identifier;
return '`' + identifier + '`';
}
private static void removeDuplicates(List<CodegenProperty> list) {
Set<String> set = new HashSet<>();
Iterator<CodegenProperty> iterator = list.iterator();
while (iterator.hasNext()) {
CodegenProperty item = iterator.next();
if (set.contains(item.name)) iterator.remove();
else set.add(item.name);
}
}
@Override
@SuppressWarnings("unchecked")
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<Object> allModels) {
super.postProcessOperationsWithModels(objs, allModels);
Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
if (operations != null) {
List<CodegenOperation> ops = (List<CodegenOperation>) operations.get("operation");
for (CodegenOperation operation : ops) {
if (operation.hasConsumes == Boolean.TRUE) {
if (isMultipartType(operation.consumes)) {
operation.isMultipart = Boolean.TRUE;
}
}
}
}
return operations;
}
private static boolean isMultipartType(List<Map<String, String>> consumes) {
Map<String, String> firstType = consumes.get(0);
if (firstType != null) {
return "multipart/form-data".equals(firstType.get("mediaType"));
}
return false;
}
}

View File

@ -2,11 +2,17 @@
## Requires
{{#jvm}}
* Kotlin 1.3.41
* Gradle 4.9
{{/jvm}}
{{#multiplatform}}
* Kotlin 1.3.50
{{/multiplatform}}
## Build
{{#jvm}}
First, create the gradle wrapper script:
```
@ -15,6 +21,7 @@ gradle wrapper
Then, run:
{{/jvm}}
```
./gradlew check assemble
```
@ -26,7 +33,7 @@ This runs all tests and packages the library.
* 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.
{{#jvm}}* Implementation of ApiClient is intended to reduce method counts, specifically to benefit Android targets.{{/jvm}}
{{#generateApiDocs}}
<a name="documentation-for-api-endpoints"></a>

View File

@ -1,3 +1,4 @@
{{#jvm}}
{{#gson}}
import com.google.gson.annotations.SerializedName
{{/gson}}
@ -9,15 +10,21 @@ import android.os.Parcelable
import kotlinx.android.parcel.Parcelize
{{/parcelizeModels}}
{{/jvm}}
{{#multiplatform}}
import kotlinx.serialization.*
import kotlinx.serialization.internal.CommonEnumSerializer
{{/multiplatform}}
/**
* {{{description}}}
{{#vars}}
* @param {{name}} {{{description}}}
* @param {{{vendorExtensions.x-escapedName}}} {{{description}}}
{{/vars}}
*/
{{#parcelizeModels}}
@Parcelize
{{/parcelizeModels}}
{{#multiplatform}}@Serializable{{/multiplatform}}
data class {{classname}} (
{{#requiredVars}}
{{>data_class_req_var}}{{^-last}},
@ -25,21 +32,33 @@ data class {{classname}} (
{{/hasOptional}}{{/hasRequired}}{{#optionalVars}}{{>data_class_opt_var}}{{^-last}},
{{/-last}}{{/optionalVars}}
){{#parcelizeModels}} : Parcelable{{/parcelizeModels}}
{{#hasEnums}}{{#vars}}{{#isEnum}}
{{#hasEnums}}
{
{{#vars}}{{#isEnum}}
/**
* {{{description}}}
* Values: {{#allowableValues}}{{#enumVars}}{{&name}}{{^-last}},{{/-last}}{{/enumVars}}{{/allowableValues}}
*/
{{#multiplatform}}@Serializable(with = {{nameInCamelCase}}.Serializer::class){{/multiplatform}}
enum class {{{nameInCamelCase}}}(val value: {{#isListContainer}}{{{ nestedType }}}{{/isListContainer}}{{^isListContainer}}{{{dataType}}}{{/isListContainer}}){
{{#allowableValues}}{{#enumVars}}
{{#jvm}}
{{#moshi}}
@Json(name = {{{value}}}) {{&name}}({{{value}}}){{^-last}},{{/-last}}{{#-last}};{{/-last}}
{{/moshi}}
{{#gson}}
@SerializedName(value={{{value}}}) {{&name}}({{{value}}}){{^-last}},{{/-last}}{{#-last}};{{/-last}}
{{/gson}}
{{/jvm}}
{{#multiplatform}}
{{&name}}({{{value}}}){{^-last}},{{/-last}}{{#-last}};{{/-last}}
{{/multiplatform}}
{{/enumVars}}{{/allowableValues}}
{{#multiplatform}}
object Serializer : CommonEnumSerializer<{{nameInCamelCase}}>("{{nameInCamelCase}}", values(), values().map { it.value }.toTypedArray())
{{/multiplatform}}
}
{{/isEnum}}{{/vars}}
}
{{/isEnum}}{{/vars}}{{/hasEnums}}
{{/hasEnums}}

View File

@ -1,10 +1,12 @@
{{#description}}
/* {{{description}}} */
{{/description}}
{{#jvm}}
{{#moshi}}
@Json(name = "{{{baseName}}}")
{{/moshi}}
{{#gson}}
@SerializedName("{{name}}")
{{/gson}}
val {{{name}}}: {{#isEnum}}{{#isListContainer}}{{#isList}}kotlin.collections.List{{/isList}}{{^isList}}kotlin.Array{{/isList}}<{{classname}}.{{{nameInCamelCase}}}>{{/isListContainer}}{{^isListContainer}}{{classname}}.{{{nameInCamelCase}}}{{/isListContainer}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{/isEnum}}? = {{#defaultvalue}}{{defaultvalue}}{{/defaultvalue}}{{^defaultvalue}}null{{/defaultvalue}}
{{/jvm}}
{{#multiplatform}}@SerialName(value = "{{name}}") {{/multiplatform}}val {{{vendorExtensions.x-escapedName}}}: {{#isEnum}}{{#isListContainer}}{{#isList}}kotlin.collections.List{{/isList}}{{^isList}}kotlin.Array{{/isList}}<{{classname}}.{{{nameInCamelCase}}}>{{/isListContainer}}{{^isListContainer}}{{classname}}.{{{nameInCamelCase}}}{{/isListContainer}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{/isEnum}}? = {{#defaultvalue}}{{defaultvalue}}{{/defaultvalue}}{{^defaultvalue}}null{{/defaultvalue}}

View File

@ -1,10 +1,12 @@
{{#description}}
/* {{{description}}} */
{{/description}}
{{#jvm}}
{{#moshi}}
@Json(name = "{{{baseName}}}")
{{/moshi}}
{{#gson}}
@SerializedName("{{name}}")
{{/gson}}
val {{{name}}}: {{#isEnum}}{{#isListContainer}}{{#isList}}kotlin.collections.List{{/isList}}{{^isList}}kotlin.Array{{/isList}}<{{classname}}.{{{nameInCamelCase}}}>{{/isListContainer}}{{^isListContainer}}{{classname}}.{{{nameInCamelCase}}}{{/isListContainer}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{/isEnum}}
{{/jvm}}
{{#multiplatform}}@SerialName(value = "{{name}}") @Required {{/multiplatform}}val {{{vendorExtensions.x-escapedName}}}: {{#isEnum}}{{#isListContainer}}{{#isList}}kotlin.collections.List{{/isList}}{{^isList}}kotlin.Array{{/isList}}<{{classname}}.{{{nameInCamelCase}}}>{{/isListContainer}}{{^isListContainer}}{{classname}}.{{{nameInCamelCase}}}{{/isListContainer}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{/isEnum}}

View File

@ -1,23 +1,32 @@
{{#jvm}}
{{#gson}}
import com.google.gson.annotations.SerializedName
{{/gson}}
{{#moshi}}
import com.squareup.moshi.Json
{{/moshi}}
{{/jvm}}
{{#multiplatform}}
import kotlinx.serialization.*
import kotlinx.serialization.internal.CommonEnumSerializer
{{/multiplatform}}
/**
* {{{description}}}
* Values: {{#allowableValues}}{{#enumVars}}{{&name}}{{^-last}},{{/-last}}{{/enumVars}}{{/allowableValues}}
*/
{{#multiplatform}}@Serializable(with = {{classname}}.Serializer::class){{/multiplatform}}
enum class {{classname}}(val value: {{{dataType}}}){
{{#allowableValues}}{{#enumVars}}
{{#jvm}}
{{#moshi}}
@Json(name = {{^isString}}"{{/isString}}{{{value}}}{{^isString}}"{{/isString}})
{{/moshi}}
{{#gson}}
@SerializedName(value = {{^isString}}"{{/isString}}{{{value}}}{{^isString}}"{{/isString}})
{{/gson}}
{{/jvm}}
{{#isListContainer}}
{{#isList}}
{{&name}}(listOf({{{value}}})){{^-last}},{{/-last}}{{#-last}};{{/-last}}
@ -31,4 +40,8 @@ enum class {{classname}}(val value: {{{dataType}}}){
{{/isListContainer}}
{{/enumVars}}{{/allowableValues}}
{{#multiplatform}}
object Serializer : CommonEnumSerializer<{{classname}}>("{{classname}}", values(), values().map { it.value }.toTypedArray())
{{/multiplatform}}
}

View File

@ -12,9 +12,12 @@ fun collectionDelimiter(collectionFormat: String) = when(collectionFormat) {
val defaultMultiValueConverter: (item: Any?) -> String = { item -> "$item" }
fun <T: Any?> toMultiValue(items: List<T>, collectionFormat: String, map: (item: Any?) -> String = defaultMultiValueConverter): List<String> {
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.map(map).joinToString(separator = collectionDelimiter(collectionFormat)))
else -> listOf(items.joinToString(separator = collectionDelimiter(collectionFormat), transform = map))
}
}

View File

@ -0,0 +1,90 @@
{{>licenseInfo}}
package {{apiPackage}}
{{#imports}}import {{import}}
{{/imports}}
import {{packageName}}.infrastructure.*
import io.ktor.client.request.forms.formData
import kotlinx.serialization.UnstableDefault
import io.ktor.client.engine.HttpClientEngine
import io.ktor.client.features.json.serializer.KotlinxSerializer
import kotlinx.serialization.json.Json
import kotlinx.serialization.json.JsonConfiguration
import io.ktor.http.ParametersBuilder
import kotlinx.serialization.*
import kotlinx.serialization.internal.StringDescriptor
{{#operations}}
class {{classname}} @UseExperimental(UnstableDefault::class) constructor(
baseUrl: kotlin.String = "{{{basePath}}}",
httpClientEngine: HttpClientEngine? = null,
serializer: KotlinxSerializer)
: ApiClient(baseUrl, httpClientEngine, serializer) {
@UseExperimental(UnstableDefault::class)
constructor(
baseUrl: kotlin.String = "{{{basePath}}}",
httpClientEngine: HttpClientEngine? = null,
jsonConfiguration: JsonConfiguration = JsonConfiguration.Default)
: this(baseUrl, httpClientEngine, KotlinxSerializer(Json(jsonConfiguration)))
{{#operation}}
/**
* {{summary}}
* {{notes}}
{{#allParams}}* @param {{paramName}} {{description}} {{^required}}(optional{{#defaultValue}}, default to {{{.}}}{{/defaultValue}}){{/required}}
{{/allParams}}* @return {{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}}
*/{{#returnType}}
@Suppress("UNCHECKED_CAST"){{/returnType}}
suspend fun {{operationId}}({{#allParams}}{{paramName}}: {{{dataType}}}{{^required}}?{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) : HttpResponse<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Unit{{/returnType}}> {
val localVariableBody = {{#hasBodyParam}}{{#bodyParam}}{{#isListContainer}}{{operationIdCamelCase}}Request({{paramName}}.asList()){{/isListContainer}}{{^isListContainer}}{{#isMapContainer}}{{operationIdCamelCase}}Request({{paramName}}){{/isMapContainer}}{{^isMapContainer}}{{paramName}}{{/isMapContainer}}{{/isListContainer}}{{/bodyParam}}{{/hasBodyParam}}
{{^hasBodyParam}}{{#hasFormParams}}{{#isMultipart}}formData {
{{#formParams}}
{{paramName}}?.apply { append("{{{baseName}}}", {{paramName}}) }
{{/formParams}}
}{{/isMultipart}}{{^isMultipart}}ParametersBuilder().also {
{{#formParams}}
{{paramName}}?.apply { it.append("{{{baseName}}}", {{paramName}}.toString()) }
{{/formParams}}
}.build(){{/isMultipart}}{{/hasFormParams}}{{^hasFormParams}}io.ktor.client.utils.EmptyContent{{/hasFormParams}}{{/hasBodyParam}}
val localVariableQuery = mutableMapOf<String, List<String>>()
{{#hasQueryParams}}{{#queryParams}}
{{paramName}}?.apply { localVariableQuery["{{baseName}}"] = {{#isContainer}}toMultiValue(this, "{{collectionFormat}}"){{/isContainer}}{{^isContainer}}listOf("${{paramName}}"){{/isContainer}} }
{{/queryParams}}{{/hasQueryParams}}
val localVariableHeaders = mutableMapOf<String, String>()
{{#hasHeaderParams}}{{#headerParams}}
{{paramName}}?.apply { localVariableHeaders["{{baseName}}"] = {{#isContainer}}this.joinToString(separator = collectionDelimiter("{{collectionFormat}}")){{/isContainer}}{{^isContainer}}this.toString(){{/isContainer}} }
{{/headerParams}}{{/hasHeaderParams}}
val localVariableConfig = RequestConfig(
RequestMethod.{{httpMethod}},
"{{path}}"{{#pathParams}}.replace("{"+"{{baseName}}"+"}", "${{paramName}}"){{/pathParams}},
query = localVariableQuery,
headers = localVariableHeaders
)
return {{#hasBodyParam}}jsonRequest{{/hasBodyParam}}{{^hasBodyParam}}{{#hasFormParams}}{{#isMultipart}}multipartFormRequest{{/isMultipart}}{{^isMultipart}}urlEncodedFormRequest{{/isMultipart}}{{/hasFormParams}}{{^hasFormParams}}request{{/hasFormParams}}{{/hasBodyParam}}(
localVariableConfig,
localVariableBody
).{{#isListContainer}}wrap<{{operationIdCamelCase}}Response>().map { value.toTypedArray() }{{/isListContainer}}{{^isListContainer}}{{#isMapContainer}}wrap<{{operationIdCamelCase}}Response>().map { value }{{/isMapContainer}}{{^isMapContainer}}wrap(){{/isMapContainer}}{{/isListContainer}}
}
{{#hasBodyParam}}{{#bodyParam}}{{#isListContainer}}{{>serial_wrapper_request_list}}{{/isListContainer}}{{#isMapContainer}}{{>serial_wrapper_request_map}}{{/isMapContainer}}{{/bodyParam}}{{/hasBodyParam}}
{{#isListContainer}}{{>serial_wrapper_response_list}}{{/isListContainer}}{{#isMapContainer}}{{>serial_wrapper_response_map}}{{/isMapContainer}}
{{/operation}}
companion object {
internal fun setMappers(serializer: KotlinxSerializer) {
{{#operation}}
{{#hasBodyParam}}{{#bodyParam}}{{#isListContainer}}serializer.setMapper({{operationIdCamelCase}}Request::class, {{operationIdCamelCase}}Request.serializer()){{/isListContainer}}{{#isMapContainer}}serializer.setMapper({{operationIdCamelCase}}Request::class, {{operationIdCamelCase}}Request.serializer()){{/isMapContainer}}{{/bodyParam}}{{/hasBodyParam}}
{{#isListContainer}}serializer.setMapper({{operationIdCamelCase}}Response::class, {{operationIdCamelCase}}Response.serializer()){{/isListContainer}}{{#isMapContainer}}serializer.setMapper({{operationIdCamelCase}}Response::class, {{operationIdCamelCase}}Response.serializer()){{/isMapContainer}}
{{/operation}}
}
}
}
{{/operations}}

View File

@ -0,0 +1,138 @@
apply plugin: 'kotlin-multiplatform'
apply plugin: 'kotlinx-serialization'
group '{{groupId}}'
version '{{artifactVersion}}'
ext {
kotlin_version = '1.3.50'
kotlinx_version = '1.1.0'
coroutines_version = '1.3.1'
serialization_version = '0.12.0'
ktor_version = '1.2.4'
}
buildscript {
repositories {
jcenter()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.50" // $kotlin_version
classpath "org.jetbrains.kotlin:kotlin-serialization:1.3.50" // $kotlin_version
}
}
repositories {
jcenter()
}
kotlin {
jvm()
iosArm64() { binaries { framework { freeCompilerArgs.add("-Xobjc-generics") } } }
iosX64() { binaries { framework { freeCompilerArgs.add("-Xobjc-generics") } } }
sourceSets {
commonMain {
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-common:$kotlin_version"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core-common:$coroutines_version"
implementation "org.jetbrains.kotlinx:kotlinx-serialization-runtime-common:$serialization_version"
implementation "io.ktor:ktor-client-core:$ktor_version"
implementation "io.ktor:ktor-client-json:$ktor_version"
implementation "io.ktor:ktor-client-serialization:$ktor_version"
}
}
commonTest {
dependencies {
implementation "org.jetbrains.kotlin:kotlin-test-common"
implementation "org.jetbrains.kotlin:kotlin-test-annotations-common"
implementation "io.ktor:ktor-client-mock:$ktor_version"
}
}
jvmMain {
dependsOn commonMain
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version"
implementation "org.jetbrains.kotlinx:kotlinx-serialization-runtime:$serialization_version"
implementation "io.ktor:ktor-client-core-jvm:$ktor_version"
implementation "io.ktor:ktor-client-json-jvm:$ktor_version"
implementation "io.ktor:ktor-client-serialization-jvm:$ktor_version"
}
}
jvmTest {
dependsOn commonTest
dependencies {
implementation "org.jetbrains.kotlin:kotlin-test"
implementation "org.jetbrains.kotlin:kotlin-test-junit"
implementation "io.ktor:ktor-client-mock-jvm:$ktor_version"
}
}
iosMain {
dependsOn commonMain
dependencies {
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core-native:$coroutines_version"
implementation "org.jetbrains.kotlinx:kotlinx-serialization-runtime-native:$serialization_version"
implementation "io.ktor:ktor-client-ios:$ktor_version"
}
}
iosTest {
dependsOn commonTest
dependencies {
implementation "io.ktor:ktor-client-mock-native:$ktor_version"
}
}
iosArm64().compilations.main.defaultSourceSet {
dependsOn iosMain
dependencies {
implementation "io.ktor:ktor-client-ios-iosarm64:$ktor_version"
implementation "io.ktor:ktor-client-json-iosarm64:$ktor_version"
implementation "io.ktor:ktor-client-serialization-iosarm64:$ktor_version"
}
}
iosArm64().compilations.test.defaultSourceSet {
dependsOn iosTest
}
iosX64().compilations.main.defaultSourceSet {
dependsOn iosMain
dependencies {
implementation "io.ktor:ktor-client-ios-iosx64:$ktor_version"
implementation "io.ktor:ktor-client-json-iosx64:$ktor_version"
implementation "io.ktor:ktor-client-serialization-iosx64:$ktor_version"
}
}
iosX64().compilations.test.defaultSourceSet {
dependsOn iosTest
}
all {
languageSettings {
useExperimentalAnnotation('kotlin.Experimental')
}
}
}
}
task iosTest {
def device = project.findProperty("device")?.toString() ?: "iPhone 8"
dependsOn 'linkDebugTestIosX64'
group = JavaBasePlugin.VERIFICATION_GROUP
description = "Execute unit tests on ${device} simulator"
doLast {
def binary = kotlin.targets.iosX64.binaries.getTest('DEBUG')
exec { commandLine 'xcrun', 'simctl', 'spawn', device, binary.outputFile }
}
}
configurations { // workaround for https://youtrack.jetbrains.com/issue/KT-27170
compileClasspath
}

View File

@ -0,0 +1,13 @@
{{>licenseInfo}}
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

View File

@ -0,0 +1,6 @@
#Tue May 17 23:08:05 CST 2016
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-bin.zip

View File

@ -0,0 +1,90 @@
@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
@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=
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@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 init
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 init
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
:init
@rem Get command-line arguments, handling Windows variants
if not "%OS%" == "Windows_NT" goto win9xME_args
if "%@eval[2+2]" == "4" goto 4NT_args
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
goto execute
:4NT_args
@rem Get arguments from the 4NT Shell from JP Software
set CMD_LINE_ARGS=%$
: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 %CMD_LINE_ARGS%
: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

View File

@ -0,0 +1,160 @@
#!/usr/bin/env bash
##############################################################################
##
## Gradle start up script for UN*X
##
##############################################################################
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS=""
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# 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
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
esac
# 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
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" ] ; 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, switch paths to Windows format before running java
if $cygwin ; 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=$((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
# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
function splitJvmOpts() {
JVM_OPTS=("$@")
}
eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"

View File

@ -0,0 +1,122 @@
package {{packageName}}.infrastructure
import io.ktor.client.HttpClient
import io.ktor.client.HttpClientConfig
import io.ktor.client.call.call
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.accept
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.response.HttpResponse
import io.ktor.client.utils.EmptyContent
import io.ktor.http.*
import io.ktor.http.content.OutgoingContent
import io.ktor.http.content.PartData
import kotlinx.serialization.UnstableDefault
import kotlinx.serialization.json.Json
import kotlinx.serialization.json.JsonConfiguration
import {{apiPackage}}.*
import {{modelPackage}}.*
open class ApiClient(
private val baseUrl: String,
httpClientEngine: HttpClientEngine?,
serializer: KotlinxSerializer) {
@UseExperimental(UnstableDefault::class)
constructor(
baseUrl: String,
httpClientEngine: HttpClientEngine?,
jsonConfiguration: JsonConfiguration) :
this(baseUrl, httpClientEngine, KotlinxSerializer(Json(jsonConfiguration)))
private val serializer: JsonSerializer by lazy {
serializer.apply { setMappers(this) }.ignoreOutgoingContent()
}
private val client: HttpClient by lazy {
val jsonConfig: JsonFeature.Config.() -> Unit = { this.serializer = this@ApiClient.serializer }
val clientConfig: (HttpClientConfig<*>) -> Unit = { it.install(JsonFeature, jsonConfig) }
httpClientEngine?.let { HttpClient(it, clientConfig) } ?: HttpClient(clientConfig)
}
companion object {
protected val UNSAFE_HEADERS = listOf(HttpHeaders.ContentType)
private fun setMappers(serializer: KotlinxSerializer) {
{{#apiInfo}}{{#apis}}
{{classname}}.setMappers(serializer)
{{/apis}}{{/apiInfo}}
{{#models}}
{{#model}}{{^isAlias}}serializer.setMapper({{classname}}::class, {{classname}}.serializer()){{/isAlias}}{{/model}}
{{/models}}
}
}
protected suspend fun multipartFormRequest(requestConfig: RequestConfig, body: List<PartData>?): HttpResponse {
return request(requestConfig, MultiPartFormDataContent(body ?: listOf()))
}
protected suspend fun urlEncodedFormRequest(requestConfig: RequestConfig, body: Parameters?): HttpResponse {
return request(requestConfig, FormDataContent(body ?: Parameters.Empty))
}
protected suspend fun jsonRequest(requestConfig: RequestConfig, body: Any? = null): HttpResponse {
val contentType = (requestConfig.headers[HttpHeaders.ContentType]?.let { ContentType.parse(it) }
?: ContentType.Application.Json)
return if (body != null) request(requestConfig, serializer.write(body, contentType))
else request(requestConfig)
}
protected suspend fun request(requestConfig: RequestConfig, body: OutgoingContent = EmptyContent): HttpResponse {
val headers = requestConfig.headers
return client.call {
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
}.response
}
private fun URLBuilder.appendPath(components: 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)
}
}

View File

@ -0,0 +1,51 @@
package {{packageName}}.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.response.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.response.HttpResponse): T
suspend fun <V : Any> typedBody(response: io.ktor.client.response.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.response.HttpResponse): T =
response.call.receive(type) as T
@Suppress("UNCHECKED_CAST")
override suspend fun <V : Any> typedBody(response: io.ktor.client.response.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.response.HttpResponse): T =
block(provider.body(response))
override suspend fun <V : Any> typedBody(response: io.ktor.client.response.HttpResponse, type: TypeInfo): V =
provider.typedBody(response, type)
}
inline fun <reified T : Any> io.ktor.client.response.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))

View File

@ -0,0 +1,8 @@
{{>licenseInfo}}
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)

View File

@ -0,0 +1,8 @@
{{>licenseInfo}}
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)

View File

@ -0,0 +1,10 @@
@Serializable
private class {{operationIdCamelCase}}Request(val value: List<{{#bodyParam}}{{baseType}}{{/bodyParam}}>) {
@Serializer({{operationIdCamelCase}}Request::class)
companion object : KSerializer<{{operationIdCamelCase}}Request> {
private val serializer: KSerializer<List<{{#bodyParam}}{{baseType}}{{/bodyParam}}>> = {{#bodyParam}}{{baseType}}{{/bodyParam}}.serializer().list
override val descriptor = StringDescriptor.withName("{{operationIdCamelCase}}Request")
override fun serialize(encoder: Encoder, obj: {{operationIdCamelCase}}Request) = serializer.serialize(encoder, obj.value)
override fun deserialize(decoder: Decoder) = {{operationIdCamelCase}}Request(serializer.deserialize(decoder))
}
}

View File

@ -0,0 +1,10 @@
@Serializable
private class {{operationIdCamelCase}}Request(val value: Map<kotlin.String, {{#bodyParam}}{{baseType}}{{/bodyParam}}>) {
@Serializer({{operationIdCamelCase}}Request::class)
companion object : KSerializer<{{operationIdCamelCase}}Request> {
private val serializer: KSerializer<Map<kotlin.String, {{#bodyParam}}{{baseType}}{{/bodyParam}}>> = (kotlin.String.serializer() to {{#bodyParam}}{{baseType}}{{/bodyParam}}.serializer()).map
override val descriptor = StringDescriptor.withName("{{operationIdCamelCase}}Request")
override fun serialize(encoder: Encoder, obj: {{operationIdCamelCase}}Request) = serializer.serialize(encoder, obj.value)
override fun deserialize(decoder: Decoder) = {{operationIdCamelCase}}Request(serializer.deserialize(decoder))
}
}

View File

@ -0,0 +1,10 @@
@Serializable
private class {{operationIdCamelCase}}Response(val value: List<{{returnBaseType}}>) {
@Serializer({{operationIdCamelCase}}Response::class)
companion object : KSerializer<{{operationIdCamelCase}}Response> {
private val serializer: KSerializer<List<{{returnBaseType}}>> = {{returnBaseType}}.serializer().list
override val descriptor = StringDescriptor.withName("{{operationIdCamelCase}}Response")
override fun serialize(encoder: Encoder, obj: {{operationIdCamelCase}}Response) = serializer.serialize(encoder, obj.value)
override fun deserialize(decoder: Decoder) = {{operationIdCamelCase}}Response(serializer.deserialize(decoder))
}
}

View File

@ -0,0 +1,10 @@
@Serializable
private class {{operationIdCamelCase}}Response(val value: Map<kotlin.String, {{returnBaseType}}>) {
@Serializer({{operationIdCamelCase}}Response::class)
companion object : KSerializer<{{operationIdCamelCase}}Response> {
private val serializer: KSerializer<Map<kotlin.String, {{returnBaseType}}>> = (kotlin.String.serializer() to {{returnBaseType}}.serializer()).map
override val descriptor = StringDescriptor.withName("{{operationIdCamelCase}}Response")
override fun serialize(encoder: Encoder, obj: {{operationIdCamelCase}}Response) = serializer.serialize(encoder, obj.value)
override fun deserialize(decoder: Decoder) = {{operationIdCamelCase}}Response(serializer.deserialize(decoder))
}
}

View File

@ -1 +1,2 @@
{{#multiplatform}}enableFeaturePreview('GRADLE_METADATA'){{/multiplatform}}
rootProject.name = '{{artifactId}}'

View File

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

View File

@ -0,0 +1 @@
4.1.3-SNAPSHOT

View File

@ -0,0 +1,81 @@
# org.openapitools.client - Kotlin client library for OpenAPI Petstore
## Requires
* Kotlin 1.3.50
## 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://petstore.swagger.io/v2*
Class | Method | HTTP request | Description
------------ | ------------- | ------------- | -------------
*PetApi* | [**addPet**](docs/PetApi.md#addpet) | **POST** /pet | Add a new pet to the store
*PetApi* | [**deletePet**](docs/PetApi.md#deletepet) | **DELETE** /pet/{petId} | Deletes a pet
*PetApi* | [**findPetsByStatus**](docs/PetApi.md#findpetsbystatus) | **GET** /pet/findByStatus | Finds Pets by status
*PetApi* | [**findPetsByTags**](docs/PetApi.md#findpetsbytags) | **GET** /pet/findByTags | Finds Pets by tags
*PetApi* | [**getPetById**](docs/PetApi.md#getpetbyid) | **GET** /pet/{petId} | Find pet by ID
*PetApi* | [**updatePet**](docs/PetApi.md#updatepet) | **PUT** /pet | Update an existing pet
*PetApi* | [**updatePetWithForm**](docs/PetApi.md#updatepetwithform) | **POST** /pet/{petId} | Updates a pet in the store with form data
*PetApi* | [**uploadFile**](docs/PetApi.md#uploadfile) | **POST** /pet/{petId}/uploadImage | uploads an image
*StoreApi* | [**deleteOrder**](docs/StoreApi.md#deleteorder) | **DELETE** /store/order/{orderId} | Delete purchase order by ID
*StoreApi* | [**getInventory**](docs/StoreApi.md#getinventory) | **GET** /store/inventory | Returns pet inventories by status
*StoreApi* | [**getOrderById**](docs/StoreApi.md#getorderbyid) | **GET** /store/order/{orderId} | Find purchase order by ID
*StoreApi* | [**placeOrder**](docs/StoreApi.md#placeorder) | **POST** /store/order | Place an order for a pet
*UserApi* | [**createUser**](docs/UserApi.md#createuser) | **POST** /user | Create user
*UserApi* | [**createUsersWithArrayInput**](docs/UserApi.md#createuserswitharrayinput) | **POST** /user/createWithArray | Creates list of users with given input array
*UserApi* | [**createUsersWithListInput**](docs/UserApi.md#createuserswithlistinput) | **POST** /user/createWithList | Creates list of users with given input array
*UserApi* | [**deleteUser**](docs/UserApi.md#deleteuser) | **DELETE** /user/{username} | Delete user
*UserApi* | [**getUserByName**](docs/UserApi.md#getuserbyname) | **GET** /user/{username} | Get user by user name
*UserApi* | [**loginUser**](docs/UserApi.md#loginuser) | **GET** /user/login | Logs user into the system
*UserApi* | [**logoutUser**](docs/UserApi.md#logoutuser) | **GET** /user/logout | Logs out current logged in user session
*UserApi* | [**updateUser**](docs/UserApi.md#updateuser) | **PUT** /user/{username} | Updated user
<a name="documentation-for-models"></a>
## Documentation for Models
- [org.openapitools.client.models.ApiResponse](docs/ApiResponse.md)
- [org.openapitools.client.models.Category](docs/Category.md)
- [org.openapitools.client.models.Order](docs/Order.md)
- [org.openapitools.client.models.Pet](docs/Pet.md)
- [org.openapitools.client.models.Tag](docs/Tag.md)
- [org.openapitools.client.models.User](docs/User.md)
<a name="documentation-for-authorization"></a>
## Documentation for Authorization
<a name="api_key"></a>
### api_key
- **Type**: API key
- **API key parameter name**: api_key
- **Location**: HTTP header
<a name="petstore_auth"></a>
### petstore_auth
- **Type**: OAuth
- **Flow**: implicit
- **Authorization URL**: http://petstore.swagger.io/api/oauth/dialog
- **Scopes**:
- write:pets: modify pets in your account
- read:pets: read your pets

View File

@ -0,0 +1,138 @@
apply plugin: 'kotlin-multiplatform'
apply plugin: 'kotlinx-serialization'
group 'org.openapitools'
version '1.0.0'
ext {
kotlin_version = '1.3.50'
kotlinx_version = '1.1.0'
coroutines_version = '1.3.1'
serialization_version = '0.12.0'
ktor_version = '1.2.4'
}
buildscript {
repositories {
jcenter()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.50" // $kotlin_version
classpath "org.jetbrains.kotlin:kotlin-serialization:1.3.50" // $kotlin_version
}
}
repositories {
jcenter()
}
kotlin {
jvm()
iosArm64() { binaries { framework { freeCompilerArgs.add("-Xobjc-generics") } } }
iosX64() { binaries { framework { freeCompilerArgs.add("-Xobjc-generics") } } }
sourceSets {
commonMain {
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-common:$kotlin_version"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core-common:$coroutines_version"
implementation "org.jetbrains.kotlinx:kotlinx-serialization-runtime-common:$serialization_version"
implementation "io.ktor:ktor-client-core:$ktor_version"
implementation "io.ktor:ktor-client-json:$ktor_version"
implementation "io.ktor:ktor-client-serialization:$ktor_version"
}
}
commonTest {
dependencies {
implementation "org.jetbrains.kotlin:kotlin-test-common"
implementation "org.jetbrains.kotlin:kotlin-test-annotations-common"
implementation "io.ktor:ktor-client-mock:$ktor_version"
}
}
jvmMain {
dependsOn commonMain
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version"
implementation "org.jetbrains.kotlinx:kotlinx-serialization-runtime:$serialization_version"
implementation "io.ktor:ktor-client-core-jvm:$ktor_version"
implementation "io.ktor:ktor-client-json-jvm:$ktor_version"
implementation "io.ktor:ktor-client-serialization-jvm:$ktor_version"
}
}
jvmTest {
dependsOn commonTest
dependencies {
implementation "org.jetbrains.kotlin:kotlin-test"
implementation "org.jetbrains.kotlin:kotlin-test-junit"
implementation "io.ktor:ktor-client-mock-jvm:$ktor_version"
}
}
iosMain {
dependsOn commonMain
dependencies {
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core-native:$coroutines_version"
implementation "org.jetbrains.kotlinx:kotlinx-serialization-runtime-native:$serialization_version"
implementation "io.ktor:ktor-client-ios:$ktor_version"
}
}
iosTest {
dependsOn commonTest
dependencies {
implementation "io.ktor:ktor-client-mock-native:$ktor_version"
}
}
iosArm64().compilations.main.defaultSourceSet {
dependsOn iosMain
dependencies {
implementation "io.ktor:ktor-client-ios-iosarm64:$ktor_version"
implementation "io.ktor:ktor-client-json-iosarm64:$ktor_version"
implementation "io.ktor:ktor-client-serialization-iosarm64:$ktor_version"
}
}
iosArm64().compilations.test.defaultSourceSet {
dependsOn iosTest
}
iosX64().compilations.main.defaultSourceSet {
dependsOn iosMain
dependencies {
implementation "io.ktor:ktor-client-ios-iosx64:$ktor_version"
implementation "io.ktor:ktor-client-json-iosx64:$ktor_version"
implementation "io.ktor:ktor-client-serialization-iosx64:$ktor_version"
}
}
iosX64().compilations.test.defaultSourceSet {
dependsOn iosTest
}
all {
languageSettings {
useExperimentalAnnotation('kotlin.Experimental')
}
}
}
}
task iosTest {
def device = project.findProperty("device")?.toString() ?: "iPhone 8"
dependsOn 'linkDebugTestIosX64'
group = JavaBasePlugin.VERIFICATION_GROUP
description = "Execute unit tests on ${device} simulator"
doLast {
def binary = kotlin.targets.iosX64.binaries.getTest('DEBUG')
exec { commandLine 'xcrun', 'simctl', 'spawn', device, binary.outputFile }
}
}
configurations { // workaround for https://youtrack.jetbrains.com/issue/KT-27170
compileClasspath
}

View File

@ -0,0 +1,12 @@
# ApiResponse
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**code** | **kotlin.Int** | | [optional]
**type** | **kotlin.String** | | [optional]
**message** | **kotlin.String** | | [optional]

View File

@ -0,0 +1,11 @@
# Category
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**id** | **kotlin.Long** | | [optional]
**name** | **kotlin.String** | | [optional]

View File

@ -0,0 +1,22 @@
# Order
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**id** | **kotlin.Long** | | [optional]
**petId** | **kotlin.Long** | | [optional]
**quantity** | **kotlin.Int** | | [optional]
**shipDate** | **kotlin.String** | | [optional]
**status** | [**inline**](#StatusEnum) | Order Status | [optional]
**complete** | **kotlin.Boolean** | | [optional]
<a name="StatusEnum"></a>
## Enum: status
Name | Value
---- | -----
status | placed, approved, delivered

View File

@ -0,0 +1,22 @@
# Pet
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**id** | **kotlin.Long** | | [optional]
**category** | [**Category**](Category.md) | | [optional]
**name** | **kotlin.String** | |
**photoUrls** | **kotlin.Array&lt;kotlin.String&gt;** | |
**tags** | [**kotlin.Array&lt;Tag&gt;**](Tag.md) | | [optional]
**status** | [**inline**](#StatusEnum) | pet status in the store | [optional]
<a name="StatusEnum"></a>
## Enum: status
Name | Value
---- | -----
status | available, pending, sold

View File

@ -0,0 +1,405 @@
# PetApi
All URIs are relative to *http://petstore.swagger.io/v2*
Method | HTTP request | Description
------------- | ------------- | -------------
[**addPet**](PetApi.md#addPet) | **POST** /pet | Add a new pet to the store
[**deletePet**](PetApi.md#deletePet) | **DELETE** /pet/{petId} | Deletes a pet
[**findPetsByStatus**](PetApi.md#findPetsByStatus) | **GET** /pet/findByStatus | Finds Pets by status
[**findPetsByTags**](PetApi.md#findPetsByTags) | **GET** /pet/findByTags | Finds Pets by tags
[**getPetById**](PetApi.md#getPetById) | **GET** /pet/{petId} | Find pet by ID
[**updatePet**](PetApi.md#updatePet) | **PUT** /pet | Update an existing pet
[**updatePetWithForm**](PetApi.md#updatePetWithForm) | **POST** /pet/{petId} | Updates a pet in the store with form data
[**uploadFile**](PetApi.md#uploadFile) | **POST** /pet/{petId}/uploadImage | uploads an image
<a name="addPet"></a>
# **addPet**
> addPet(body)
Add a new pet to the store
### Example
```kotlin
// Import classes:
//import org.openapitools.client.infrastructure.*
//import org.openapitools.client.models.*
val apiInstance = PetApi()
val body : Pet = // Pet | Pet object that needs to be added to the store
try {
apiInstance.addPet(body)
} catch (e: ClientException) {
println("4xx response calling PetApi#addPet")
e.printStackTrace()
} catch (e: ServerException) {
println("5xx response calling PetApi#addPet")
e.printStackTrace()
}
```
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**body** | [**Pet**](Pet.md)| Pet object that needs to be added to the store |
### Return type
null (empty response body)
### Authorization
Configure petstore_auth:
ApiClient.accessToken = ""
### HTTP request headers
- **Content-Type**: application/json, application/xml
- **Accept**: Not defined
<a name="deletePet"></a>
# **deletePet**
> deletePet(petId, apiKey)
Deletes a pet
### Example
```kotlin
// Import classes:
//import org.openapitools.client.infrastructure.*
//import org.openapitools.client.models.*
val apiInstance = PetApi()
val petId : kotlin.Long = 789 // kotlin.Long | Pet id to delete
val apiKey : kotlin.String = apiKey_example // kotlin.String |
try {
apiInstance.deletePet(petId, apiKey)
} catch (e: ClientException) {
println("4xx response calling PetApi#deletePet")
e.printStackTrace()
} catch (e: ServerException) {
println("5xx response calling PetApi#deletePet")
e.printStackTrace()
}
```
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**petId** | **kotlin.Long**| Pet id to delete |
**apiKey** | **kotlin.String**| | [optional]
### Return type
null (empty response body)
### Authorization
Configure petstore_auth:
ApiClient.accessToken = ""
### HTTP request headers
- **Content-Type**: Not defined
- **Accept**: Not defined
<a name="findPetsByStatus"></a>
# **findPetsByStatus**
> kotlin.Array&lt;Pet&gt; findPetsByStatus(status)
Finds Pets by status
Multiple status values can be provided with comma separated strings
### Example
```kotlin
// Import classes:
//import org.openapitools.client.infrastructure.*
//import org.openapitools.client.models.*
val apiInstance = PetApi()
val status : kotlin.Array<kotlin.String> = // kotlin.Array<kotlin.String> | Status values that need to be considered for filter
try {
val result : kotlin.Array<Pet> = apiInstance.findPetsByStatus(status)
println(result)
} catch (e: ClientException) {
println("4xx response calling PetApi#findPetsByStatus")
e.printStackTrace()
} catch (e: ServerException) {
println("5xx response calling PetApi#findPetsByStatus")
e.printStackTrace()
}
```
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**status** | [**kotlin.Array&lt;kotlin.String&gt;**](kotlin.String.md)| Status values that need to be considered for filter | [enum: available, pending, sold]
### Return type
[**kotlin.Array&lt;Pet&gt;**](Pet.md)
### Authorization
Configure petstore_auth:
ApiClient.accessToken = ""
### HTTP request headers
- **Content-Type**: Not defined
- **Accept**: application/xml, application/json
<a name="findPetsByTags"></a>
# **findPetsByTags**
> kotlin.Array&lt;Pet&gt; findPetsByTags(tags)
Finds Pets by tags
Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
### Example
```kotlin
// Import classes:
//import org.openapitools.client.infrastructure.*
//import org.openapitools.client.models.*
val apiInstance = PetApi()
val tags : kotlin.Array<kotlin.String> = // kotlin.Array<kotlin.String> | Tags to filter by
try {
val result : kotlin.Array<Pet> = apiInstance.findPetsByTags(tags)
println(result)
} catch (e: ClientException) {
println("4xx response calling PetApi#findPetsByTags")
e.printStackTrace()
} catch (e: ServerException) {
println("5xx response calling PetApi#findPetsByTags")
e.printStackTrace()
}
```
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**tags** | [**kotlin.Array&lt;kotlin.String&gt;**](kotlin.String.md)| Tags to filter by |
### Return type
[**kotlin.Array&lt;Pet&gt;**](Pet.md)
### Authorization
Configure petstore_auth:
ApiClient.accessToken = ""
### HTTP request headers
- **Content-Type**: Not defined
- **Accept**: application/xml, application/json
<a name="getPetById"></a>
# **getPetById**
> Pet getPetById(petId)
Find pet by ID
Returns a single pet
### Example
```kotlin
// Import classes:
//import org.openapitools.client.infrastructure.*
//import org.openapitools.client.models.*
val apiInstance = PetApi()
val petId : kotlin.Long = 789 // kotlin.Long | ID of pet to return
try {
val result : Pet = apiInstance.getPetById(petId)
println(result)
} catch (e: ClientException) {
println("4xx response calling PetApi#getPetById")
e.printStackTrace()
} catch (e: ServerException) {
println("5xx response calling PetApi#getPetById")
e.printStackTrace()
}
```
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**petId** | **kotlin.Long**| ID of pet to return |
### Return type
[**Pet**](Pet.md)
### Authorization
Configure api_key:
ApiClient.apiKey["api_key"] = ""
ApiClient.apiKeyPrefix["api_key"] = ""
### HTTP request headers
- **Content-Type**: Not defined
- **Accept**: application/xml, application/json
<a name="updatePet"></a>
# **updatePet**
> updatePet(body)
Update an existing pet
### Example
```kotlin
// Import classes:
//import org.openapitools.client.infrastructure.*
//import org.openapitools.client.models.*
val apiInstance = PetApi()
val body : Pet = // Pet | Pet object that needs to be added to the store
try {
apiInstance.updatePet(body)
} catch (e: ClientException) {
println("4xx response calling PetApi#updatePet")
e.printStackTrace()
} catch (e: ServerException) {
println("5xx response calling PetApi#updatePet")
e.printStackTrace()
}
```
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**body** | [**Pet**](Pet.md)| Pet object that needs to be added to the store |
### Return type
null (empty response body)
### Authorization
Configure petstore_auth:
ApiClient.accessToken = ""
### HTTP request headers
- **Content-Type**: application/json, application/xml
- **Accept**: Not defined
<a name="updatePetWithForm"></a>
# **updatePetWithForm**
> updatePetWithForm(petId, name, status)
Updates a pet in the store with form data
### Example
```kotlin
// Import classes:
//import org.openapitools.client.infrastructure.*
//import org.openapitools.client.models.*
val apiInstance = PetApi()
val petId : kotlin.Long = 789 // kotlin.Long | ID of pet that needs to be updated
val name : kotlin.String = name_example // kotlin.String | Updated name of the pet
val status : kotlin.String = status_example // kotlin.String | Updated status of the pet
try {
apiInstance.updatePetWithForm(petId, name, status)
} catch (e: ClientException) {
println("4xx response calling PetApi#updatePetWithForm")
e.printStackTrace()
} catch (e: ServerException) {
println("5xx response calling PetApi#updatePetWithForm")
e.printStackTrace()
}
```
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**petId** | **kotlin.Long**| ID of pet that needs to be updated |
**name** | **kotlin.String**| Updated name of the pet | [optional]
**status** | **kotlin.String**| Updated status of the pet | [optional]
### Return type
null (empty response body)
### Authorization
Configure petstore_auth:
ApiClient.accessToken = ""
### HTTP request headers
- **Content-Type**: application/x-www-form-urlencoded
- **Accept**: Not defined
<a name="uploadFile"></a>
# **uploadFile**
> ApiResponse uploadFile(petId, additionalMetadata, file)
uploads an image
### Example
```kotlin
// Import classes:
//import org.openapitools.client.infrastructure.*
//import org.openapitools.client.models.*
val apiInstance = PetApi()
val petId : kotlin.Long = 789 // kotlin.Long | ID of pet to update
val additionalMetadata : kotlin.String = additionalMetadata_example // kotlin.String | Additional data to pass to server
val file : io.ktor.client.request.forms.InputProvider = BINARY_DATA_HERE // io.ktor.client.request.forms.InputProvider | file to upload
try {
val result : ApiResponse = apiInstance.uploadFile(petId, additionalMetadata, file)
println(result)
} catch (e: ClientException) {
println("4xx response calling PetApi#uploadFile")
e.printStackTrace()
} catch (e: ServerException) {
println("5xx response calling PetApi#uploadFile")
e.printStackTrace()
}
```
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**petId** | **kotlin.Long**| ID of pet to update |
**additionalMetadata** | **kotlin.String**| Additional data to pass to server | [optional]
**file** | **io.ktor.client.request.forms.InputProvider**| file to upload | [optional]
### Return type
[**ApiResponse**](ApiResponse.md)
### Authorization
Configure petstore_auth:
ApiClient.accessToken = ""
### HTTP request headers
- **Content-Type**: multipart/form-data
- **Accept**: application/json

View File

@ -0,0 +1,196 @@
# StoreApi
All URIs are relative to *http://petstore.swagger.io/v2*
Method | HTTP request | Description
------------- | ------------- | -------------
[**deleteOrder**](StoreApi.md#deleteOrder) | **DELETE** /store/order/{orderId} | Delete purchase order by ID
[**getInventory**](StoreApi.md#getInventory) | **GET** /store/inventory | Returns pet inventories by status
[**getOrderById**](StoreApi.md#getOrderById) | **GET** /store/order/{orderId} | Find purchase order by ID
[**placeOrder**](StoreApi.md#placeOrder) | **POST** /store/order | Place an order for a pet
<a name="deleteOrder"></a>
# **deleteOrder**
> deleteOrder(orderId)
Delete purchase order by ID
For valid response try integer IDs with value &lt; 1000. Anything above 1000 or nonintegers will generate API errors
### Example
```kotlin
// Import classes:
//import org.openapitools.client.infrastructure.*
//import org.openapitools.client.models.*
val apiInstance = StoreApi()
val orderId : kotlin.String = orderId_example // kotlin.String | ID of the order that needs to be deleted
try {
apiInstance.deleteOrder(orderId)
} catch (e: ClientException) {
println("4xx response calling StoreApi#deleteOrder")
e.printStackTrace()
} catch (e: ServerException) {
println("5xx response calling StoreApi#deleteOrder")
e.printStackTrace()
}
```
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**orderId** | **kotlin.String**| ID of the order that needs to be deleted |
### Return type
null (empty response body)
### Authorization
No authorization required
### HTTP request headers
- **Content-Type**: Not defined
- **Accept**: Not defined
<a name="getInventory"></a>
# **getInventory**
> kotlin.collections.Map&lt;kotlin.String, kotlin.Int&gt; getInventory()
Returns pet inventories by status
Returns a map of status codes to quantities
### Example
```kotlin
// Import classes:
//import org.openapitools.client.infrastructure.*
//import org.openapitools.client.models.*
val apiInstance = StoreApi()
try {
val result : kotlin.collections.Map<kotlin.String, kotlin.Int> = apiInstance.getInventory()
println(result)
} catch (e: ClientException) {
println("4xx response calling StoreApi#getInventory")
e.printStackTrace()
} catch (e: ServerException) {
println("5xx response calling StoreApi#getInventory")
e.printStackTrace()
}
```
### Parameters
This endpoint does not need any parameter.
### Return type
**kotlin.collections.Map&lt;kotlin.String, kotlin.Int&gt;**
### Authorization
Configure api_key:
ApiClient.apiKey["api_key"] = ""
ApiClient.apiKeyPrefix["api_key"] = ""
### HTTP request headers
- **Content-Type**: Not defined
- **Accept**: application/json
<a name="getOrderById"></a>
# **getOrderById**
> Order getOrderById(orderId)
Find purchase order by ID
For valid response try integer IDs with value &lt;&#x3D; 5 or &gt; 10. Other values will generated exceptions
### Example
```kotlin
// Import classes:
//import org.openapitools.client.infrastructure.*
//import org.openapitools.client.models.*
val apiInstance = StoreApi()
val orderId : kotlin.Long = 789 // kotlin.Long | ID of pet that needs to be fetched
try {
val result : Order = apiInstance.getOrderById(orderId)
println(result)
} catch (e: ClientException) {
println("4xx response calling StoreApi#getOrderById")
e.printStackTrace()
} catch (e: ServerException) {
println("5xx response calling StoreApi#getOrderById")
e.printStackTrace()
}
```
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**orderId** | **kotlin.Long**| ID of pet that needs to be fetched |
### Return type
[**Order**](Order.md)
### Authorization
No authorization required
### HTTP request headers
- **Content-Type**: Not defined
- **Accept**: application/xml, application/json
<a name="placeOrder"></a>
# **placeOrder**
> Order placeOrder(body)
Place an order for a pet
### Example
```kotlin
// Import classes:
//import org.openapitools.client.infrastructure.*
//import org.openapitools.client.models.*
val apiInstance = StoreApi()
val body : Order = // Order | order placed for purchasing the pet
try {
val result : Order = apiInstance.placeOrder(body)
println(result)
} catch (e: ClientException) {
println("4xx response calling StoreApi#placeOrder")
e.printStackTrace()
} catch (e: ServerException) {
println("5xx response calling StoreApi#placeOrder")
e.printStackTrace()
}
```
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**body** | [**Order**](Order.md)| order placed for purchasing the pet |
### Return type
[**Order**](Order.md)
### Authorization
No authorization required
### HTTP request headers
- **Content-Type**: Not defined
- **Accept**: application/xml, application/json

View File

@ -0,0 +1,11 @@
# Tag
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**id** | **kotlin.Long** | | [optional]
**name** | **kotlin.String** | | [optional]

View File

@ -0,0 +1,17 @@
# User
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**id** | **kotlin.Long** | | [optional]
**username** | **kotlin.String** | | [optional]
**firstName** | **kotlin.String** | | [optional]
**lastName** | **kotlin.String** | | [optional]
**email** | **kotlin.String** | | [optional]
**password** | **kotlin.String** | | [optional]
**phone** | **kotlin.String** | | [optional]
**userStatus** | **kotlin.Int** | User Status | [optional]

View File

@ -0,0 +1,376 @@
# UserApi
All URIs are relative to *http://petstore.swagger.io/v2*
Method | HTTP request | Description
------------- | ------------- | -------------
[**createUser**](UserApi.md#createUser) | **POST** /user | Create user
[**createUsersWithArrayInput**](UserApi.md#createUsersWithArrayInput) | **POST** /user/createWithArray | Creates list of users with given input array
[**createUsersWithListInput**](UserApi.md#createUsersWithListInput) | **POST** /user/createWithList | Creates list of users with given input array
[**deleteUser**](UserApi.md#deleteUser) | **DELETE** /user/{username} | Delete user
[**getUserByName**](UserApi.md#getUserByName) | **GET** /user/{username} | Get user by user name
[**loginUser**](UserApi.md#loginUser) | **GET** /user/login | Logs user into the system
[**logoutUser**](UserApi.md#logoutUser) | **GET** /user/logout | Logs out current logged in user session
[**updateUser**](UserApi.md#updateUser) | **PUT** /user/{username} | Updated user
<a name="createUser"></a>
# **createUser**
> createUser(body)
Create user
This can only be done by the logged in user.
### Example
```kotlin
// Import classes:
//import org.openapitools.client.infrastructure.*
//import org.openapitools.client.models.*
val apiInstance = UserApi()
val body : User = // User | Created user object
try {
apiInstance.createUser(body)
} catch (e: ClientException) {
println("4xx response calling UserApi#createUser")
e.printStackTrace()
} catch (e: ServerException) {
println("5xx response calling UserApi#createUser")
e.printStackTrace()
}
```
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**body** | [**User**](User.md)| Created user object |
### Return type
null (empty response body)
### Authorization
No authorization required
### HTTP request headers
- **Content-Type**: Not defined
- **Accept**: Not defined
<a name="createUsersWithArrayInput"></a>
# **createUsersWithArrayInput**
> createUsersWithArrayInput(body)
Creates list of users with given input array
### Example
```kotlin
// Import classes:
//import org.openapitools.client.infrastructure.*
//import org.openapitools.client.models.*
val apiInstance = UserApi()
val body : kotlin.Array<User> = // kotlin.Array<User> | List of user object
try {
apiInstance.createUsersWithArrayInput(body)
} catch (e: ClientException) {
println("4xx response calling UserApi#createUsersWithArrayInput")
e.printStackTrace()
} catch (e: ServerException) {
println("5xx response calling UserApi#createUsersWithArrayInput")
e.printStackTrace()
}
```
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**body** | [**kotlin.Array&lt;User&gt;**](User.md)| List of user object |
### Return type
null (empty response body)
### Authorization
No authorization required
### HTTP request headers
- **Content-Type**: Not defined
- **Accept**: Not defined
<a name="createUsersWithListInput"></a>
# **createUsersWithListInput**
> createUsersWithListInput(body)
Creates list of users with given input array
### Example
```kotlin
// Import classes:
//import org.openapitools.client.infrastructure.*
//import org.openapitools.client.models.*
val apiInstance = UserApi()
val body : kotlin.Array<User> = // kotlin.Array<User> | List of user object
try {
apiInstance.createUsersWithListInput(body)
} catch (e: ClientException) {
println("4xx response calling UserApi#createUsersWithListInput")
e.printStackTrace()
} catch (e: ServerException) {
println("5xx response calling UserApi#createUsersWithListInput")
e.printStackTrace()
}
```
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**body** | [**kotlin.Array&lt;User&gt;**](User.md)| List of user object |
### Return type
null (empty response body)
### Authorization
No authorization required
### HTTP request headers
- **Content-Type**: Not defined
- **Accept**: Not defined
<a name="deleteUser"></a>
# **deleteUser**
> deleteUser(username)
Delete user
This can only be done by the logged in user.
### Example
```kotlin
// Import classes:
//import org.openapitools.client.infrastructure.*
//import org.openapitools.client.models.*
val apiInstance = UserApi()
val username : kotlin.String = username_example // kotlin.String | The name that needs to be deleted
try {
apiInstance.deleteUser(username)
} catch (e: ClientException) {
println("4xx response calling UserApi#deleteUser")
e.printStackTrace()
} catch (e: ServerException) {
println("5xx response calling UserApi#deleteUser")
e.printStackTrace()
}
```
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**username** | **kotlin.String**| The name that needs to be deleted |
### Return type
null (empty response body)
### Authorization
No authorization required
### HTTP request headers
- **Content-Type**: Not defined
- **Accept**: Not defined
<a name="getUserByName"></a>
# **getUserByName**
> User getUserByName(username)
Get user by user name
### Example
```kotlin
// Import classes:
//import org.openapitools.client.infrastructure.*
//import org.openapitools.client.models.*
val apiInstance = UserApi()
val username : kotlin.String = username_example // kotlin.String | The name that needs to be fetched. Use user1 for testing.
try {
val result : User = apiInstance.getUserByName(username)
println(result)
} catch (e: ClientException) {
println("4xx response calling UserApi#getUserByName")
e.printStackTrace()
} catch (e: ServerException) {
println("5xx response calling UserApi#getUserByName")
e.printStackTrace()
}
```
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**username** | **kotlin.String**| The name that needs to be fetched. Use user1 for testing. |
### Return type
[**User**](User.md)
### Authorization
No authorization required
### HTTP request headers
- **Content-Type**: Not defined
- **Accept**: application/xml, application/json
<a name="loginUser"></a>
# **loginUser**
> kotlin.String loginUser(username, password)
Logs user into the system
### Example
```kotlin
// Import classes:
//import org.openapitools.client.infrastructure.*
//import org.openapitools.client.models.*
val apiInstance = UserApi()
val username : kotlin.String = username_example // kotlin.String | The user name for login
val password : kotlin.String = password_example // kotlin.String | The password for login in clear text
try {
val result : kotlin.String = apiInstance.loginUser(username, password)
println(result)
} catch (e: ClientException) {
println("4xx response calling UserApi#loginUser")
e.printStackTrace()
} catch (e: ServerException) {
println("5xx response calling UserApi#loginUser")
e.printStackTrace()
}
```
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**username** | **kotlin.String**| The user name for login |
**password** | **kotlin.String**| The password for login in clear text |
### Return type
**kotlin.String**
### Authorization
No authorization required
### HTTP request headers
- **Content-Type**: Not defined
- **Accept**: application/xml, application/json
<a name="logoutUser"></a>
# **logoutUser**
> logoutUser()
Logs out current logged in user session
### Example
```kotlin
// Import classes:
//import org.openapitools.client.infrastructure.*
//import org.openapitools.client.models.*
val apiInstance = UserApi()
try {
apiInstance.logoutUser()
} catch (e: ClientException) {
println("4xx response calling UserApi#logoutUser")
e.printStackTrace()
} catch (e: ServerException) {
println("5xx response calling UserApi#logoutUser")
e.printStackTrace()
}
```
### Parameters
This endpoint does not need any parameter.
### Return type
null (empty response body)
### Authorization
No authorization required
### HTTP request headers
- **Content-Type**: Not defined
- **Accept**: Not defined
<a name="updateUser"></a>
# **updateUser**
> updateUser(username, body)
Updated user
This can only be done by the logged in user.
### Example
```kotlin
// Import classes:
//import org.openapitools.client.infrastructure.*
//import org.openapitools.client.models.*
val apiInstance = UserApi()
val username : kotlin.String = username_example // kotlin.String | name that need to be deleted
val body : User = // User | Updated user object
try {
apiInstance.updateUser(username, body)
} catch (e: ClientException) {
println("4xx response calling UserApi#updateUser")
e.printStackTrace()
} catch (e: ServerException) {
println("5xx response calling UserApi#updateUser")
e.printStackTrace()
}
```
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**username** | **kotlin.String**| name that need to be deleted |
**body** | [**User**](User.md)| Updated user object |
### Return type
null (empty response body)
### Authorization
No authorization required
### HTTP request headers
- **Content-Type**: Not defined
- **Accept**: Not defined

View File

@ -0,0 +1,6 @@
#Tue May 17 23:08:05 CST 2016
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-bin.zip

View File

@ -0,0 +1,160 @@
#!/usr/bin/env bash
##############################################################################
##
## Gradle start up script for UN*X
##
##############################################################################
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS=""
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# 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
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
esac
# 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
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" ] ; 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, switch paths to Windows format before running java
if $cygwin ; 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=$((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
# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
function splitJvmOpts() {
JVM_OPTS=("$@")
}
eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"

View File

@ -0,0 +1,90 @@
@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
@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=
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@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 init
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 init
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
:init
@rem Get command-line arguments, handling Windows variants
if not "%OS%" == "Windows_NT" goto win9xME_args
if "%@eval[2+2]" == "4" goto 4NT_args
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
goto execute
:4NT_args
@rem Get arguments from the 4NT Shell from JP Software
set CMD_LINE_ARGS=%$
: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 %CMD_LINE_ARGS%
: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

View File

@ -0,0 +1,2 @@
enableFeaturePreview('GRADLE_METADATA')
rootProject.name = 'kotlin-client-petstore-multiplatform'

View File

@ -0,0 +1,365 @@
/**
* OpenAPI Petstore
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
*
* The version of the OpenAPI document: 1.0.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
package org.openapitools.client.apis
import org.openapitools.client.models.ApiResponse
import org.openapitools.client.models.Pet
import org.openapitools.client.infrastructure.*
import io.ktor.client.request.forms.formData
import kotlinx.serialization.UnstableDefault
import io.ktor.client.engine.HttpClientEngine
import io.ktor.client.features.json.serializer.KotlinxSerializer
import kotlinx.serialization.json.Json
import kotlinx.serialization.json.JsonConfiguration
import io.ktor.http.ParametersBuilder
import kotlinx.serialization.*
import kotlinx.serialization.internal.StringDescriptor
class PetApi @UseExperimental(UnstableDefault::class) constructor(
baseUrl: kotlin.String = "http://petstore.swagger.io/v2",
httpClientEngine: HttpClientEngine? = null,
serializer: KotlinxSerializer)
: ApiClient(baseUrl, httpClientEngine, serializer) {
@UseExperimental(UnstableDefault::class)
constructor(
baseUrl: kotlin.String = "http://petstore.swagger.io/v2",
httpClientEngine: HttpClientEngine? = null,
jsonConfiguration: JsonConfiguration = JsonConfiguration.Default)
: this(baseUrl, httpClientEngine, KotlinxSerializer(Json(jsonConfiguration)))
/**
* Add a new pet to the store
*
* @param body Pet object that needs to be added to the store
* @return void
*/
suspend fun addPet(body: Pet) : HttpResponse<Unit> {
val localVariableBody = body
val localVariableQuery = mutableMapOf<String, List<String>>()
val localVariableHeaders = mutableMapOf<String, String>()
val localVariableConfig = RequestConfig(
RequestMethod.POST,
"/pet",
query = localVariableQuery,
headers = localVariableHeaders
)
return jsonRequest(
localVariableConfig,
localVariableBody
).wrap()
}
/**
* Deletes a pet
*
* @param petId Pet id to delete
* @param apiKey (optional)
* @return void
*/
suspend fun deletePet(petId: kotlin.Long, apiKey: kotlin.String?) : HttpResponse<Unit> {
val localVariableBody =
io.ktor.client.utils.EmptyContent
val localVariableQuery = mutableMapOf<String, List<String>>()
val localVariableHeaders = mutableMapOf<String, String>()
apiKey?.apply { localVariableHeaders["api_key"] = this.toString() }
val localVariableConfig = RequestConfig(
RequestMethod.DELETE,
"/pet/{petId}".replace("{"+"petId"+"}", "$petId"),
query = localVariableQuery,
headers = localVariableHeaders
)
return request(
localVariableConfig,
localVariableBody
).wrap()
}
/**
* Finds Pets by status
* Multiple status values can be provided with comma separated strings
* @param status Status values that need to be considered for filter
* @return kotlin.Array<Pet>
*/
@Suppress("UNCHECKED_CAST")
suspend fun findPetsByStatus(status: kotlin.Array<kotlin.String>) : HttpResponse<kotlin.Array<Pet>> {
val localVariableBody =
io.ktor.client.utils.EmptyContent
val localVariableQuery = mutableMapOf<String, List<String>>()
status?.apply { localVariableQuery["status"] = toMultiValue(this, "csv") }
val localVariableHeaders = mutableMapOf<String, String>()
val localVariableConfig = RequestConfig(
RequestMethod.GET,
"/pet/findByStatus",
query = localVariableQuery,
headers = localVariableHeaders
)
return request(
localVariableConfig,
localVariableBody
).wrap<FindPetsByStatusResponse>().map { value.toTypedArray() }
}
@Serializable
private class FindPetsByStatusResponse(val value: List<Pet>) {
@Serializer(FindPetsByStatusResponse::class)
companion object : KSerializer<FindPetsByStatusResponse> {
private val serializer: KSerializer<List<Pet>> = Pet.serializer().list
override val descriptor = StringDescriptor.withName("FindPetsByStatusResponse")
override fun serialize(encoder: Encoder, obj: FindPetsByStatusResponse) = serializer.serialize(encoder, obj.value)
override fun deserialize(decoder: Decoder) = FindPetsByStatusResponse(serializer.deserialize(decoder))
}
}
/**
* Finds Pets by tags
* Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
* @param tags Tags to filter by
* @return kotlin.Array<Pet>
*/
@Suppress("UNCHECKED_CAST")
suspend fun findPetsByTags(tags: kotlin.Array<kotlin.String>) : HttpResponse<kotlin.Array<Pet>> {
val localVariableBody =
io.ktor.client.utils.EmptyContent
val localVariableQuery = mutableMapOf<String, List<String>>()
tags?.apply { localVariableQuery["tags"] = toMultiValue(this, "csv") }
val localVariableHeaders = mutableMapOf<String, String>()
val localVariableConfig = RequestConfig(
RequestMethod.GET,
"/pet/findByTags",
query = localVariableQuery,
headers = localVariableHeaders
)
return request(
localVariableConfig,
localVariableBody
).wrap<FindPetsByTagsResponse>().map { value.toTypedArray() }
}
@Serializable
private class FindPetsByTagsResponse(val value: List<Pet>) {
@Serializer(FindPetsByTagsResponse::class)
companion object : KSerializer<FindPetsByTagsResponse> {
private val serializer: KSerializer<List<Pet>> = Pet.serializer().list
override val descriptor = StringDescriptor.withName("FindPetsByTagsResponse")
override fun serialize(encoder: Encoder, obj: FindPetsByTagsResponse) = serializer.serialize(encoder, obj.value)
override fun deserialize(decoder: Decoder) = FindPetsByTagsResponse(serializer.deserialize(decoder))
}
}
/**
* Find pet by ID
* Returns a single pet
* @param petId ID of pet to return
* @return Pet
*/
@Suppress("UNCHECKED_CAST")
suspend fun getPetById(petId: kotlin.Long) : HttpResponse<Pet> {
val localVariableBody =
io.ktor.client.utils.EmptyContent
val localVariableQuery = mutableMapOf<String, List<String>>()
val localVariableHeaders = mutableMapOf<String, String>()
val localVariableConfig = RequestConfig(
RequestMethod.GET,
"/pet/{petId}".replace("{"+"petId"+"}", "$petId"),
query = localVariableQuery,
headers = localVariableHeaders
)
return request(
localVariableConfig,
localVariableBody
).wrap()
}
/**
* Update an existing pet
*
* @param body Pet object that needs to be added to the store
* @return void
*/
suspend fun updatePet(body: Pet) : HttpResponse<Unit> {
val localVariableBody = body
val localVariableQuery = mutableMapOf<String, List<String>>()
val localVariableHeaders = mutableMapOf<String, String>()
val localVariableConfig = RequestConfig(
RequestMethod.PUT,
"/pet",
query = localVariableQuery,
headers = localVariableHeaders
)
return jsonRequest(
localVariableConfig,
localVariableBody
).wrap()
}
/**
* Updates a pet in the store with form data
*
* @param petId ID of pet that needs to be updated
* @param name Updated name of the pet (optional)
* @param status Updated status of the pet (optional)
* @return void
*/
suspend fun updatePetWithForm(petId: kotlin.Long, name: kotlin.String?, status: kotlin.String?) : HttpResponse<Unit> {
val localVariableBody =
ParametersBuilder().also {
name?.apply { it.append("name", name) }
status?.apply { it.append("status", status) }
}.build()
val localVariableQuery = mutableMapOf<String, List<String>>()
val localVariableHeaders = mutableMapOf<String, String>()
val localVariableConfig = RequestConfig(
RequestMethod.POST,
"/pet/{petId}".replace("{"+"petId"+"}", "$petId"),
query = localVariableQuery,
headers = localVariableHeaders
)
return urlEncodedFormRequest(
localVariableConfig,
localVariableBody
).wrap()
}
/**
* uploads an image
*
* @param petId ID of pet to update
* @param additionalMetadata Additional data to pass to server (optional)
* @param file file to upload (optional)
* @return ApiResponse
*/
@Suppress("UNCHECKED_CAST")
suspend fun uploadFile(petId: kotlin.Long, additionalMetadata: kotlin.String?, file: io.ktor.client.request.forms.InputProvider?) : HttpResponse<ApiResponse> {
val localVariableBody =
formData {
additionalMetadata?.apply { append("additionalMetadata", additionalMetadata) }
file?.apply { append("file", file) }
}
val localVariableQuery = mutableMapOf<String, List<String>>()
val localVariableHeaders = mutableMapOf<String, String>()
val localVariableConfig = RequestConfig(
RequestMethod.POST,
"/pet/{petId}/uploadImage".replace("{"+"petId"+"}", "$petId"),
query = localVariableQuery,
headers = localVariableHeaders
)
return multipartFormRequest(
localVariableConfig,
localVariableBody
).wrap()
}
companion object {
internal fun setMappers(serializer: KotlinxSerializer) {
serializer.setMapper(FindPetsByStatusResponse::class, FindPetsByStatusResponse.serializer())
serializer.setMapper(FindPetsByTagsResponse::class, FindPetsByTagsResponse.serializer())
}
}
}

View File

@ -0,0 +1,196 @@
/**
* OpenAPI Petstore
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
*
* The version of the OpenAPI document: 1.0.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
package org.openapitools.client.apis
import org.openapitools.client.models.Order
import org.openapitools.client.infrastructure.*
import io.ktor.client.request.forms.formData
import kotlinx.serialization.UnstableDefault
import io.ktor.client.engine.HttpClientEngine
import io.ktor.client.features.json.serializer.KotlinxSerializer
import kotlinx.serialization.json.Json
import kotlinx.serialization.json.JsonConfiguration
import io.ktor.http.ParametersBuilder
import kotlinx.serialization.*
import kotlinx.serialization.internal.StringDescriptor
class StoreApi @UseExperimental(UnstableDefault::class) constructor(
baseUrl: kotlin.String = "http://petstore.swagger.io/v2",
httpClientEngine: HttpClientEngine? = null,
serializer: KotlinxSerializer)
: ApiClient(baseUrl, httpClientEngine, serializer) {
@UseExperimental(UnstableDefault::class)
constructor(
baseUrl: kotlin.String = "http://petstore.swagger.io/v2",
httpClientEngine: HttpClientEngine? = null,
jsonConfiguration: JsonConfiguration = JsonConfiguration.Default)
: this(baseUrl, httpClientEngine, KotlinxSerializer(Json(jsonConfiguration)))
/**
* Delete purchase order by ID
* For valid response try integer IDs with value &lt; 1000. Anything above 1000 or nonintegers will generate API errors
* @param orderId ID of the order that needs to be deleted
* @return void
*/
suspend fun deleteOrder(orderId: kotlin.String) : HttpResponse<Unit> {
val localVariableBody =
io.ktor.client.utils.EmptyContent
val localVariableQuery = mutableMapOf<String, List<String>>()
val localVariableHeaders = mutableMapOf<String, String>()
val localVariableConfig = RequestConfig(
RequestMethod.DELETE,
"/store/order/{orderId}".replace("{"+"orderId"+"}", "$orderId"),
query = localVariableQuery,
headers = localVariableHeaders
)
return request(
localVariableConfig,
localVariableBody
).wrap()
}
/**
* Returns pet inventories by status
* Returns a map of status codes to quantities
* @return kotlin.collections.Map<kotlin.String, kotlin.Int>
*/
@Suppress("UNCHECKED_CAST")
suspend fun getInventory() : HttpResponse<kotlin.collections.Map<kotlin.String, kotlin.Int>> {
val localVariableBody =
io.ktor.client.utils.EmptyContent
val localVariableQuery = mutableMapOf<String, List<String>>()
val localVariableHeaders = mutableMapOf<String, String>()
val localVariableConfig = RequestConfig(
RequestMethod.GET,
"/store/inventory",
query = localVariableQuery,
headers = localVariableHeaders
)
return request(
localVariableConfig,
localVariableBody
).wrap<GetInventoryResponse>().map { value }
}
@Serializable
private class GetInventoryResponse(val value: Map<kotlin.String, kotlin.Int>) {
@Serializer(GetInventoryResponse::class)
companion object : KSerializer<GetInventoryResponse> {
private val serializer: KSerializer<Map<kotlin.String, kotlin.Int>> = (kotlin.String.serializer() to kotlin.Int.serializer()).map
override val descriptor = StringDescriptor.withName("GetInventoryResponse")
override fun serialize(encoder: Encoder, obj: GetInventoryResponse) = serializer.serialize(encoder, obj.value)
override fun deserialize(decoder: Decoder) = GetInventoryResponse(serializer.deserialize(decoder))
}
}
/**
* Find purchase order by ID
* For valid response try integer IDs with value &lt;&#x3D; 5 or &gt; 10. Other values will generated exceptions
* @param orderId ID of pet that needs to be fetched
* @return Order
*/
@Suppress("UNCHECKED_CAST")
suspend fun getOrderById(orderId: kotlin.Long) : HttpResponse<Order> {
val localVariableBody =
io.ktor.client.utils.EmptyContent
val localVariableQuery = mutableMapOf<String, List<String>>()
val localVariableHeaders = mutableMapOf<String, String>()
val localVariableConfig = RequestConfig(
RequestMethod.GET,
"/store/order/{orderId}".replace("{"+"orderId"+"}", "$orderId"),
query = localVariableQuery,
headers = localVariableHeaders
)
return request(
localVariableConfig,
localVariableBody
).wrap()
}
/**
* Place an order for a pet
*
* @param body order placed for purchasing the pet
* @return Order
*/
@Suppress("UNCHECKED_CAST")
suspend fun placeOrder(body: Order) : HttpResponse<Order> {
val localVariableBody = body
val localVariableQuery = mutableMapOf<String, List<String>>()
val localVariableHeaders = mutableMapOf<String, String>()
val localVariableConfig = RequestConfig(
RequestMethod.POST,
"/store/order",
query = localVariableQuery,
headers = localVariableHeaders
)
return jsonRequest(
localVariableConfig,
localVariableBody
).wrap()
}
companion object {
internal fun setMappers(serializer: KotlinxSerializer) {
serializer.setMapper(GetInventoryResponse::class, GetInventoryResponse.serializer())
}
}
}

View File

@ -0,0 +1,350 @@
/**
* OpenAPI Petstore
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
*
* The version of the OpenAPI document: 1.0.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
package org.openapitools.client.apis
import org.openapitools.client.models.User
import org.openapitools.client.infrastructure.*
import io.ktor.client.request.forms.formData
import kotlinx.serialization.UnstableDefault
import io.ktor.client.engine.HttpClientEngine
import io.ktor.client.features.json.serializer.KotlinxSerializer
import kotlinx.serialization.json.Json
import kotlinx.serialization.json.JsonConfiguration
import io.ktor.http.ParametersBuilder
import kotlinx.serialization.*
import kotlinx.serialization.internal.StringDescriptor
class UserApi @UseExperimental(UnstableDefault::class) constructor(
baseUrl: kotlin.String = "http://petstore.swagger.io/v2",
httpClientEngine: HttpClientEngine? = null,
serializer: KotlinxSerializer)
: ApiClient(baseUrl, httpClientEngine, serializer) {
@UseExperimental(UnstableDefault::class)
constructor(
baseUrl: kotlin.String = "http://petstore.swagger.io/v2",
httpClientEngine: HttpClientEngine? = null,
jsonConfiguration: JsonConfiguration = JsonConfiguration.Default)
: this(baseUrl, httpClientEngine, KotlinxSerializer(Json(jsonConfiguration)))
/**
* Create user
* This can only be done by the logged in user.
* @param body Created user object
* @return void
*/
suspend fun createUser(body: User) : HttpResponse<Unit> {
val localVariableBody = body
val localVariableQuery = mutableMapOf<String, List<String>>()
val localVariableHeaders = mutableMapOf<String, String>()
val localVariableConfig = RequestConfig(
RequestMethod.POST,
"/user",
query = localVariableQuery,
headers = localVariableHeaders
)
return jsonRequest(
localVariableConfig,
localVariableBody
).wrap()
}
/**
* Creates list of users with given input array
*
* @param body List of user object
* @return void
*/
suspend fun createUsersWithArrayInput(body: kotlin.Array<User>) : HttpResponse<Unit> {
val localVariableBody = CreateUsersWithArrayInputRequest(body.asList())
val localVariableQuery = mutableMapOf<String, List<String>>()
val localVariableHeaders = mutableMapOf<String, String>()
val localVariableConfig = RequestConfig(
RequestMethod.POST,
"/user/createWithArray",
query = localVariableQuery,
headers = localVariableHeaders
)
return jsonRequest(
localVariableConfig,
localVariableBody
).wrap()
}
@Serializable
private class CreateUsersWithArrayInputRequest(val value: List<User>) {
@Serializer(CreateUsersWithArrayInputRequest::class)
companion object : KSerializer<CreateUsersWithArrayInputRequest> {
private val serializer: KSerializer<List<User>> = User.serializer().list
override val descriptor = StringDescriptor.withName("CreateUsersWithArrayInputRequest")
override fun serialize(encoder: Encoder, obj: CreateUsersWithArrayInputRequest) = serializer.serialize(encoder, obj.value)
override fun deserialize(decoder: Decoder) = CreateUsersWithArrayInputRequest(serializer.deserialize(decoder))
}
}
/**
* Creates list of users with given input array
*
* @param body List of user object
* @return void
*/
suspend fun createUsersWithListInput(body: kotlin.Array<User>) : HttpResponse<Unit> {
val localVariableBody = CreateUsersWithListInputRequest(body.asList())
val localVariableQuery = mutableMapOf<String, List<String>>()
val localVariableHeaders = mutableMapOf<String, String>()
val localVariableConfig = RequestConfig(
RequestMethod.POST,
"/user/createWithList",
query = localVariableQuery,
headers = localVariableHeaders
)
return jsonRequest(
localVariableConfig,
localVariableBody
).wrap()
}
@Serializable
private class CreateUsersWithListInputRequest(val value: List<User>) {
@Serializer(CreateUsersWithListInputRequest::class)
companion object : KSerializer<CreateUsersWithListInputRequest> {
private val serializer: KSerializer<List<User>> = User.serializer().list
override val descriptor = StringDescriptor.withName("CreateUsersWithListInputRequest")
override fun serialize(encoder: Encoder, obj: CreateUsersWithListInputRequest) = serializer.serialize(encoder, obj.value)
override fun deserialize(decoder: Decoder) = CreateUsersWithListInputRequest(serializer.deserialize(decoder))
}
}
/**
* Delete user
* This can only be done by the logged in user.
* @param username The name that needs to be deleted
* @return void
*/
suspend fun deleteUser(username: kotlin.String) : HttpResponse<Unit> {
val localVariableBody =
io.ktor.client.utils.EmptyContent
val localVariableQuery = mutableMapOf<String, List<String>>()
val localVariableHeaders = mutableMapOf<String, String>()
val localVariableConfig = RequestConfig(
RequestMethod.DELETE,
"/user/{username}".replace("{"+"username"+"}", "$username"),
query = localVariableQuery,
headers = localVariableHeaders
)
return request(
localVariableConfig,
localVariableBody
).wrap()
}
/**
* Get user by user name
*
* @param username The name that needs to be fetched. Use user1 for testing.
* @return User
*/
@Suppress("UNCHECKED_CAST")
suspend fun getUserByName(username: kotlin.String) : HttpResponse<User> {
val localVariableBody =
io.ktor.client.utils.EmptyContent
val localVariableQuery = mutableMapOf<String, List<String>>()
val localVariableHeaders = mutableMapOf<String, String>()
val localVariableConfig = RequestConfig(
RequestMethod.GET,
"/user/{username}".replace("{"+"username"+"}", "$username"),
query = localVariableQuery,
headers = localVariableHeaders
)
return request(
localVariableConfig,
localVariableBody
).wrap()
}
/**
* Logs user into the system
*
* @param username The user name for login
* @param password The password for login in clear text
* @return kotlin.String
*/
@Suppress("UNCHECKED_CAST")
suspend fun loginUser(username: kotlin.String, password: kotlin.String) : HttpResponse<kotlin.String> {
val localVariableBody =
io.ktor.client.utils.EmptyContent
val localVariableQuery = mutableMapOf<String, List<String>>()
username?.apply { localVariableQuery["username"] = listOf("$username") }
password?.apply { localVariableQuery["password"] = listOf("$password") }
val localVariableHeaders = mutableMapOf<String, String>()
val localVariableConfig = RequestConfig(
RequestMethod.GET,
"/user/login",
query = localVariableQuery,
headers = localVariableHeaders
)
return request(
localVariableConfig,
localVariableBody
).wrap()
}
/**
* Logs out current logged in user session
*
* @return void
*/
suspend fun logoutUser() : HttpResponse<Unit> {
val localVariableBody =
io.ktor.client.utils.EmptyContent
val localVariableQuery = mutableMapOf<String, List<String>>()
val localVariableHeaders = mutableMapOf<String, String>()
val localVariableConfig = RequestConfig(
RequestMethod.GET,
"/user/logout",
query = localVariableQuery,
headers = localVariableHeaders
)
return request(
localVariableConfig,
localVariableBody
).wrap()
}
/**
* Updated user
* This can only be done by the logged in user.
* @param username name that need to be deleted
* @param body Updated user object
* @return void
*/
suspend fun updateUser(username: kotlin.String, body: User) : HttpResponse<Unit> {
val localVariableBody = body
val localVariableQuery = mutableMapOf<String, List<String>>()
val localVariableHeaders = mutableMapOf<String, String>()
val localVariableConfig = RequestConfig(
RequestMethod.PUT,
"/user/{username}".replace("{"+"username"+"}", "$username"),
query = localVariableQuery,
headers = localVariableHeaders
)
return jsonRequest(
localVariableConfig,
localVariableBody
).wrap()
}
companion object {
internal fun setMappers(serializer: KotlinxSerializer) {
serializer.setMapper(CreateUsersWithArrayInputRequest::class, CreateUsersWithArrayInputRequest.serializer())
serializer.setMapper(CreateUsersWithListInputRequest::class, CreateUsersWithListInputRequest.serializer())
}
}
}

View File

@ -0,0 +1,23 @@
package org.openapitools.client.infrastructure
typealias MultiValueMap = Map<String,List<String>>
fun collectionDelimiter(collectionFormat: String) = when(collectionFormat) {
"csv" -> ","
"tsv" -> "\t"
"pipes" -> "|"
"ssv" -> " "
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))
}
}

View File

@ -0,0 +1,129 @@
package org.openapitools.client.infrastructure
import io.ktor.client.HttpClient
import io.ktor.client.HttpClientConfig
import io.ktor.client.call.call
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.accept
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.response.HttpResponse
import io.ktor.client.utils.EmptyContent
import io.ktor.http.*
import io.ktor.http.content.OutgoingContent
import io.ktor.http.content.PartData
import kotlinx.serialization.UnstableDefault
import kotlinx.serialization.json.Json
import kotlinx.serialization.json.JsonConfiguration
import org.openapitools.client.apis.*
import org.openapitools.client.models.*
open class ApiClient(
private val baseUrl: String,
httpClientEngine: HttpClientEngine?,
serializer: KotlinxSerializer) {
@UseExperimental(UnstableDefault::class)
constructor(
baseUrl: String,
httpClientEngine: HttpClientEngine?,
jsonConfiguration: JsonConfiguration) :
this(baseUrl, httpClientEngine, KotlinxSerializer(Json(jsonConfiguration)))
private val serializer: JsonSerializer by lazy {
serializer.apply { setMappers(this) }.ignoreOutgoingContent()
}
private val client: HttpClient by lazy {
val jsonConfig: JsonFeature.Config.() -> Unit = { this.serializer = this@ApiClient.serializer }
val clientConfig: (HttpClientConfig<*>) -> Unit = { it.install(JsonFeature, jsonConfig) }
httpClientEngine?.let { HttpClient(it, clientConfig) } ?: HttpClient(clientConfig)
}
companion object {
protected val UNSAFE_HEADERS = listOf(HttpHeaders.ContentType)
private fun setMappers(serializer: KotlinxSerializer) {
PetApi.setMappers(serializer)
StoreApi.setMappers(serializer)
UserApi.setMappers(serializer)
serializer.setMapper(ApiResponse::class, ApiResponse.serializer())
serializer.setMapper(Category::class, Category.serializer())
serializer.setMapper(Order::class, Order.serializer())
serializer.setMapper(Pet::class, Pet.serializer())
serializer.setMapper(Tag::class, Tag.serializer())
serializer.setMapper(User::class, User.serializer())
}
}
protected suspend fun multipartFormRequest(requestConfig: RequestConfig, body: List<PartData>?): HttpResponse {
return request(requestConfig, MultiPartFormDataContent(body ?: listOf()))
}
protected suspend fun urlEncodedFormRequest(requestConfig: RequestConfig, body: Parameters?): HttpResponse {
return request(requestConfig, FormDataContent(body ?: Parameters.Empty))
}
protected suspend fun jsonRequest(requestConfig: RequestConfig, body: Any? = null): HttpResponse {
val contentType = (requestConfig.headers[HttpHeaders.ContentType]?.let { ContentType.parse(it) }
?: ContentType.Application.Json)
return if (body != null) request(requestConfig, serializer.write(body, contentType))
else request(requestConfig)
}
protected suspend fun request(requestConfig: RequestConfig, body: OutgoingContent = EmptyContent): HttpResponse {
val headers = requestConfig.headers
return client.call {
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
}.response
}
private fun URLBuilder.appendPath(components: 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)
}
}

View File

@ -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.response.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.response.HttpResponse): T
suspend fun <V : Any> typedBody(response: io.ktor.client.response.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.response.HttpResponse): T =
response.call.receive(type) as T
@Suppress("UNCHECKED_CAST")
override suspend fun <V : Any> typedBody(response: io.ktor.client.response.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.response.HttpResponse): T =
block(provider.body(response))
override suspend fun <V : Any> typedBody(response: io.ktor.client.response.HttpResponse, type: TypeInfo): V =
provider.typedBody(response, type)
}
inline fun <reified T : Any> io.ktor.client.response.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))

View File

@ -0,0 +1,16 @@
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(
val method: RequestMethod,
val path: String,
val headers: MutableMap<String, String> = mutableMapOf(),
val query: Map<String, List<String>> = mapOf()
)

View File

@ -0,0 +1,8 @@
package org.openapitools.client.infrastructure
/**
* Provides enumerated HTTP verbs
*/
enum class RequestMethod {
GET, DELETE, HEAD, OPTIONS, PATCH, POST, PUT
}

View File

@ -0,0 +1,30 @@
/**
* OpenAPI Petstore
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
*
* The version of the OpenAPI document: 1.0.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
package org.openapitools.client.models
import kotlinx.serialization.*
import kotlinx.serialization.internal.CommonEnumSerializer
/**
* Describes the result of uploading an image resource
* @param code
* @param type
* @param message
*/
@Serializable
data class ApiResponse (
@SerialName(value = "code") val code: kotlin.Int? = null,
@SerialName(value = "type") val type: kotlin.String? = null,
@SerialName(value = "message") val message: kotlin.String? = null
)

View File

@ -0,0 +1,28 @@
/**
* OpenAPI Petstore
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
*
* The version of the OpenAPI document: 1.0.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
package org.openapitools.client.models
import kotlinx.serialization.*
import kotlinx.serialization.internal.CommonEnumSerializer
/**
* A category for a pet
* @param id
* @param name
*/
@Serializable
data class Category (
@SerialName(value = "id") val id: kotlin.Long? = null,
@SerialName(value = "name") val name: kotlin.String? = null
)

View File

@ -0,0 +1,56 @@
/**
* OpenAPI Petstore
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
*
* The version of the OpenAPI document: 1.0.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
package org.openapitools.client.models
import kotlinx.serialization.*
import kotlinx.serialization.internal.CommonEnumSerializer
/**
* An order for a pets from the pet store
* @param id
* @param petId
* @param quantity
* @param shipDate
* @param status Order Status
* @param complete
*/
@Serializable
data class Order (
@SerialName(value = "id") val id: kotlin.Long? = null,
@SerialName(value = "petId") val petId: kotlin.Long? = null,
@SerialName(value = "quantity") val quantity: kotlin.Int? = null,
@SerialName(value = "shipDate") val shipDate: kotlin.String? = null,
/* Order Status */
@SerialName(value = "status") val status: Order.Status? = null,
@SerialName(value = "complete") val complete: kotlin.Boolean? = null
)
{
/**
* Order Status
* Values: placed,approved,delivered
*/
@Serializable(with = Status.Serializer::class)
enum class Status(val value: kotlin.String){
placed("placed"),
approved("approved"),
delivered("delivered");
object Serializer : CommonEnumSerializer<Status>("Status", values(), values().map { it.value }.toTypedArray())
}
}

View File

@ -0,0 +1,58 @@
/**
* OpenAPI Petstore
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
*
* The version of the OpenAPI document: 1.0.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
package org.openapitools.client.models
import org.openapitools.client.models.Category
import org.openapitools.client.models.Tag
import kotlinx.serialization.*
import kotlinx.serialization.internal.CommonEnumSerializer
/**
* A pet for sale in the pet store
* @param id
* @param category
* @param name
* @param photoUrls
* @param tags
* @param status pet status in the store
*/
@Serializable
data class Pet (
@SerialName(value = "name") @Required val name: kotlin.String,
@SerialName(value = "photoUrls") @Required val photoUrls: kotlin.Array<kotlin.String>,
@SerialName(value = "id") val id: kotlin.Long? = null,
@SerialName(value = "category") val category: Category? = null,
@SerialName(value = "tags") val tags: kotlin.Array<Tag>? = null,
/* pet status in the store */
@SerialName(value = "status") val status: Pet.Status? = null
)
{
/**
* pet status in the store
* Values: available,pending,sold
*/
@Serializable(with = Status.Serializer::class)
enum class Status(val value: kotlin.String){
available("available"),
pending("pending"),
sold("sold");
object Serializer : CommonEnumSerializer<Status>("Status", values(), values().map { it.value }.toTypedArray())
}
}

View File

@ -0,0 +1,28 @@
/**
* OpenAPI Petstore
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
*
* The version of the OpenAPI document: 1.0.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
package org.openapitools.client.models
import kotlinx.serialization.*
import kotlinx.serialization.internal.CommonEnumSerializer
/**
* A tag for a pet
* @param id
* @param name
*/
@Serializable
data class Tag (
@SerialName(value = "id") val id: kotlin.Long? = null,
@SerialName(value = "name") val name: kotlin.String? = null
)

View File

@ -0,0 +1,41 @@
/**
* OpenAPI Petstore
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
*
* The version of the OpenAPI document: 1.0.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
package org.openapitools.client.models
import kotlinx.serialization.*
import kotlinx.serialization.internal.CommonEnumSerializer
/**
* A User who is purchasing from the pet store
* @param id
* @param username
* @param firstName
* @param lastName
* @param email
* @param password
* @param phone
* @param userStatus User Status
*/
@Serializable
data class User (
@SerialName(value = "id") val id: kotlin.Long? = null,
@SerialName(value = "username") val username: kotlin.String? = null,
@SerialName(value = "firstName") val firstName: kotlin.String? = null,
@SerialName(value = "lastName") val lastName: kotlin.String? = null,
@SerialName(value = "email") val email: kotlin.String? = null,
@SerialName(value = "password") val password: kotlin.String? = null,
@SerialName(value = "phone") val phone: kotlin.String? = null,
/* User Status */
@SerialName(value = "userStatus") val userStatus: kotlin.Int? = null
)

View File

@ -0,0 +1,23 @@
/**
* OpenAPI Petstore
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
*
* The version of the OpenAPI document: 1.0.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
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

View File

@ -0,0 +1,18 @@
/**
* OpenAPI Petstore
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
*
* The version of the OpenAPI document: 1.0.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
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)

View File

@ -0,0 +1,18 @@
/**
* OpenAPI Petstore
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
*
* The version of the OpenAPI document: 1.0.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
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)

View File

@ -1 +1,2 @@
rootProject.name = 'kotlin-petstore-string'

View File

@ -12,9 +12,12 @@ fun collectionDelimiter(collectionFormat: String) = when(collectionFormat) {
val defaultMultiValueConverter: (item: Any?) -> String = { item -> "$item" }
fun <T: Any?> toMultiValue(items: List<T>, collectionFormat: String, map: (item: Any?) -> String = defaultMultiValueConverter): List<String> {
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.map(map).joinToString(separator = collectionDelimiter(collectionFormat)))
else -> listOf(items.joinToString(separator = collectionDelimiter(collectionFormat), transform = map))
}
}

View File

@ -19,6 +19,7 @@ import com.squareup.moshi.Json
* @param type
* @param message
*/
data class ApiResponse (
@Json(name = "code")
val code: kotlin.Int? = null,
@ -28,4 +29,3 @@ data class ApiResponse (
val message: kotlin.String? = null
)

View File

@ -18,6 +18,7 @@ import com.squareup.moshi.Json
* @param id
* @param name
*/
data class Category (
@Json(name = "id")
val id: kotlin.Long? = null,
@ -25,4 +26,3 @@ data class Category (
val name: kotlin.String? = null
)

View File

@ -22,6 +22,7 @@ import com.squareup.moshi.Json
* @param status Order Status
* @param complete
*/
data class Order (
@Json(name = "id")
val id: kotlin.Long? = null,
@ -37,12 +38,13 @@ data class Order (
@Json(name = "complete")
val complete: kotlin.Boolean? = null
)
{
/**
* Order Status
* Values: placed,approved,delivered
*/
enum class Status(val value: kotlin.String){
@Json(name = "placed") placed("placed"),
@ -51,7 +53,8 @@ data class Order (
@Json(name = "delivered") delivered("delivered");
}
}

View File

@ -24,6 +24,7 @@ import com.squareup.moshi.Json
* @param tags
* @param status pet status in the store
*/
data class Pet (
@Json(name = "name")
val name: kotlin.String,
@ -39,12 +40,13 @@ data class Pet (
@Json(name = "status")
val status: Pet.Status? = null
)
{
/**
* pet status in the store
* Values: available,pending,sold
*/
enum class Status(val value: kotlin.String){
@Json(name = "available") available("available"),
@ -53,7 +55,8 @@ data class Pet (
@Json(name = "sold") sold("sold");
}
}

View File

@ -18,6 +18,7 @@ import com.squareup.moshi.Json
* @param id
* @param name
*/
data class Tag (
@Json(name = "id")
val id: kotlin.Long? = null,
@ -25,4 +26,3 @@ data class Tag (
val name: kotlin.String? = null
)

View File

@ -24,6 +24,7 @@ import com.squareup.moshi.Json
* @param phone
* @param userStatus User Status
*/
data class User (
@Json(name = "id")
val id: kotlin.Long? = null,
@ -44,4 +45,3 @@ data class User (
val userStatus: kotlin.Int? = null
)

View File

@ -1 +1,2 @@
rootProject.name = 'kotlin-petstore-threetenbp'

View File

@ -12,9 +12,12 @@ fun collectionDelimiter(collectionFormat: String) = when(collectionFormat) {
val defaultMultiValueConverter: (item: Any?) -> String = { item -> "$item" }
fun <T: Any?> toMultiValue(items: List<T>, collectionFormat: String, map: (item: Any?) -> String = defaultMultiValueConverter): List<String> {
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.map(map).joinToString(separator = collectionDelimiter(collectionFormat)))
else -> listOf(items.joinToString(separator = collectionDelimiter(collectionFormat), transform = map))
}
}

View File

@ -19,6 +19,7 @@ import com.squareup.moshi.Json
* @param type
* @param message
*/
data class ApiResponse (
@Json(name = "code")
val code: kotlin.Int? = null,
@ -28,4 +29,3 @@ data class ApiResponse (
val message: kotlin.String? = null
)

View File

@ -18,6 +18,7 @@ import com.squareup.moshi.Json
* @param id
* @param name
*/
data class Category (
@Json(name = "id")
val id: kotlin.Long? = null,
@ -25,4 +26,3 @@ data class Category (
val name: kotlin.String? = null
)

View File

@ -22,6 +22,7 @@ import com.squareup.moshi.Json
* @param status Order Status
* @param complete
*/
data class Order (
@Json(name = "id")
val id: kotlin.Long? = null,
@ -37,12 +38,13 @@ data class Order (
@Json(name = "complete")
val complete: kotlin.Boolean? = null
)
{
/**
* Order Status
* Values: placed,approved,delivered
*/
enum class Status(val value: kotlin.String){
@Json(name = "placed") placed("placed"),
@ -51,7 +53,8 @@ data class Order (
@Json(name = "delivered") delivered("delivered");
}
}

View File

@ -24,6 +24,7 @@ import com.squareup.moshi.Json
* @param tags
* @param status pet status in the store
*/
data class Pet (
@Json(name = "name")
val name: kotlin.String,
@ -39,12 +40,13 @@ data class Pet (
@Json(name = "status")
val status: Pet.Status? = null
)
{
/**
* pet status in the store
* Values: available,pending,sold
*/
enum class Status(val value: kotlin.String){
@Json(name = "available") available("available"),
@ -53,7 +55,8 @@ data class Pet (
@Json(name = "sold") sold("sold");
}
}

View File

@ -18,6 +18,7 @@ import com.squareup.moshi.Json
* @param id
* @param name
*/
data class Tag (
@Json(name = "id")
val id: kotlin.Long? = null,
@ -25,4 +26,3 @@ data class Tag (
val name: kotlin.String? = null
)

View File

@ -24,6 +24,7 @@ import com.squareup.moshi.Json
* @param phone
* @param userStatus User Status
*/
data class User (
@Json(name = "id")
val id: kotlin.Long? = null,
@ -44,4 +45,3 @@ data class User (
val userStatus: kotlin.Int? = null
)

View File

@ -1 +1,2 @@
rootProject.name = 'kotlin-petstore-client'

View File

@ -12,9 +12,12 @@ fun collectionDelimiter(collectionFormat: String) = when(collectionFormat) {
val defaultMultiValueConverter: (item: Any?) -> String = { item -> "$item" }
fun <T: Any?> toMultiValue(items: List<T>, collectionFormat: String, map: (item: Any?) -> String = defaultMultiValueConverter): List<String> {
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.map(map).joinToString(separator = collectionDelimiter(collectionFormat)))
else -> listOf(items.joinToString(separator = collectionDelimiter(collectionFormat), transform = map))
}
}

View File

@ -19,6 +19,7 @@ import com.squareup.moshi.Json
* @param type
* @param message
*/
data class ApiResponse (
@Json(name = "code")
val code: kotlin.Int? = null,
@ -28,4 +29,3 @@ data class ApiResponse (
val message: kotlin.String? = null
)

View File

@ -18,6 +18,7 @@ import com.squareup.moshi.Json
* @param id
* @param name
*/
data class Category (
@Json(name = "id")
val id: kotlin.Long? = null,
@ -25,4 +26,3 @@ data class Category (
val name: kotlin.String? = null
)

View File

@ -22,6 +22,7 @@ import com.squareup.moshi.Json
* @param status Order Status
* @param complete
*/
data class Order (
@Json(name = "id")
val id: kotlin.Long? = null,
@ -37,12 +38,13 @@ data class Order (
@Json(name = "complete")
val complete: kotlin.Boolean? = null
)
{
/**
* Order Status
* Values: placed,approved,delivered
*/
enum class Status(val value: kotlin.String){
@Json(name = "placed") placed("placed"),
@ -51,7 +53,8 @@ data class Order (
@Json(name = "delivered") delivered("delivered");
}
}

View File

@ -24,6 +24,7 @@ import com.squareup.moshi.Json
* @param tags
* @param status pet status in the store
*/
data class Pet (
@Json(name = "name")
val name: kotlin.String,
@ -39,12 +40,13 @@ data class Pet (
@Json(name = "status")
val status: Pet.Status? = null
)
{
/**
* pet status in the store
* Values: available,pending,sold
*/
enum class Status(val value: kotlin.String){
@Json(name = "available") available("available"),
@ -53,7 +55,8 @@ data class Pet (
@Json(name = "sold") sold("sold");
}
}

View File

@ -18,6 +18,7 @@ import com.squareup.moshi.Json
* @param id
* @param name
*/
data class Tag (
@Json(name = "id")
val id: kotlin.Long? = null,
@ -25,4 +26,3 @@ data class Tag (
val name: kotlin.String? = null
)

View File

@ -24,6 +24,7 @@ import com.squareup.moshi.Json
* @param phone
* @param userStatus User Status
*/
data class User (
@Json(name = "id")
val id: kotlin.Long? = null,
@ -44,4 +45,3 @@ data class User (
val userStatus: kotlin.Int? = null
)

View File

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

View File

@ -0,0 +1 @@
4.1.3-SNAPSHOT

View File

@ -0,0 +1,158 @@
# org.openapitools.client - Kotlin client library for OpenAPI Petstore
## Requires
* Kotlin 1.3.50
## 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://petstore.swagger.io:80/v2*
Class | Method | HTTP request | Description
------------ | ------------- | ------------- | -------------
*AnotherFakeApi* | [**call123testSpecialTags**](docs/AnotherFakeApi.md#call123testspecialtags) | **PATCH** /another-fake/dummy | To test special tags
*DefaultApi* | [**fooGet**](docs/DefaultApi.md#fooget) | **GET** /foo |
*FakeApi* | [**fakeHealthGet**](docs/FakeApi.md#fakehealthget) | **GET** /fake/health | Health check endpoint
*FakeApi* | [**fakeOuterBooleanSerialize**](docs/FakeApi.md#fakeouterbooleanserialize) | **POST** /fake/outer/boolean |
*FakeApi* | [**fakeOuterCompositeSerialize**](docs/FakeApi.md#fakeoutercompositeserialize) | **POST** /fake/outer/composite |
*FakeApi* | [**fakeOuterNumberSerialize**](docs/FakeApi.md#fakeouternumberserialize) | **POST** /fake/outer/number |
*FakeApi* | [**fakeOuterStringSerialize**](docs/FakeApi.md#fakeouterstringserialize) | **POST** /fake/outer/string |
*FakeApi* | [**testBodyWithFileSchema**](docs/FakeApi.md#testbodywithfileschema) | **PUT** /fake/body-with-file-schema |
*FakeApi* | [**testBodyWithQueryParams**](docs/FakeApi.md#testbodywithqueryparams) | **PUT** /fake/body-with-query-params |
*FakeApi* | [**testClientModel**](docs/FakeApi.md#testclientmodel) | **PATCH** /fake | To test \"client\" model
*FakeApi* | [**testEndpointParameters**](docs/FakeApi.md#testendpointparameters) | **POST** /fake | Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
*FakeApi* | [**testEnumParameters**](docs/FakeApi.md#testenumparameters) | **GET** /fake | To test enum parameters
*FakeApi* | [**testGroupParameters**](docs/FakeApi.md#testgroupparameters) | **DELETE** /fake | Fake endpoint to test group parameters (optional)
*FakeApi* | [**testInlineAdditionalProperties**](docs/FakeApi.md#testinlineadditionalproperties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties
*FakeApi* | [**testJsonFormData**](docs/FakeApi.md#testjsonformdata) | **GET** /fake/jsonFormData | test json serialization of form data
*FakeApi* | [**testQueryParameterCollectionFormat**](docs/FakeApi.md#testqueryparametercollectionformat) | **PUT** /fake/test-query-paramters |
*FakeClassnameTags123Api* | [**testClassname**](docs/FakeClassnameTags123Api.md#testclassname) | **PATCH** /fake_classname_test | To test class name in snake case
*PetApi* | [**addPet**](docs/PetApi.md#addpet) | **POST** /pet | Add a new pet to the store
*PetApi* | [**deletePet**](docs/PetApi.md#deletepet) | **DELETE** /pet/{petId} | Deletes a pet
*PetApi* | [**findPetsByStatus**](docs/PetApi.md#findpetsbystatus) | **GET** /pet/findByStatus | Finds Pets by status
*PetApi* | [**findPetsByTags**](docs/PetApi.md#findpetsbytags) | **GET** /pet/findByTags | Finds Pets by tags
*PetApi* | [**getPetById**](docs/PetApi.md#getpetbyid) | **GET** /pet/{petId} | Find pet by ID
*PetApi* | [**updatePet**](docs/PetApi.md#updatepet) | **PUT** /pet | Update an existing pet
*PetApi* | [**updatePetWithForm**](docs/PetApi.md#updatepetwithform) | **POST** /pet/{petId} | Updates a pet in the store with form data
*PetApi* | [**uploadFile**](docs/PetApi.md#uploadfile) | **POST** /pet/{petId}/uploadImage | uploads an image
*PetApi* | [**uploadFileWithRequiredFile**](docs/PetApi.md#uploadfilewithrequiredfile) | **POST** /fake/{petId}/uploadImageWithRequiredFile | uploads an image (required)
*StoreApi* | [**deleteOrder**](docs/StoreApi.md#deleteorder) | **DELETE** /store/order/{order_id} | Delete purchase order by ID
*StoreApi* | [**getInventory**](docs/StoreApi.md#getinventory) | **GET** /store/inventory | Returns pet inventories by status
*StoreApi* | [**getOrderById**](docs/StoreApi.md#getorderbyid) | **GET** /store/order/{order_id} | Find purchase order by ID
*StoreApi* | [**placeOrder**](docs/StoreApi.md#placeorder) | **POST** /store/order | Place an order for a pet
*UserApi* | [**createUser**](docs/UserApi.md#createuser) | **POST** /user | Create user
*UserApi* | [**createUsersWithArrayInput**](docs/UserApi.md#createuserswitharrayinput) | **POST** /user/createWithArray | Creates list of users with given input array
*UserApi* | [**createUsersWithListInput**](docs/UserApi.md#createuserswithlistinput) | **POST** /user/createWithList | Creates list of users with given input array
*UserApi* | [**deleteUser**](docs/UserApi.md#deleteuser) | **DELETE** /user/{username} | Delete user
*UserApi* | [**getUserByName**](docs/UserApi.md#getuserbyname) | **GET** /user/{username} | Get user by user name
*UserApi* | [**loginUser**](docs/UserApi.md#loginuser) | **GET** /user/login | Logs user into the system
*UserApi* | [**logoutUser**](docs/UserApi.md#logoutuser) | **GET** /user/logout | Logs out current logged in user session
*UserApi* | [**updateUser**](docs/UserApi.md#updateuser) | **PUT** /user/{username} | Updated user
<a name="documentation-for-models"></a>
## Documentation for Models
- [org.openapitools.client.models.AdditionalPropertiesClass](docs/AdditionalPropertiesClass.md)
- [org.openapitools.client.models.Animal](docs/Animal.md)
- [org.openapitools.client.models.ApiResponse](docs/ApiResponse.md)
- [org.openapitools.client.models.ArrayOfArrayOfNumberOnly](docs/ArrayOfArrayOfNumberOnly.md)
- [org.openapitools.client.models.ArrayOfNumberOnly](docs/ArrayOfNumberOnly.md)
- [org.openapitools.client.models.ArrayTest](docs/ArrayTest.md)
- [org.openapitools.client.models.Capitalization](docs/Capitalization.md)
- [org.openapitools.client.models.Cat](docs/Cat.md)
- [org.openapitools.client.models.CatAllOf](docs/CatAllOf.md)
- [org.openapitools.client.models.Category](docs/Category.md)
- [org.openapitools.client.models.ClassModel](docs/ClassModel.md)
- [org.openapitools.client.models.Client](docs/Client.md)
- [org.openapitools.client.models.Dog](docs/Dog.md)
- [org.openapitools.client.models.DogAllOf](docs/DogAllOf.md)
- [org.openapitools.client.models.EnumArrays](docs/EnumArrays.md)
- [org.openapitools.client.models.EnumClass](docs/EnumClass.md)
- [org.openapitools.client.models.EnumTest](docs/EnumTest.md)
- [org.openapitools.client.models.FileSchemaTestClass](docs/FileSchemaTestClass.md)
- [org.openapitools.client.models.Foo](docs/Foo.md)
- [org.openapitools.client.models.FormatTest](docs/FormatTest.md)
- [org.openapitools.client.models.HasOnlyReadOnly](docs/HasOnlyReadOnly.md)
- [org.openapitools.client.models.HealthCheckResult](docs/HealthCheckResult.md)
- [org.openapitools.client.models.InlineObject](docs/InlineObject.md)
- [org.openapitools.client.models.InlineObject1](docs/InlineObject1.md)
- [org.openapitools.client.models.InlineObject2](docs/InlineObject2.md)
- [org.openapitools.client.models.InlineObject3](docs/InlineObject3.md)
- [org.openapitools.client.models.InlineObject4](docs/InlineObject4.md)
- [org.openapitools.client.models.InlineObject5](docs/InlineObject5.md)
- [org.openapitools.client.models.InlineResponseDefault](docs/InlineResponseDefault.md)
- [org.openapitools.client.models.List](docs/List.md)
- [org.openapitools.client.models.MapTest](docs/MapTest.md)
- [org.openapitools.client.models.MixedPropertiesAndAdditionalPropertiesClass](docs/MixedPropertiesAndAdditionalPropertiesClass.md)
- [org.openapitools.client.models.Model200Response](docs/Model200Response.md)
- [org.openapitools.client.models.Name](docs/Name.md)
- [org.openapitools.client.models.NullableClass](docs/NullableClass.md)
- [org.openapitools.client.models.NumberOnly](docs/NumberOnly.md)
- [org.openapitools.client.models.Order](docs/Order.md)
- [org.openapitools.client.models.OuterComposite](docs/OuterComposite.md)
- [org.openapitools.client.models.OuterEnum](docs/OuterEnum.md)
- [org.openapitools.client.models.OuterEnumDefaultValue](docs/OuterEnumDefaultValue.md)
- [org.openapitools.client.models.OuterEnumInteger](docs/OuterEnumInteger.md)
- [org.openapitools.client.models.OuterEnumIntegerDefaultValue](docs/OuterEnumIntegerDefaultValue.md)
- [org.openapitools.client.models.Pet](docs/Pet.md)
- [org.openapitools.client.models.ReadOnlyFirst](docs/ReadOnlyFirst.md)
- [org.openapitools.client.models.Return](docs/Return.md)
- [org.openapitools.client.models.SpecialModelname](docs/SpecialModelname.md)
- [org.openapitools.client.models.Tag](docs/Tag.md)
- [org.openapitools.client.models.User](docs/User.md)
<a name="documentation-for-authorization"></a>
## Documentation for Authorization
<a name="api_key"></a>
### api_key
- **Type**: API key
- **API key parameter name**: api_key
- **Location**: HTTP header
<a name="api_key_query"></a>
### api_key_query
- **Type**: API key
- **API key parameter name**: api_key_query
- **Location**: URL query string
<a name="bearer_test"></a>
### bearer_test
- **Type**: HTTP basic authentication
<a name="http_basic_test"></a>
### http_basic_test
- **Type**: HTTP basic authentication
<a name="petstore_auth"></a>
### petstore_auth
- **Type**: OAuth
- **Flow**: implicit
- **Authorization URL**: http://petstore.swagger.io/api/oauth/dialog
- **Scopes**:
- write:pets: modify pets in your account
- read:pets: read your pets

View File

@ -0,0 +1,138 @@
apply plugin: 'kotlin-multiplatform'
apply plugin: 'kotlinx-serialization'
group 'org.openapitools'
version '1.0.0'
ext {
kotlin_version = '1.3.50'
kotlinx_version = '1.1.0'
coroutines_version = '1.3.1'
serialization_version = '0.12.0'
ktor_version = '1.2.4'
}
buildscript {
repositories {
jcenter()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.50" // $kotlin_version
classpath "org.jetbrains.kotlin:kotlin-serialization:1.3.50" // $kotlin_version
}
}
repositories {
jcenter()
}
kotlin {
jvm()
iosArm64() { binaries { framework { freeCompilerArgs.add("-Xobjc-generics") } } }
iosX64() { binaries { framework { freeCompilerArgs.add("-Xobjc-generics") } } }
sourceSets {
commonMain {
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-common:$kotlin_version"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core-common:$coroutines_version"
implementation "org.jetbrains.kotlinx:kotlinx-serialization-runtime-common:$serialization_version"
implementation "io.ktor:ktor-client-core:$ktor_version"
implementation "io.ktor:ktor-client-json:$ktor_version"
implementation "io.ktor:ktor-client-serialization:$ktor_version"
}
}
commonTest {
dependencies {
implementation "org.jetbrains.kotlin:kotlin-test-common"
implementation "org.jetbrains.kotlin:kotlin-test-annotations-common"
implementation "io.ktor:ktor-client-mock:$ktor_version"
}
}
jvmMain {
dependsOn commonMain
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version"
implementation "org.jetbrains.kotlinx:kotlinx-serialization-runtime:$serialization_version"
implementation "io.ktor:ktor-client-core-jvm:$ktor_version"
implementation "io.ktor:ktor-client-json-jvm:$ktor_version"
implementation "io.ktor:ktor-client-serialization-jvm:$ktor_version"
}
}
jvmTest {
dependsOn commonTest
dependencies {
implementation "org.jetbrains.kotlin:kotlin-test"
implementation "org.jetbrains.kotlin:kotlin-test-junit"
implementation "io.ktor:ktor-client-mock-jvm:$ktor_version"
}
}
iosMain {
dependsOn commonMain
dependencies {
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core-native:$coroutines_version"
implementation "org.jetbrains.kotlinx:kotlinx-serialization-runtime-native:$serialization_version"
implementation "io.ktor:ktor-client-ios:$ktor_version"
}
}
iosTest {
dependsOn commonTest
dependencies {
implementation "io.ktor:ktor-client-mock-native:$ktor_version"
}
}
iosArm64().compilations.main.defaultSourceSet {
dependsOn iosMain
dependencies {
implementation "io.ktor:ktor-client-ios-iosarm64:$ktor_version"
implementation "io.ktor:ktor-client-json-iosarm64:$ktor_version"
implementation "io.ktor:ktor-client-serialization-iosarm64:$ktor_version"
}
}
iosArm64().compilations.test.defaultSourceSet {
dependsOn iosTest
}
iosX64().compilations.main.defaultSourceSet {
dependsOn iosMain
dependencies {
implementation "io.ktor:ktor-client-ios-iosx64:$ktor_version"
implementation "io.ktor:ktor-client-json-iosx64:$ktor_version"
implementation "io.ktor:ktor-client-serialization-iosx64:$ktor_version"
}
}
iosX64().compilations.test.defaultSourceSet {
dependsOn iosTest
}
all {
languageSettings {
useExperimentalAnnotation('kotlin.Experimental')
}
}
}
}
task iosTest {
def device = project.findProperty("device")?.toString() ?: "iPhone 8"
dependsOn 'linkDebugTestIosX64'
group = JavaBasePlugin.VERIFICATION_GROUP
description = "Execute unit tests on ${device} simulator"
doLast {
def binary = kotlin.targets.iosX64.binaries.getTest('DEBUG')
exec { commandLine 'xcrun', 'simctl', 'spawn', device, binary.outputFile }
}
}
configurations { // workaround for https://youtrack.jetbrains.com/issue/KT-27170
compileClasspath
}

Some files were not shown because too many files have changed in this diff Show More