diff --git a/bin/kotlin-client-petstore-multiplatform.sh b/bin/kotlin-client-petstore-multiplatform.sh new file mode 100755 index 00000000000..a0b5de50b53 --- /dev/null +++ b/bin/kotlin-client-petstore-multiplatform.sh @@ -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} diff --git a/bin/openapi3/kotlin-client-petstore-multiplatform.sh b/bin/openapi3/kotlin-client-petstore-multiplatform.sh new file mode 100755 index 00000000000..913f73ef1d8 --- /dev/null +++ b/bin/openapi3/kotlin-client-petstore-multiplatform.sh @@ -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 diff --git a/bin/windows/kotlin-client-petstore-multiplatform.bat b/bin/windows/kotlin-client-petstore-multiplatform.bat new file mode 100644 index 00000000000..628170d6007 --- /dev/null +++ b/bin/windows/kotlin-client-petstore-multiplatform.bat @@ -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% diff --git a/docs/generators/kotlin.md b/docs/generators/kotlin.md index ccf17bb6ecc..264842d4bb2 100644 --- a/docs/generators/kotlin.md +++ b/docs/generators/kotlin.md @@ -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|
**string**
String
**java8**
Java 8 native JSR310
**threetenbp**
Threetenbp
|java8| +|dateLibrary|Option. Date library to use|
**string**
String
**java8**
Java 8 native JSR310 (jvm only)
**threetenbp**
Threetenbp (jvm only)
|java8| |collectionType|Option. Collection type to use|
**array**
kotlin.Array
**list**
kotlin.collections.List
|array| +|library|Library template (sub-template) to use|
**jvm**
Platform: Java Virtual Machine. HTTP client: OkHttp 2.7.5. JSON processing: Gson 2.8.1.
**multiplatform**
Platform: Kotlin multiplatform. HTTP client: Ktor 1.2.4. JSON processing: Kotlinx Serialization: 0.12.0.
|jvm| diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/KotlinClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/KotlinClientCodegen.java index adb1eba7cf1..a0a92778058 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/KotlinClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/KotlinClientCodegen.java @@ -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 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 postProcessModels(Map objs) { + objs = super.postProcessModels(objs); + return postProcessModelsEscapeNames(objs); + } - final String infrastructureFolder = (sourceFolder + File.separator + packageName + File.separator + "infrastructure").replace(".", "/"); + @SuppressWarnings("unchecked") + private static Map postProcessModelsEscapeNames(Map objs) { + List models = (List) objs.get("models"); + for (Object _mo : models) { + Map mo = (Map) _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 list) { + Set set = new HashSet<>(); + Iterator 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 postProcessOperationsWithModels(Map objs, List allModels) { + super.postProcessOperationsWithModels(objs, allModels); + Map operations = (Map) objs.get("operations"); + if (operations != null) { + List ops = (List) 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> consumes) { + Map firstType = consumes.get(0); + if (firstType != null) { + return "multipart/form-data".equals(firstType.get("mediaType")); + } + return false; } } diff --git a/modules/openapi-generator/src/main/resources/kotlin-client/README.mustache b/modules/openapi-generator/src/main/resources/kotlin-client/README.mustache index b3d790c19ca..725ac257c09 100644 --- a/modules/openapi-generator/src/main/resources/kotlin-client/README.mustache +++ b/modules/openapi-generator/src/main/resources/kotlin-client/README.mustache @@ -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}} diff --git a/modules/openapi-generator/src/main/resources/kotlin-client/data_class.mustache b/modules/openapi-generator/src/main/resources/kotlin-client/data_class.mustache index a9f020ff400..0cece22bb0b 100644 --- a/modules/openapi-generator/src/main/resources/kotlin-client/data_class.mustache +++ b/modules/openapi-generator/src/main/resources/kotlin-client/data_class.mustache @@ -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}} diff --git a/modules/openapi-generator/src/main/resources/kotlin-client/data_class_opt_var.mustache b/modules/openapi-generator/src/main/resources/kotlin-client/data_class_opt_var.mustache index 7312c4f3fdc..e77b8b2b2ba 100644 --- a/modules/openapi-generator/src/main/resources/kotlin-client/data_class_opt_var.mustache +++ b/modules/openapi-generator/src/main/resources/kotlin-client/data_class_opt_var.mustache @@ -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}} \ No newline at end of file + {{/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}} \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/kotlin-client/data_class_req_var.mustache b/modules/openapi-generator/src/main/resources/kotlin-client/data_class_req_var.mustache index 223bf5904b4..0097d0702a9 100644 --- a/modules/openapi-generator/src/main/resources/kotlin-client/data_class_req_var.mustache +++ b/modules/openapi-generator/src/main/resources/kotlin-client/data_class_req_var.mustache @@ -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}} \ No newline at end of file + {{/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}} \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/kotlin-client/enum_class.mustache b/modules/openapi-generator/src/main/resources/kotlin-client/enum_class.mustache index af9a327b3db..ccf8eb0c89f 100644 --- a/modules/openapi-generator/src/main/resources/kotlin-client/enum_class.mustache +++ b/modules/openapi-generator/src/main/resources/kotlin-client/enum_class.mustache @@ -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}} } diff --git a/modules/openapi-generator/src/main/resources/kotlin-client/infrastructure/ApiAbstractions.kt.mustache b/modules/openapi-generator/src/main/resources/kotlin-client/infrastructure/ApiAbstractions.kt.mustache index 0a42ce534d3..6123c8b01b1 100644 --- a/modules/openapi-generator/src/main/resources/kotlin-client/infrastructure/ApiAbstractions.kt.mustache +++ b/modules/openapi-generator/src/main/resources/kotlin-client/infrastructure/ApiAbstractions.kt.mustache @@ -12,9 +12,12 @@ fun collectionDelimiter(collectionFormat: String) = when(collectionFormat) { val defaultMultiValueConverter: (item: Any?) -> String = { item -> "$item" } -fun toMultiValue(items: List, collectionFormat: String, map: (item: Any?) -> String = defaultMultiValueConverter): List { +fun toMultiValue(items: Array, collectionFormat: String, map: (item: T) -> String = defaultMultiValueConverter) + = toMultiValue(items.asIterable(), collectionFormat, map) + +fun toMultiValue(items: Iterable, collectionFormat: String, map: (item: T) -> String = defaultMultiValueConverter): List { 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)) } } \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/kotlin-client/infrastructure/ApiClient.kt.mustache b/modules/openapi-generator/src/main/resources/kotlin-client/libraries/jvm/infrastructure/ApiClient.kt.mustache similarity index 100% rename from modules/openapi-generator/src/main/resources/kotlin-client/infrastructure/ApiClient.kt.mustache rename to modules/openapi-generator/src/main/resources/kotlin-client/libraries/jvm/infrastructure/ApiClient.kt.mustache diff --git a/modules/openapi-generator/src/main/resources/kotlin-client/infrastructure/ApiInfrastructureResponse.kt.mustache b/modules/openapi-generator/src/main/resources/kotlin-client/libraries/jvm/infrastructure/ApiInfrastructureResponse.kt.mustache similarity index 100% rename from modules/openapi-generator/src/main/resources/kotlin-client/infrastructure/ApiInfrastructureResponse.kt.mustache rename to modules/openapi-generator/src/main/resources/kotlin-client/libraries/jvm/infrastructure/ApiInfrastructureResponse.kt.mustache diff --git a/modules/openapi-generator/src/main/resources/kotlin-client/infrastructure/ApplicationDelegates.kt.mustache b/modules/openapi-generator/src/main/resources/kotlin-client/libraries/jvm/infrastructure/ApplicationDelegates.kt.mustache similarity index 100% rename from modules/openapi-generator/src/main/resources/kotlin-client/infrastructure/ApplicationDelegates.kt.mustache rename to modules/openapi-generator/src/main/resources/kotlin-client/libraries/jvm/infrastructure/ApplicationDelegates.kt.mustache diff --git a/modules/openapi-generator/src/main/resources/kotlin-client/infrastructure/ByteArrayAdapter.kt.mustache b/modules/openapi-generator/src/main/resources/kotlin-client/libraries/jvm/infrastructure/ByteArrayAdapter.kt.mustache similarity index 100% rename from modules/openapi-generator/src/main/resources/kotlin-client/infrastructure/ByteArrayAdapter.kt.mustache rename to modules/openapi-generator/src/main/resources/kotlin-client/libraries/jvm/infrastructure/ByteArrayAdapter.kt.mustache diff --git a/modules/openapi-generator/src/main/resources/kotlin-client/infrastructure/Errors.kt.mustache b/modules/openapi-generator/src/main/resources/kotlin-client/libraries/jvm/infrastructure/Errors.kt.mustache similarity index 100% rename from modules/openapi-generator/src/main/resources/kotlin-client/infrastructure/Errors.kt.mustache rename to modules/openapi-generator/src/main/resources/kotlin-client/libraries/jvm/infrastructure/Errors.kt.mustache diff --git a/modules/openapi-generator/src/main/resources/kotlin-client/infrastructure/LocalDateAdapter.kt.mustache b/modules/openapi-generator/src/main/resources/kotlin-client/libraries/jvm/infrastructure/LocalDateAdapter.kt.mustache similarity index 100% rename from modules/openapi-generator/src/main/resources/kotlin-client/infrastructure/LocalDateAdapter.kt.mustache rename to modules/openapi-generator/src/main/resources/kotlin-client/libraries/jvm/infrastructure/LocalDateAdapter.kt.mustache diff --git a/modules/openapi-generator/src/main/resources/kotlin-client/infrastructure/LocalDateTimeAdapter.kt.mustache b/modules/openapi-generator/src/main/resources/kotlin-client/libraries/jvm/infrastructure/LocalDateTimeAdapter.kt.mustache similarity index 100% rename from modules/openapi-generator/src/main/resources/kotlin-client/infrastructure/LocalDateTimeAdapter.kt.mustache rename to modules/openapi-generator/src/main/resources/kotlin-client/libraries/jvm/infrastructure/LocalDateTimeAdapter.kt.mustache diff --git a/modules/openapi-generator/src/main/resources/kotlin-client/infrastructure/ResponseExtensions.kt.mustache b/modules/openapi-generator/src/main/resources/kotlin-client/libraries/jvm/infrastructure/ResponseExtensions.kt.mustache similarity index 100% rename from modules/openapi-generator/src/main/resources/kotlin-client/infrastructure/ResponseExtensions.kt.mustache rename to modules/openapi-generator/src/main/resources/kotlin-client/libraries/jvm/infrastructure/ResponseExtensions.kt.mustache diff --git a/modules/openapi-generator/src/main/resources/kotlin-client/infrastructure/Serializer.kt.mustache b/modules/openapi-generator/src/main/resources/kotlin-client/libraries/jvm/infrastructure/Serializer.kt.mustache similarity index 100% rename from modules/openapi-generator/src/main/resources/kotlin-client/infrastructure/Serializer.kt.mustache rename to modules/openapi-generator/src/main/resources/kotlin-client/libraries/jvm/infrastructure/Serializer.kt.mustache diff --git a/modules/openapi-generator/src/main/resources/kotlin-client/infrastructure/UUIDAdapter.kt.mustache b/modules/openapi-generator/src/main/resources/kotlin-client/libraries/jvm/infrastructure/UUIDAdapter.kt.mustache similarity index 100% rename from modules/openapi-generator/src/main/resources/kotlin-client/infrastructure/UUIDAdapter.kt.mustache rename to modules/openapi-generator/src/main/resources/kotlin-client/libraries/jvm/infrastructure/UUIDAdapter.kt.mustache diff --git a/modules/openapi-generator/src/main/resources/kotlin-client/libraries/multiplatform/api.mustache b/modules/openapi-generator/src/main/resources/kotlin-client/libraries/multiplatform/api.mustache new file mode 100644 index 00000000000..232c77d5fda --- /dev/null +++ b/modules/openapi-generator/src/main/resources/kotlin-client/libraries/multiplatform/api.mustache @@ -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>() + {{#hasQueryParams}}{{#queryParams}} + {{paramName}}?.apply { localVariableQuery["{{baseName}}"] = {{#isContainer}}toMultiValue(this, "{{collectionFormat}}"){{/isContainer}}{{^isContainer}}listOf("${{paramName}}"){{/isContainer}} } + {{/queryParams}}{{/hasQueryParams}} + + val localVariableHeaders = mutableMapOf() + {{#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}} diff --git a/modules/openapi-generator/src/main/resources/kotlin-client/libraries/multiplatform/build.gradle.mustache b/modules/openapi-generator/src/main/resources/kotlin-client/libraries/multiplatform/build.gradle.mustache new file mode 100644 index 00000000000..1e309cc464a --- /dev/null +++ b/modules/openapi-generator/src/main/resources/kotlin-client/libraries/multiplatform/build.gradle.mustache @@ -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 +} diff --git a/modules/openapi-generator/src/main/resources/kotlin-client/libraries/multiplatform/commonTest/coroutine.mustache b/modules/openapi-generator/src/main/resources/kotlin-client/libraries/multiplatform/commonTest/coroutine.mustache new file mode 100644 index 00000000000..c3bd8b18461 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/kotlin-client/libraries/multiplatform/commonTest/coroutine.mustache @@ -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 runTest(block: suspend CoroutineScope.() -> T): T diff --git a/modules/openapi-generator/src/main/resources/kotlin-client/libraries/multiplatform/gradle-wrapper.jar b/modules/openapi-generator/src/main/resources/kotlin-client/libraries/multiplatform/gradle-wrapper.jar new file mode 100644 index 00000000000..2c6137b8789 Binary files /dev/null and b/modules/openapi-generator/src/main/resources/kotlin-client/libraries/multiplatform/gradle-wrapper.jar differ diff --git a/modules/openapi-generator/src/main/resources/kotlin-client/libraries/multiplatform/gradle-wrapper.properties.mustache b/modules/openapi-generator/src/main/resources/kotlin-client/libraries/multiplatform/gradle-wrapper.properties.mustache new file mode 100644 index 00000000000..ce3ca77db54 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/kotlin-client/libraries/multiplatform/gradle-wrapper.properties.mustache @@ -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 diff --git a/modules/openapi-generator/src/main/resources/kotlin-client/libraries/multiplatform/gradlew.bat.mustache b/modules/openapi-generator/src/main/resources/kotlin-client/libraries/multiplatform/gradlew.bat.mustache new file mode 100644 index 00000000000..5f192121eb4 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/kotlin-client/libraries/multiplatform/gradlew.bat.mustache @@ -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 diff --git a/modules/openapi-generator/src/main/resources/kotlin-client/libraries/multiplatform/gradlew.mustache b/modules/openapi-generator/src/main/resources/kotlin-client/libraries/multiplatform/gradlew.mustache new file mode 100755 index 00000000000..9d82f789151 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/kotlin-client/libraries/multiplatform/gradlew.mustache @@ -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 "$@" diff --git a/modules/openapi-generator/src/main/resources/kotlin-client/libraries/multiplatform/infrastructure/ApiClient.kt.mustache b/modules/openapi-generator/src/main/resources/kotlin-client/libraries/multiplatform/infrastructure/ApiClient.kt.mustache new file mode 100644 index 00000000000..fdb83114b7b --- /dev/null +++ b/modules/openapi-generator/src/main/resources/kotlin-client/libraries/multiplatform/infrastructure/ApiClient.kt.mustache @@ -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?): 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): 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) + } +} diff --git a/modules/openapi-generator/src/main/resources/kotlin-client/libraries/multiplatform/infrastructure/HttpResponse.kt.mustache b/modules/openapi-generator/src/main/resources/kotlin-client/libraries/multiplatform/infrastructure/HttpResponse.kt.mustache new file mode 100644 index 00000000000..6bf43085b73 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/kotlin-client/libraries/multiplatform/infrastructure/HttpResponse.kt.mustache @@ -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(val response: io.ktor.client.response.HttpResponse, val provider: BodyProvider) { + val status: Int = response.status.value + val success: Boolean = response.status.isSuccess() + val headers: Map> = response.headers.mapEntries() + suspend fun body(): T = provider.body(response) + suspend fun typedBody(type: TypeInfo): V = provider.typedBody(response, type) + + companion object { + private fun Headers.mapEntries(): Map> { + val result = mutableMapOf>() + entries().forEach { result[it.key] = it.value } + return result + } + } +} + +interface BodyProvider { + suspend fun body(response: io.ktor.client.response.HttpResponse): T + suspend fun typedBody(response: io.ktor.client.response.HttpResponse, type: TypeInfo): V +} + +class TypedBodyProvider(private val type: TypeInfo) : BodyProvider { + @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 typedBody(response: io.ktor.client.response.HttpResponse, type: TypeInfo): V = + response.call.receive(type) as V +} + +class MappedBodyProvider(private val provider: BodyProvider, private val block: S.() -> T) : BodyProvider { + override suspend fun body(response: io.ktor.client.response.HttpResponse): T = + block(provider.body(response)) + + override suspend fun typedBody(response: io.ktor.client.response.HttpResponse, type: TypeInfo): V = + provider.typedBody(response, type) +} + +inline fun io.ktor.client.response.HttpResponse.wrap(): HttpResponse = + HttpResponse(this, TypedBodyProvider(typeInfo())) + +fun HttpResponse.map(block: T.() -> V): HttpResponse = + HttpResponse(response, MappedBodyProvider(provider, block)) diff --git a/modules/openapi-generator/src/main/resources/kotlin-client/libraries/multiplatform/iosTest/coroutine.mustache b/modules/openapi-generator/src/main/resources/kotlin-client/libraries/multiplatform/iosTest/coroutine.mustache new file mode 100644 index 00000000000..351c0120b7b --- /dev/null +++ b/modules/openapi-generator/src/main/resources/kotlin-client/libraries/multiplatform/iosTest/coroutine.mustache @@ -0,0 +1,8 @@ +{{>licenseInfo}} + +package util + +import kotlinx.coroutines.CoroutineScope +import kotlin.coroutines.EmptyCoroutineContext + +internal actual fun runTest(block: suspend CoroutineScope.() -> T): T = kotlinx.coroutines.runBlocking(EmptyCoroutineContext, block) diff --git a/modules/openapi-generator/src/main/resources/kotlin-client/libraries/multiplatform/jvmTest/coroutine.mustache b/modules/openapi-generator/src/main/resources/kotlin-client/libraries/multiplatform/jvmTest/coroutine.mustache new file mode 100644 index 00000000000..351c0120b7b --- /dev/null +++ b/modules/openapi-generator/src/main/resources/kotlin-client/libraries/multiplatform/jvmTest/coroutine.mustache @@ -0,0 +1,8 @@ +{{>licenseInfo}} + +package util + +import kotlinx.coroutines.CoroutineScope +import kotlin.coroutines.EmptyCoroutineContext + +internal actual fun runTest(block: suspend CoroutineScope.() -> T): T = kotlinx.coroutines.runBlocking(EmptyCoroutineContext, block) diff --git a/modules/openapi-generator/src/main/resources/kotlin-client/libraries/multiplatform/serial_wrapper_request_list.mustache b/modules/openapi-generator/src/main/resources/kotlin-client/libraries/multiplatform/serial_wrapper_request_list.mustache new file mode 100644 index 00000000000..1e240683b80 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/kotlin-client/libraries/multiplatform/serial_wrapper_request_list.mustache @@ -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> = {{#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)) + } +} \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/kotlin-client/libraries/multiplatform/serial_wrapper_request_map.mustache b/modules/openapi-generator/src/main/resources/kotlin-client/libraries/multiplatform/serial_wrapper_request_map.mustache new file mode 100644 index 00000000000..7da90c9974b --- /dev/null +++ b/modules/openapi-generator/src/main/resources/kotlin-client/libraries/multiplatform/serial_wrapper_request_map.mustache @@ -0,0 +1,10 @@ +@Serializable +private class {{operationIdCamelCase}}Request(val value: Map) { + @Serializer({{operationIdCamelCase}}Request::class) + companion object : KSerializer<{{operationIdCamelCase}}Request> { + private val serializer: KSerializer> = (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)) + } +} \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/kotlin-client/libraries/multiplatform/serial_wrapper_response_list.mustache b/modules/openapi-generator/src/main/resources/kotlin-client/libraries/multiplatform/serial_wrapper_response_list.mustache new file mode 100644 index 00000000000..91403ee50b4 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/kotlin-client/libraries/multiplatform/serial_wrapper_response_list.mustache @@ -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> = {{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)) + } +} \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/kotlin-client/libraries/multiplatform/serial_wrapper_response_map.mustache b/modules/openapi-generator/src/main/resources/kotlin-client/libraries/multiplatform/serial_wrapper_response_map.mustache new file mode 100644 index 00000000000..730e0b672c5 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/kotlin-client/libraries/multiplatform/serial_wrapper_response_map.mustache @@ -0,0 +1,10 @@ +@Serializable +private class {{operationIdCamelCase}}Response(val value: Map) { + @Serializer({{operationIdCamelCase}}Response::class) + companion object : KSerializer<{{operationIdCamelCase}}Response> { + private val serializer: KSerializer> = (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)) + } +} \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/kotlin-client/settings.gradle.mustache b/modules/openapi-generator/src/main/resources/kotlin-client/settings.gradle.mustache index 448dc07602e..2a789fe8d04 100644 --- a/modules/openapi-generator/src/main/resources/kotlin-client/settings.gradle.mustache +++ b/modules/openapi-generator/src/main/resources/kotlin-client/settings.gradle.mustache @@ -1 +1,2 @@ +{{#multiplatform}}enableFeaturePreview('GRADLE_METADATA'){{/multiplatform}} rootProject.name = '{{artifactId}}' \ No newline at end of file diff --git a/samples/client/petstore/kotlin-multiplatform/.openapi-generator-ignore b/samples/client/petstore/kotlin-multiplatform/.openapi-generator-ignore new file mode 100644 index 00000000000..7484ee590a3 --- /dev/null +++ b/samples/client/petstore/kotlin-multiplatform/.openapi-generator-ignore @@ -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 diff --git a/samples/client/petstore/kotlin-multiplatform/.openapi-generator/VERSION b/samples/client/petstore/kotlin-multiplatform/.openapi-generator/VERSION new file mode 100644 index 00000000000..0e97bd19efb --- /dev/null +++ b/samples/client/petstore/kotlin-multiplatform/.openapi-generator/VERSION @@ -0,0 +1 @@ +4.1.3-SNAPSHOT \ No newline at end of file diff --git a/samples/client/petstore/kotlin-multiplatform/README.md b/samples/client/petstore/kotlin-multiplatform/README.md new file mode 100644 index 00000000000..308e8b1c99e --- /dev/null +++ b/samples/client/petstore/kotlin-multiplatform/README.md @@ -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. + + + +## 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 + + + +## 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) + + + +## Documentation for Authorization + + +### api_key + +- **Type**: API key +- **API key parameter name**: api_key +- **Location**: HTTP header + + +### 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 + diff --git a/samples/client/petstore/kotlin-multiplatform/build.gradle b/samples/client/petstore/kotlin-multiplatform/build.gradle new file mode 100644 index 00000000000..c976992112f --- /dev/null +++ b/samples/client/petstore/kotlin-multiplatform/build.gradle @@ -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 +} diff --git a/samples/client/petstore/kotlin-multiplatform/docs/ApiResponse.md b/samples/client/petstore/kotlin-multiplatform/docs/ApiResponse.md new file mode 100644 index 00000000000..6b4c6bf2779 --- /dev/null +++ b/samples/client/petstore/kotlin-multiplatform/docs/ApiResponse.md @@ -0,0 +1,12 @@ + +# ApiResponse + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**code** | **kotlin.Int** | | [optional] +**type** | **kotlin.String** | | [optional] +**message** | **kotlin.String** | | [optional] + + + diff --git a/samples/client/petstore/kotlin-multiplatform/docs/Category.md b/samples/client/petstore/kotlin-multiplatform/docs/Category.md new file mode 100644 index 00000000000..2c28a670fc7 --- /dev/null +++ b/samples/client/petstore/kotlin-multiplatform/docs/Category.md @@ -0,0 +1,11 @@ + +# Category + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **kotlin.Long** | | [optional] +**name** | **kotlin.String** | | [optional] + + + diff --git a/samples/client/petstore/kotlin-multiplatform/docs/Order.md b/samples/client/petstore/kotlin-multiplatform/docs/Order.md new file mode 100644 index 00000000000..4683c14c1cb --- /dev/null +++ b/samples/client/petstore/kotlin-multiplatform/docs/Order.md @@ -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] + + + +## Enum: status +Name | Value +---- | ----- +status | placed, approved, delivered + + + diff --git a/samples/client/petstore/kotlin-multiplatform/docs/Pet.md b/samples/client/petstore/kotlin-multiplatform/docs/Pet.md new file mode 100644 index 00000000000..ec775600737 --- /dev/null +++ b/samples/client/petstore/kotlin-multiplatform/docs/Pet.md @@ -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<kotlin.String>** | | +**tags** | [**kotlin.Array<Tag>**](Tag.md) | | [optional] +**status** | [**inline**](#StatusEnum) | pet status in the store | [optional] + + + +## Enum: status +Name | Value +---- | ----- +status | available, pending, sold + + + diff --git a/samples/client/petstore/kotlin-multiplatform/docs/PetApi.md b/samples/client/petstore/kotlin-multiplatform/docs/PetApi.md new file mode 100644 index 00000000000..38df230ae67 --- /dev/null +++ b/samples/client/petstore/kotlin-multiplatform/docs/PetApi.md @@ -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 + + + +# **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 + + +# **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 + + +# **findPetsByStatus** +> kotlin.Array<Pet> 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.Array | Status values that need to be considered for filter +try { + val result : kotlin.Array = 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<kotlin.String>**](kotlin.String.md)| Status values that need to be considered for filter | [enum: available, pending, sold] + +### Return type + +[**kotlin.Array<Pet>**](Pet.md) + +### Authorization + + +Configure petstore_auth: + ApiClient.accessToken = "" + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + + +# **findPetsByTags** +> kotlin.Array<Pet> 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.Array | Tags to filter by +try { + val result : kotlin.Array = 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<kotlin.String>**](kotlin.String.md)| Tags to filter by | + +### Return type + +[**kotlin.Array<Pet>**](Pet.md) + +### Authorization + + +Configure petstore_auth: + ApiClient.accessToken = "" + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + + +# **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 + + +# **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 + + +# **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 + + +# **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 + diff --git a/samples/client/petstore/kotlin-multiplatform/docs/StoreApi.md b/samples/client/petstore/kotlin-multiplatform/docs/StoreApi.md new file mode 100644 index 00000000000..f4986041af8 --- /dev/null +++ b/samples/client/petstore/kotlin-multiplatform/docs/StoreApi.md @@ -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 + + + +# **deleteOrder** +> deleteOrder(orderId) + +Delete purchase order by ID + +For valid response try integer IDs with value < 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 + + +# **getInventory** +> kotlin.collections.Map<kotlin.String, kotlin.Int> 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 = 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<kotlin.String, kotlin.Int>** + +### Authorization + + +Configure api_key: + ApiClient.apiKey["api_key"] = "" + ApiClient.apiKeyPrefix["api_key"] = "" + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + + +# **getOrderById** +> Order getOrderById(orderId) + +Find purchase order by ID + +For valid response try integer IDs with value <= 5 or > 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 + + +# **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 + diff --git a/samples/client/petstore/kotlin-multiplatform/docs/Tag.md b/samples/client/petstore/kotlin-multiplatform/docs/Tag.md new file mode 100644 index 00000000000..60ce1bcdbad --- /dev/null +++ b/samples/client/petstore/kotlin-multiplatform/docs/Tag.md @@ -0,0 +1,11 @@ + +# Tag + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **kotlin.Long** | | [optional] +**name** | **kotlin.String** | | [optional] + + + diff --git a/samples/client/petstore/kotlin-multiplatform/docs/User.md b/samples/client/petstore/kotlin-multiplatform/docs/User.md new file mode 100644 index 00000000000..e801729b5ed --- /dev/null +++ b/samples/client/petstore/kotlin-multiplatform/docs/User.md @@ -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] + + + diff --git a/samples/client/petstore/kotlin-multiplatform/docs/UserApi.md b/samples/client/petstore/kotlin-multiplatform/docs/UserApi.md new file mode 100644 index 00000000000..0f55f06bc62 --- /dev/null +++ b/samples/client/petstore/kotlin-multiplatform/docs/UserApi.md @@ -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 + + + +# **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 + + +# **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 = // kotlin.Array | 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<User>**](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 + + +# **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 = // kotlin.Array | 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<User>**](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 + + +# **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 + + +# **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 + + +# **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 + + +# **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 + + +# **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 + diff --git a/samples/client/petstore/kotlin-multiplatform/gradle/wrapper/gradle-wrapper.jar b/samples/client/petstore/kotlin-multiplatform/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 00000000000..2c6137b8789 Binary files /dev/null and b/samples/client/petstore/kotlin-multiplatform/gradle/wrapper/gradle-wrapper.jar differ diff --git a/samples/client/petstore/kotlin-multiplatform/gradle/wrapper/gradle-wrapper.properties b/samples/client/petstore/kotlin-multiplatform/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 00000000000..ce3ca77db54 --- /dev/null +++ b/samples/client/petstore/kotlin-multiplatform/gradle/wrapper/gradle-wrapper.properties @@ -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 diff --git a/samples/client/petstore/kotlin-multiplatform/gradlew b/samples/client/petstore/kotlin-multiplatform/gradlew new file mode 100644 index 00000000000..9d82f789151 --- /dev/null +++ b/samples/client/petstore/kotlin-multiplatform/gradlew @@ -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 "$@" diff --git a/samples/client/petstore/kotlin-multiplatform/gradlew.bat b/samples/client/petstore/kotlin-multiplatform/gradlew.bat new file mode 100644 index 00000000000..5f192121eb4 --- /dev/null +++ b/samples/client/petstore/kotlin-multiplatform/gradlew.bat @@ -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 diff --git a/samples/client/petstore/kotlin-multiplatform/settings.gradle b/samples/client/petstore/kotlin-multiplatform/settings.gradle new file mode 100644 index 00000000000..b000833f485 --- /dev/null +++ b/samples/client/petstore/kotlin-multiplatform/settings.gradle @@ -0,0 +1,2 @@ +enableFeaturePreview('GRADLE_METADATA') +rootProject.name = 'kotlin-client-petstore-multiplatform' \ No newline at end of file diff --git a/samples/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/apis/PetApi.kt b/samples/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/apis/PetApi.kt new file mode 100644 index 00000000000..be06c23d33c --- /dev/null +++ b/samples/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/apis/PetApi.kt @@ -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 { + + val localVariableBody = body + + + val localVariableQuery = mutableMapOf>() + + + val localVariableHeaders = mutableMapOf() + + + 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 { + + val localVariableBody = + io.ktor.client.utils.EmptyContent + + val localVariableQuery = mutableMapOf>() + + + val localVariableHeaders = mutableMapOf() + + 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 + */ + @Suppress("UNCHECKED_CAST") + suspend fun findPetsByStatus(status: kotlin.Array) : HttpResponse> { + + val localVariableBody = + io.ktor.client.utils.EmptyContent + + val localVariableQuery = mutableMapOf>() + + status?.apply { localVariableQuery["status"] = toMultiValue(this, "csv") } + + + val localVariableHeaders = mutableMapOf() + + + val localVariableConfig = RequestConfig( + RequestMethod.GET, + "/pet/findByStatus", + query = localVariableQuery, + headers = localVariableHeaders + ) + + return request( + localVariableConfig, + localVariableBody + ).wrap().map { value.toTypedArray() } + } + + + @Serializable +private class FindPetsByStatusResponse(val value: List) { + @Serializer(FindPetsByStatusResponse::class) + companion object : KSerializer { + private val serializer: KSerializer> = 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 + */ + @Suppress("UNCHECKED_CAST") + suspend fun findPetsByTags(tags: kotlin.Array) : HttpResponse> { + + val localVariableBody = + io.ktor.client.utils.EmptyContent + + val localVariableQuery = mutableMapOf>() + + tags?.apply { localVariableQuery["tags"] = toMultiValue(this, "csv") } + + + val localVariableHeaders = mutableMapOf() + + + val localVariableConfig = RequestConfig( + RequestMethod.GET, + "/pet/findByTags", + query = localVariableQuery, + headers = localVariableHeaders + ) + + return request( + localVariableConfig, + localVariableBody + ).wrap().map { value.toTypedArray() } + } + + + @Serializable +private class FindPetsByTagsResponse(val value: List) { + @Serializer(FindPetsByTagsResponse::class) + companion object : KSerializer { + private val serializer: KSerializer> = 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 { + + val localVariableBody = + io.ktor.client.utils.EmptyContent + + val localVariableQuery = mutableMapOf>() + + + val localVariableHeaders = mutableMapOf() + + + 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 { + + val localVariableBody = body + + + val localVariableQuery = mutableMapOf>() + + + val localVariableHeaders = mutableMapOf() + + + 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 { + + val localVariableBody = + ParametersBuilder().also { + name?.apply { it.append("name", name) } + status?.apply { it.append("status", status) } + }.build() + + val localVariableQuery = mutableMapOf>() + + + val localVariableHeaders = mutableMapOf() + + + 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 { + + val localVariableBody = + formData { + additionalMetadata?.apply { append("additionalMetadata", additionalMetadata) } + file?.apply { append("file", file) } + } + + val localVariableQuery = mutableMapOf>() + + + val localVariableHeaders = mutableMapOf() + + + 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()) + + + + + + + + + } + } +} diff --git a/samples/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/apis/StoreApi.kt b/samples/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/apis/StoreApi.kt new file mode 100644 index 00000000000..e7ff3358d8b --- /dev/null +++ b/samples/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/apis/StoreApi.kt @@ -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 < 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 { + + val localVariableBody = + io.ktor.client.utils.EmptyContent + + val localVariableQuery = mutableMapOf>() + + + val localVariableHeaders = mutableMapOf() + + + 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 + */ + @Suppress("UNCHECKED_CAST") + suspend fun getInventory() : HttpResponse> { + + val localVariableBody = + io.ktor.client.utils.EmptyContent + + val localVariableQuery = mutableMapOf>() + + + val localVariableHeaders = mutableMapOf() + + + val localVariableConfig = RequestConfig( + RequestMethod.GET, + "/store/inventory", + query = localVariableQuery, + headers = localVariableHeaders + ) + + return request( + localVariableConfig, + localVariableBody + ).wrap().map { value } + } + + + @Serializable +private class GetInventoryResponse(val value: Map) { + @Serializer(GetInventoryResponse::class) + companion object : KSerializer { + private val serializer: KSerializer> = (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 <= 5 or > 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 { + + val localVariableBody = + io.ktor.client.utils.EmptyContent + + val localVariableQuery = mutableMapOf>() + + + val localVariableHeaders = mutableMapOf() + + + 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 { + + val localVariableBody = body + + + val localVariableQuery = mutableMapOf>() + + + val localVariableHeaders = mutableMapOf() + + + 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()) + + + + + } + } +} diff --git a/samples/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/apis/UserApi.kt b/samples/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/apis/UserApi.kt new file mode 100644 index 00000000000..96e7031c296 --- /dev/null +++ b/samples/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/apis/UserApi.kt @@ -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 { + + val localVariableBody = body + + + val localVariableQuery = mutableMapOf>() + + + val localVariableHeaders = mutableMapOf() + + + 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) : HttpResponse { + + val localVariableBody = CreateUsersWithArrayInputRequest(body.asList()) + + + val localVariableQuery = mutableMapOf>() + + + val localVariableHeaders = mutableMapOf() + + + val localVariableConfig = RequestConfig( + RequestMethod.POST, + "/user/createWithArray", + query = localVariableQuery, + headers = localVariableHeaders + ) + + return jsonRequest( + localVariableConfig, + localVariableBody + ).wrap() + } + + @Serializable +private class CreateUsersWithArrayInputRequest(val value: List) { + @Serializer(CreateUsersWithArrayInputRequest::class) + companion object : KSerializer { + private val serializer: KSerializer> = 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) : HttpResponse { + + val localVariableBody = CreateUsersWithListInputRequest(body.asList()) + + + val localVariableQuery = mutableMapOf>() + + + val localVariableHeaders = mutableMapOf() + + + val localVariableConfig = RequestConfig( + RequestMethod.POST, + "/user/createWithList", + query = localVariableQuery, + headers = localVariableHeaders + ) + + return jsonRequest( + localVariableConfig, + localVariableBody + ).wrap() + } + + @Serializable +private class CreateUsersWithListInputRequest(val value: List) { + @Serializer(CreateUsersWithListInputRequest::class) + companion object : KSerializer { + private val serializer: KSerializer> = 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 { + + val localVariableBody = + io.ktor.client.utils.EmptyContent + + val localVariableQuery = mutableMapOf>() + + + val localVariableHeaders = mutableMapOf() + + + 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 { + + val localVariableBody = + io.ktor.client.utils.EmptyContent + + val localVariableQuery = mutableMapOf>() + + + val localVariableHeaders = mutableMapOf() + + + 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 { + + val localVariableBody = + io.ktor.client.utils.EmptyContent + + val localVariableQuery = mutableMapOf>() + + username?.apply { localVariableQuery["username"] = listOf("$username") } + + password?.apply { localVariableQuery["password"] = listOf("$password") } + + + val localVariableHeaders = mutableMapOf() + + + 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 { + + val localVariableBody = + io.ktor.client.utils.EmptyContent + + val localVariableQuery = mutableMapOf>() + + + val localVariableHeaders = mutableMapOf() + + + 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 { + + val localVariableBody = body + + + val localVariableQuery = mutableMapOf>() + + + val localVariableHeaders = mutableMapOf() + + + 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()) + + + + + + + + + + + + } + } +} diff --git a/samples/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/infrastructure/ApiAbstractions.kt b/samples/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/infrastructure/ApiAbstractions.kt new file mode 100644 index 00000000000..f97cb88d233 --- /dev/null +++ b/samples/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/infrastructure/ApiAbstractions.kt @@ -0,0 +1,23 @@ +package org.openapitools.client.infrastructure + +typealias MultiValueMap = Map> + +fun collectionDelimiter(collectionFormat: String) = when(collectionFormat) { + "csv" -> "," + "tsv" -> "\t" + "pipes" -> "|" + "ssv" -> " " + else -> "" +} + +val defaultMultiValueConverter: (item: Any?) -> String = { item -> "$item" } + +fun toMultiValue(items: Array, collectionFormat: String, map: (item: T) -> String = defaultMultiValueConverter) + = toMultiValue(items.asIterable(), collectionFormat, map) + +fun toMultiValue(items: Iterable, collectionFormat: String, map: (item: T) -> String = defaultMultiValueConverter): List { + return when(collectionFormat) { + "multi" -> items.map(map) + else -> listOf(items.joinToString(separator = collectionDelimiter(collectionFormat), transform = map)) + } +} \ No newline at end of file diff --git a/samples/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/infrastructure/ApiClient.kt b/samples/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/infrastructure/ApiClient.kt new file mode 100644 index 00000000000..66a5140d254 --- /dev/null +++ b/samples/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/infrastructure/ApiClient.kt @@ -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?): 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): 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) + } +} diff --git a/samples/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/infrastructure/HttpResponse.kt b/samples/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/infrastructure/HttpResponse.kt new file mode 100644 index 00000000000..c457eb4bce0 --- /dev/null +++ b/samples/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/infrastructure/HttpResponse.kt @@ -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(val response: io.ktor.client.response.HttpResponse, val provider: BodyProvider) { + val status: Int = response.status.value + val success: Boolean = response.status.isSuccess() + val headers: Map> = response.headers.mapEntries() + suspend fun body(): T = provider.body(response) + suspend fun typedBody(type: TypeInfo): V = provider.typedBody(response, type) + + companion object { + private fun Headers.mapEntries(): Map> { + val result = mutableMapOf>() + entries().forEach { result[it.key] = it.value } + return result + } + } +} + +interface BodyProvider { + suspend fun body(response: io.ktor.client.response.HttpResponse): T + suspend fun typedBody(response: io.ktor.client.response.HttpResponse, type: TypeInfo): V +} + +class TypedBodyProvider(private val type: TypeInfo) : BodyProvider { + @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 typedBody(response: io.ktor.client.response.HttpResponse, type: TypeInfo): V = + response.call.receive(type) as V +} + +class MappedBodyProvider(private val provider: BodyProvider, private val block: S.() -> T) : BodyProvider { + override suspend fun body(response: io.ktor.client.response.HttpResponse): T = + block(provider.body(response)) + + override suspend fun typedBody(response: io.ktor.client.response.HttpResponse, type: TypeInfo): V = + provider.typedBody(response, type) +} + +inline fun io.ktor.client.response.HttpResponse.wrap(): HttpResponse = + HttpResponse(this, TypedBodyProvider(typeInfo())) + +fun HttpResponse.map(block: T.() -> V): HttpResponse = + HttpResponse(response, MappedBodyProvider(provider, block)) diff --git a/samples/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/infrastructure/RequestConfig.kt b/samples/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/infrastructure/RequestConfig.kt new file mode 100644 index 00000000000..53e689237d7 --- /dev/null +++ b/samples/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/infrastructure/RequestConfig.kt @@ -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 because rfc2616 defines + * multi-valued headers as csv-only. + */ +data class RequestConfig( + val method: RequestMethod, + val path: String, + val headers: MutableMap = mutableMapOf(), + val query: Map> = mapOf() +) \ No newline at end of file diff --git a/samples/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/infrastructure/RequestMethod.kt b/samples/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/infrastructure/RequestMethod.kt new file mode 100644 index 00000000000..931b12b8bd7 --- /dev/null +++ b/samples/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/infrastructure/RequestMethod.kt @@ -0,0 +1,8 @@ +package org.openapitools.client.infrastructure + +/** + * Provides enumerated HTTP verbs + */ +enum class RequestMethod { + GET, DELETE, HEAD, OPTIONS, PATCH, POST, PUT +} \ No newline at end of file diff --git a/samples/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/models/ApiResponse.kt b/samples/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/models/ApiResponse.kt new file mode 100644 index 00000000000..c57290ce102 --- /dev/null +++ b/samples/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/models/ApiResponse.kt @@ -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 +) + + diff --git a/samples/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/models/Category.kt b/samples/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/models/Category.kt new file mode 100644 index 00000000000..fbf598b4f9e --- /dev/null +++ b/samples/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/models/Category.kt @@ -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 +) + + diff --git a/samples/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/models/Order.kt b/samples/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/models/Order.kt new file mode 100644 index 00000000000..a487bc27e2c --- /dev/null +++ b/samples/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/models/Order.kt @@ -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", values(), values().map { it.value }.toTypedArray()) + } +} + + diff --git a/samples/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/models/Pet.kt b/samples/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/models/Pet.kt new file mode 100644 index 00000000000..4406842eeb5 --- /dev/null +++ b/samples/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/models/Pet.kt @@ -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, + @SerialName(value = "id") val id: kotlin.Long? = null, + @SerialName(value = "category") val category: Category? = null, + @SerialName(value = "tags") val tags: kotlin.Array? = 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", values(), values().map { it.value }.toTypedArray()) + } +} + + diff --git a/samples/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/models/Tag.kt b/samples/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/models/Tag.kt new file mode 100644 index 00000000000..b99b06e8bcd --- /dev/null +++ b/samples/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/models/Tag.kt @@ -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 +) + + diff --git a/samples/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/models/User.kt b/samples/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/models/User.kt new file mode 100644 index 00000000000..1950a140de6 --- /dev/null +++ b/samples/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/models/User.kt @@ -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 +) + + diff --git a/samples/client/petstore/kotlin-multiplatform/src/commonTest/kotlin/util/Coroutine.kt b/samples/client/petstore/kotlin-multiplatform/src/commonTest/kotlin/util/Coroutine.kt new file mode 100644 index 00000000000..fcff288bfef --- /dev/null +++ b/samples/client/petstore/kotlin-multiplatform/src/commonTest/kotlin/util/Coroutine.kt @@ -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 runTest(block: suspend CoroutineScope.() -> T): T diff --git a/samples/client/petstore/kotlin-multiplatform/src/iosTest/kotlin/util/Coroutine.kt b/samples/client/petstore/kotlin-multiplatform/src/iosTest/kotlin/util/Coroutine.kt new file mode 100644 index 00000000000..b8b36f3f759 --- /dev/null +++ b/samples/client/petstore/kotlin-multiplatform/src/iosTest/kotlin/util/Coroutine.kt @@ -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 runTest(block: suspend CoroutineScope.() -> T): T = kotlinx.coroutines.runBlocking(EmptyCoroutineContext, block) diff --git a/samples/client/petstore/kotlin-multiplatform/src/jvmTest/kotlin/util/Coroutine.kt b/samples/client/petstore/kotlin-multiplatform/src/jvmTest/kotlin/util/Coroutine.kt new file mode 100644 index 00000000000..b8b36f3f759 --- /dev/null +++ b/samples/client/petstore/kotlin-multiplatform/src/jvmTest/kotlin/util/Coroutine.kt @@ -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 runTest(block: suspend CoroutineScope.() -> T): T = kotlinx.coroutines.runBlocking(EmptyCoroutineContext, block) diff --git a/samples/client/petstore/kotlin-string/settings.gradle b/samples/client/petstore/kotlin-string/settings.gradle index 39b507d9963..9699edc8713 100644 --- a/samples/client/petstore/kotlin-string/settings.gradle +++ b/samples/client/petstore/kotlin-string/settings.gradle @@ -1 +1,2 @@ + rootProject.name = 'kotlin-petstore-string' \ No newline at end of file diff --git a/samples/client/petstore/kotlin-string/src/main/kotlin/org/openapitools/client/infrastructure/ApiAbstractions.kt b/samples/client/petstore/kotlin-string/src/main/kotlin/org/openapitools/client/infrastructure/ApiAbstractions.kt index c2c3f1f0eae..f97cb88d233 100644 --- a/samples/client/petstore/kotlin-string/src/main/kotlin/org/openapitools/client/infrastructure/ApiAbstractions.kt +++ b/samples/client/petstore/kotlin-string/src/main/kotlin/org/openapitools/client/infrastructure/ApiAbstractions.kt @@ -12,9 +12,12 @@ fun collectionDelimiter(collectionFormat: String) = when(collectionFormat) { val defaultMultiValueConverter: (item: Any?) -> String = { item -> "$item" } -fun toMultiValue(items: List, collectionFormat: String, map: (item: Any?) -> String = defaultMultiValueConverter): List { +fun toMultiValue(items: Array, collectionFormat: String, map: (item: T) -> String = defaultMultiValueConverter) + = toMultiValue(items.asIterable(), collectionFormat, map) + +fun toMultiValue(items: Iterable, collectionFormat: String, map: (item: T) -> String = defaultMultiValueConverter): List { 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)) } } \ No newline at end of file diff --git a/samples/client/petstore/kotlin-string/src/main/kotlin/org/openapitools/client/models/ApiResponse.kt b/samples/client/petstore/kotlin-string/src/main/kotlin/org/openapitools/client/models/ApiResponse.kt index b8b15769853..ada15fee7a1 100644 --- a/samples/client/petstore/kotlin-string/src/main/kotlin/org/openapitools/client/models/ApiResponse.kt +++ b/samples/client/petstore/kotlin-string/src/main/kotlin/org/openapitools/client/models/ApiResponse.kt @@ -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 ) - diff --git a/samples/client/petstore/kotlin-string/src/main/kotlin/org/openapitools/client/models/Category.kt b/samples/client/petstore/kotlin-string/src/main/kotlin/org/openapitools/client/models/Category.kt index 2cb38b9fba5..426a0e51592 100644 --- a/samples/client/petstore/kotlin-string/src/main/kotlin/org/openapitools/client/models/Category.kt +++ b/samples/client/petstore/kotlin-string/src/main/kotlin/org/openapitools/client/models/Category.kt @@ -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 ) - diff --git a/samples/client/petstore/kotlin-string/src/main/kotlin/org/openapitools/client/models/Order.kt b/samples/client/petstore/kotlin-string/src/main/kotlin/org/openapitools/client/models/Order.kt index d979b8b691a..38be465c021 100644 --- a/samples/client/petstore/kotlin-string/src/main/kotlin/org/openapitools/client/models/Order.kt +++ b/samples/client/petstore/kotlin-string/src/main/kotlin/org/openapitools/client/models/Order.kt @@ -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"); + } + } - diff --git a/samples/client/petstore/kotlin-string/src/main/kotlin/org/openapitools/client/models/Pet.kt b/samples/client/petstore/kotlin-string/src/main/kotlin/org/openapitools/client/models/Pet.kt index 9ee00ac631e..d870b69e5e7 100644 --- a/samples/client/petstore/kotlin-string/src/main/kotlin/org/openapitools/client/models/Pet.kt +++ b/samples/client/petstore/kotlin-string/src/main/kotlin/org/openapitools/client/models/Pet.kt @@ -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"); + } + } - diff --git a/samples/client/petstore/kotlin-string/src/main/kotlin/org/openapitools/client/models/Tag.kt b/samples/client/petstore/kotlin-string/src/main/kotlin/org/openapitools/client/models/Tag.kt index 475acce8a0a..f9ef87e13fb 100644 --- a/samples/client/petstore/kotlin-string/src/main/kotlin/org/openapitools/client/models/Tag.kt +++ b/samples/client/petstore/kotlin-string/src/main/kotlin/org/openapitools/client/models/Tag.kt @@ -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 ) - diff --git a/samples/client/petstore/kotlin-string/src/main/kotlin/org/openapitools/client/models/User.kt b/samples/client/petstore/kotlin-string/src/main/kotlin/org/openapitools/client/models/User.kt index 0cc681309b4..dfd63806da9 100644 --- a/samples/client/petstore/kotlin-string/src/main/kotlin/org/openapitools/client/models/User.kt +++ b/samples/client/petstore/kotlin-string/src/main/kotlin/org/openapitools/client/models/User.kt @@ -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 ) - diff --git a/samples/client/petstore/kotlin-threetenbp/settings.gradle b/samples/client/petstore/kotlin-threetenbp/settings.gradle index e786c8eb23f..1f071e0d3ca 100644 --- a/samples/client/petstore/kotlin-threetenbp/settings.gradle +++ b/samples/client/petstore/kotlin-threetenbp/settings.gradle @@ -1 +1,2 @@ + rootProject.name = 'kotlin-petstore-threetenbp' \ No newline at end of file diff --git a/samples/client/petstore/kotlin-threetenbp/src/main/kotlin/org/openapitools/client/infrastructure/ApiAbstractions.kt b/samples/client/petstore/kotlin-threetenbp/src/main/kotlin/org/openapitools/client/infrastructure/ApiAbstractions.kt index c2c3f1f0eae..f97cb88d233 100644 --- a/samples/client/petstore/kotlin-threetenbp/src/main/kotlin/org/openapitools/client/infrastructure/ApiAbstractions.kt +++ b/samples/client/petstore/kotlin-threetenbp/src/main/kotlin/org/openapitools/client/infrastructure/ApiAbstractions.kt @@ -12,9 +12,12 @@ fun collectionDelimiter(collectionFormat: String) = when(collectionFormat) { val defaultMultiValueConverter: (item: Any?) -> String = { item -> "$item" } -fun toMultiValue(items: List, collectionFormat: String, map: (item: Any?) -> String = defaultMultiValueConverter): List { +fun toMultiValue(items: Array, collectionFormat: String, map: (item: T) -> String = defaultMultiValueConverter) + = toMultiValue(items.asIterable(), collectionFormat, map) + +fun toMultiValue(items: Iterable, collectionFormat: String, map: (item: T) -> String = defaultMultiValueConverter): List { 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)) } } \ No newline at end of file diff --git a/samples/client/petstore/kotlin-threetenbp/src/main/kotlin/org/openapitools/client/models/ApiResponse.kt b/samples/client/petstore/kotlin-threetenbp/src/main/kotlin/org/openapitools/client/models/ApiResponse.kt index b8b15769853..ada15fee7a1 100644 --- a/samples/client/petstore/kotlin-threetenbp/src/main/kotlin/org/openapitools/client/models/ApiResponse.kt +++ b/samples/client/petstore/kotlin-threetenbp/src/main/kotlin/org/openapitools/client/models/ApiResponse.kt @@ -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 ) - diff --git a/samples/client/petstore/kotlin-threetenbp/src/main/kotlin/org/openapitools/client/models/Category.kt b/samples/client/petstore/kotlin-threetenbp/src/main/kotlin/org/openapitools/client/models/Category.kt index 2cb38b9fba5..426a0e51592 100644 --- a/samples/client/petstore/kotlin-threetenbp/src/main/kotlin/org/openapitools/client/models/Category.kt +++ b/samples/client/petstore/kotlin-threetenbp/src/main/kotlin/org/openapitools/client/models/Category.kt @@ -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 ) - diff --git a/samples/client/petstore/kotlin-threetenbp/src/main/kotlin/org/openapitools/client/models/Order.kt b/samples/client/petstore/kotlin-threetenbp/src/main/kotlin/org/openapitools/client/models/Order.kt index 6f1657150d8..abf5219de33 100644 --- a/samples/client/petstore/kotlin-threetenbp/src/main/kotlin/org/openapitools/client/models/Order.kt +++ b/samples/client/petstore/kotlin-threetenbp/src/main/kotlin/org/openapitools/client/models/Order.kt @@ -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"); + } + } - diff --git a/samples/client/petstore/kotlin-threetenbp/src/main/kotlin/org/openapitools/client/models/Pet.kt b/samples/client/petstore/kotlin-threetenbp/src/main/kotlin/org/openapitools/client/models/Pet.kt index 9ee00ac631e..d870b69e5e7 100644 --- a/samples/client/petstore/kotlin-threetenbp/src/main/kotlin/org/openapitools/client/models/Pet.kt +++ b/samples/client/petstore/kotlin-threetenbp/src/main/kotlin/org/openapitools/client/models/Pet.kt @@ -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"); + } + } - diff --git a/samples/client/petstore/kotlin-threetenbp/src/main/kotlin/org/openapitools/client/models/Tag.kt b/samples/client/petstore/kotlin-threetenbp/src/main/kotlin/org/openapitools/client/models/Tag.kt index 475acce8a0a..f9ef87e13fb 100644 --- a/samples/client/petstore/kotlin-threetenbp/src/main/kotlin/org/openapitools/client/models/Tag.kt +++ b/samples/client/petstore/kotlin-threetenbp/src/main/kotlin/org/openapitools/client/models/Tag.kt @@ -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 ) - diff --git a/samples/client/petstore/kotlin-threetenbp/src/main/kotlin/org/openapitools/client/models/User.kt b/samples/client/petstore/kotlin-threetenbp/src/main/kotlin/org/openapitools/client/models/User.kt index 0cc681309b4..dfd63806da9 100644 --- a/samples/client/petstore/kotlin-threetenbp/src/main/kotlin/org/openapitools/client/models/User.kt +++ b/samples/client/petstore/kotlin-threetenbp/src/main/kotlin/org/openapitools/client/models/User.kt @@ -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 ) - diff --git a/samples/client/petstore/kotlin/settings.gradle b/samples/client/petstore/kotlin/settings.gradle index 17e020387e2..7540d01de36 100644 --- a/samples/client/petstore/kotlin/settings.gradle +++ b/samples/client/petstore/kotlin/settings.gradle @@ -1 +1,2 @@ + rootProject.name = 'kotlin-petstore-client' \ No newline at end of file diff --git a/samples/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/infrastructure/ApiAbstractions.kt b/samples/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/infrastructure/ApiAbstractions.kt index c2c3f1f0eae..f97cb88d233 100644 --- a/samples/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/infrastructure/ApiAbstractions.kt +++ b/samples/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/infrastructure/ApiAbstractions.kt @@ -12,9 +12,12 @@ fun collectionDelimiter(collectionFormat: String) = when(collectionFormat) { val defaultMultiValueConverter: (item: Any?) -> String = { item -> "$item" } -fun toMultiValue(items: List, collectionFormat: String, map: (item: Any?) -> String = defaultMultiValueConverter): List { +fun toMultiValue(items: Array, collectionFormat: String, map: (item: T) -> String = defaultMultiValueConverter) + = toMultiValue(items.asIterable(), collectionFormat, map) + +fun toMultiValue(items: Iterable, collectionFormat: String, map: (item: T) -> String = defaultMultiValueConverter): List { 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)) } } \ No newline at end of file diff --git a/samples/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/ApiResponse.kt b/samples/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/ApiResponse.kt index b8b15769853..ada15fee7a1 100644 --- a/samples/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/ApiResponse.kt +++ b/samples/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/ApiResponse.kt @@ -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 ) - diff --git a/samples/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/Category.kt b/samples/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/Category.kt index 2cb38b9fba5..426a0e51592 100644 --- a/samples/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/Category.kt +++ b/samples/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/Category.kt @@ -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 ) - diff --git a/samples/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/Order.kt b/samples/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/Order.kt index e77abd68d51..2e9074a650a 100644 --- a/samples/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/Order.kt +++ b/samples/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/Order.kt @@ -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"); + } + } - diff --git a/samples/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/Pet.kt b/samples/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/Pet.kt index 9ee00ac631e..d870b69e5e7 100644 --- a/samples/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/Pet.kt +++ b/samples/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/Pet.kt @@ -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"); + } + } - diff --git a/samples/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/Tag.kt b/samples/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/Tag.kt index 475acce8a0a..f9ef87e13fb 100644 --- a/samples/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/Tag.kt +++ b/samples/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/Tag.kt @@ -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 ) - diff --git a/samples/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/User.kt b/samples/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/User.kt index 0cc681309b4..dfd63806da9 100644 --- a/samples/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/User.kt +++ b/samples/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/User.kt @@ -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 ) - diff --git a/samples/openapi3/client/petstore/kotlin-multiplatform/.openapi-generator-ignore b/samples/openapi3/client/petstore/kotlin-multiplatform/.openapi-generator-ignore new file mode 100644 index 00000000000..7484ee590a3 --- /dev/null +++ b/samples/openapi3/client/petstore/kotlin-multiplatform/.openapi-generator-ignore @@ -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 diff --git a/samples/openapi3/client/petstore/kotlin-multiplatform/.openapi-generator/VERSION b/samples/openapi3/client/petstore/kotlin-multiplatform/.openapi-generator/VERSION new file mode 100644 index 00000000000..0e97bd19efb --- /dev/null +++ b/samples/openapi3/client/petstore/kotlin-multiplatform/.openapi-generator/VERSION @@ -0,0 +1 @@ +4.1.3-SNAPSHOT \ No newline at end of file diff --git a/samples/openapi3/client/petstore/kotlin-multiplatform/README.md b/samples/openapi3/client/petstore/kotlin-multiplatform/README.md new file mode 100644 index 00000000000..36d27771012 --- /dev/null +++ b/samples/openapi3/client/petstore/kotlin-multiplatform/README.md @@ -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. + + + +## 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 + + + +## 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) + + + +## Documentation for Authorization + + +### api_key + +- **Type**: API key +- **API key parameter name**: api_key +- **Location**: HTTP header + + +### api_key_query + +- **Type**: API key +- **API key parameter name**: api_key_query +- **Location**: URL query string + + +### bearer_test + +- **Type**: HTTP basic authentication + + +### http_basic_test + +- **Type**: HTTP basic authentication + + +### 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 + diff --git a/samples/openapi3/client/petstore/kotlin-multiplatform/build.gradle b/samples/openapi3/client/petstore/kotlin-multiplatform/build.gradle new file mode 100644 index 00000000000..c976992112f --- /dev/null +++ b/samples/openapi3/client/petstore/kotlin-multiplatform/build.gradle @@ -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 +} diff --git a/samples/openapi3/client/petstore/kotlin-multiplatform/docs/200Response.md b/samples/openapi3/client/petstore/kotlin-multiplatform/docs/200Response.md new file mode 100644 index 00000000000..53c1edacfb8 --- /dev/null +++ b/samples/openapi3/client/petstore/kotlin-multiplatform/docs/200Response.md @@ -0,0 +1,11 @@ + +# Model200Response + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**name** | **kotlin.Int** | | [optional] +**propertyClass** | **kotlin.String** | | [optional] + + + diff --git a/samples/openapi3/client/petstore/kotlin-multiplatform/docs/AdditionalPropertiesClass.md b/samples/openapi3/client/petstore/kotlin-multiplatform/docs/AdditionalPropertiesClass.md new file mode 100644 index 00000000000..1025301ce94 --- /dev/null +++ b/samples/openapi3/client/petstore/kotlin-multiplatform/docs/AdditionalPropertiesClass.md @@ -0,0 +1,11 @@ + +# AdditionalPropertiesClass + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**mapProperty** | **kotlin.collections.Map<kotlin.String, kotlin.String>** | | [optional] +**mapOfMapProperty** | **kotlin.collections.Map<kotlin.String, kotlin.collections.Map<kotlin.String, kotlin.String>>** | | [optional] + + + diff --git a/samples/openapi3/client/petstore/kotlin-multiplatform/docs/Animal.md b/samples/openapi3/client/petstore/kotlin-multiplatform/docs/Animal.md new file mode 100644 index 00000000000..5ce5a4972c8 --- /dev/null +++ b/samples/openapi3/client/petstore/kotlin-multiplatform/docs/Animal.md @@ -0,0 +1,11 @@ + +# Animal + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**className** | **kotlin.String** | | +**color** | **kotlin.String** | | [optional] + + + diff --git a/samples/openapi3/client/petstore/kotlin-multiplatform/docs/AnotherFakeApi.md b/samples/openapi3/client/petstore/kotlin-multiplatform/docs/AnotherFakeApi.md new file mode 100644 index 00000000000..55d482238db --- /dev/null +++ b/samples/openapi3/client/petstore/kotlin-multiplatform/docs/AnotherFakeApi.md @@ -0,0 +1,56 @@ +# AnotherFakeApi + +All URIs are relative to *http://petstore.swagger.io:80/v2* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**call123testSpecialTags**](AnotherFakeApi.md#call123testSpecialTags) | **PATCH** /another-fake/dummy | To test special tags + + + +# **call123testSpecialTags** +> Client call123testSpecialTags(client) + +To test special tags + +To test special tags and operation ID starting with number + +### Example +```kotlin +// Import classes: +//import org.openapitools.client.infrastructure.* +//import org.openapitools.client.models.* + +val apiInstance = AnotherFakeApi() +val client : Client = // Client | client model +try { + val result : Client = apiInstance.call123testSpecialTags(client) + println(result) +} catch (e: ClientException) { + println("4xx response calling AnotherFakeApi#call123testSpecialTags") + e.printStackTrace() +} catch (e: ServerException) { + println("5xx response calling AnotherFakeApi#call123testSpecialTags") + e.printStackTrace() +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **client** | [**Client**](Client.md)| client model | + +### Return type + +[**Client**](Client.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: application/json + diff --git a/samples/openapi3/client/petstore/kotlin-multiplatform/docs/ApiResponse.md b/samples/openapi3/client/petstore/kotlin-multiplatform/docs/ApiResponse.md new file mode 100644 index 00000000000..6b4c6bf2779 --- /dev/null +++ b/samples/openapi3/client/petstore/kotlin-multiplatform/docs/ApiResponse.md @@ -0,0 +1,12 @@ + +# ApiResponse + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**code** | **kotlin.Int** | | [optional] +**type** | **kotlin.String** | | [optional] +**message** | **kotlin.String** | | [optional] + + + diff --git a/samples/openapi3/client/petstore/kotlin-multiplatform/docs/ArrayOfArrayOfNumberOnly.md b/samples/openapi3/client/petstore/kotlin-multiplatform/docs/ArrayOfArrayOfNumberOnly.md new file mode 100644 index 00000000000..7d57b3c840f --- /dev/null +++ b/samples/openapi3/client/petstore/kotlin-multiplatform/docs/ArrayOfArrayOfNumberOnly.md @@ -0,0 +1,10 @@ + +# ArrayOfArrayOfNumberOnly + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**arrayArrayNumber** | **kotlin.Array<kotlin.Array<kotlin.Double>>** | | [optional] + + + diff --git a/samples/openapi3/client/petstore/kotlin-multiplatform/docs/ArrayOfNumberOnly.md b/samples/openapi3/client/petstore/kotlin-multiplatform/docs/ArrayOfNumberOnly.md new file mode 100644 index 00000000000..e5259bbe3e5 --- /dev/null +++ b/samples/openapi3/client/petstore/kotlin-multiplatform/docs/ArrayOfNumberOnly.md @@ -0,0 +1,10 @@ + +# ArrayOfNumberOnly + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**arrayNumber** | **kotlin.Array<kotlin.Double>** | | [optional] + + + diff --git a/samples/openapi3/client/petstore/kotlin-multiplatform/docs/ArrayTest.md b/samples/openapi3/client/petstore/kotlin-multiplatform/docs/ArrayTest.md new file mode 100644 index 00000000000..aa0bbbe936c --- /dev/null +++ b/samples/openapi3/client/petstore/kotlin-multiplatform/docs/ArrayTest.md @@ -0,0 +1,12 @@ + +# ArrayTest + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**arrayOfString** | **kotlin.Array<kotlin.String>** | | [optional] +**arrayArrayOfInteger** | **kotlin.Array<kotlin.Array<kotlin.Long>>** | | [optional] +**arrayArrayOfModel** | **kotlin.Array<kotlin.Array<ReadOnlyFirst>>** | | [optional] + + + diff --git a/samples/openapi3/client/petstore/kotlin-multiplatform/docs/Capitalization.md b/samples/openapi3/client/petstore/kotlin-multiplatform/docs/Capitalization.md new file mode 100644 index 00000000000..9d44a82fb7f --- /dev/null +++ b/samples/openapi3/client/petstore/kotlin-multiplatform/docs/Capitalization.md @@ -0,0 +1,15 @@ + +# Capitalization + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**smallCamel** | **kotlin.String** | | [optional] +**capitalCamel** | **kotlin.String** | | [optional] +**smallSnake** | **kotlin.String** | | [optional] +**capitalSnake** | **kotlin.String** | | [optional] +**scAETHFlowPoints** | **kotlin.String** | | [optional] +**ATT_NAME** | **kotlin.String** | Name of the pet | [optional] + + + diff --git a/samples/openapi3/client/petstore/kotlin-multiplatform/docs/Cat.md b/samples/openapi3/client/petstore/kotlin-multiplatform/docs/Cat.md new file mode 100644 index 00000000000..b6da7c47ced --- /dev/null +++ b/samples/openapi3/client/petstore/kotlin-multiplatform/docs/Cat.md @@ -0,0 +1,10 @@ + +# Cat + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**declawed** | **kotlin.Boolean** | | [optional] + + + diff --git a/samples/openapi3/client/petstore/kotlin-multiplatform/docs/CatAllOf.md b/samples/openapi3/client/petstore/kotlin-multiplatform/docs/CatAllOf.md new file mode 100644 index 00000000000..fb8883197a1 --- /dev/null +++ b/samples/openapi3/client/petstore/kotlin-multiplatform/docs/CatAllOf.md @@ -0,0 +1,10 @@ + +# CatAllOf + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**declawed** | **kotlin.Boolean** | | [optional] + + + diff --git a/samples/openapi3/client/petstore/kotlin-multiplatform/docs/Category.md b/samples/openapi3/client/petstore/kotlin-multiplatform/docs/Category.md new file mode 100644 index 00000000000..92c9e2243d6 --- /dev/null +++ b/samples/openapi3/client/petstore/kotlin-multiplatform/docs/Category.md @@ -0,0 +1,11 @@ + +# Category + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **kotlin.Long** | | [optional] +**name** | **kotlin.String** | | + + + diff --git a/samples/openapi3/client/petstore/kotlin-multiplatform/docs/ClassModel.md b/samples/openapi3/client/petstore/kotlin-multiplatform/docs/ClassModel.md new file mode 100644 index 00000000000..50ad61b51a5 --- /dev/null +++ b/samples/openapi3/client/petstore/kotlin-multiplatform/docs/ClassModel.md @@ -0,0 +1,10 @@ + +# ClassModel + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**propertyClass** | **kotlin.String** | | [optional] + + + diff --git a/samples/openapi3/client/petstore/kotlin-multiplatform/docs/Client.md b/samples/openapi3/client/petstore/kotlin-multiplatform/docs/Client.md new file mode 100644 index 00000000000..11afbcf0c9f --- /dev/null +++ b/samples/openapi3/client/petstore/kotlin-multiplatform/docs/Client.md @@ -0,0 +1,10 @@ + +# Client + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**client** | **kotlin.String** | | [optional] + + + diff --git a/samples/openapi3/client/petstore/kotlin-multiplatform/docs/DefaultApi.md b/samples/openapi3/client/petstore/kotlin-multiplatform/docs/DefaultApi.md new file mode 100644 index 00000000000..784be537594 --- /dev/null +++ b/samples/openapi3/client/petstore/kotlin-multiplatform/docs/DefaultApi.md @@ -0,0 +1,50 @@ +# DefaultApi + +All URIs are relative to *http://petstore.swagger.io:80/v2* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**fooGet**](DefaultApi.md#fooGet) | **GET** /foo | + + + +# **fooGet** +> InlineResponseDefault fooGet() + + + +### Example +```kotlin +// Import classes: +//import org.openapitools.client.infrastructure.* +//import org.openapitools.client.models.* + +val apiInstance = DefaultApi() +try { + val result : InlineResponseDefault = apiInstance.fooGet() + println(result) +} catch (e: ClientException) { + println("4xx response calling DefaultApi#fooGet") + e.printStackTrace() +} catch (e: ServerException) { + println("5xx response calling DefaultApi#fooGet") + e.printStackTrace() +} +``` + +### Parameters +This endpoint does not need any parameter. + +### Return type + +[**InlineResponseDefault**](InlineResponseDefault.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + diff --git a/samples/openapi3/client/petstore/kotlin-multiplatform/docs/Dog.md b/samples/openapi3/client/petstore/kotlin-multiplatform/docs/Dog.md new file mode 100644 index 00000000000..41d9c6ba0d1 --- /dev/null +++ b/samples/openapi3/client/petstore/kotlin-multiplatform/docs/Dog.md @@ -0,0 +1,10 @@ + +# Dog + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**breed** | **kotlin.String** | | [optional] + + + diff --git a/samples/openapi3/client/petstore/kotlin-multiplatform/docs/DogAllOf.md b/samples/openapi3/client/petstore/kotlin-multiplatform/docs/DogAllOf.md new file mode 100644 index 00000000000..6b14d5e9147 --- /dev/null +++ b/samples/openapi3/client/petstore/kotlin-multiplatform/docs/DogAllOf.md @@ -0,0 +1,10 @@ + +# DogAllOf + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**breed** | **kotlin.String** | | [optional] + + + diff --git a/samples/openapi3/client/petstore/kotlin-multiplatform/docs/EnumArrays.md b/samples/openapi3/client/petstore/kotlin-multiplatform/docs/EnumArrays.md new file mode 100644 index 00000000000..719084e5f94 --- /dev/null +++ b/samples/openapi3/client/petstore/kotlin-multiplatform/docs/EnumArrays.md @@ -0,0 +1,25 @@ + +# EnumArrays + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**justSymbol** | [**inline**](#JustSymbolEnum) | | [optional] +**arrayEnum** | [**inline**](#kotlin.Array<ArrayEnumEnum>) | | [optional] + + + +## Enum: just_symbol +Name | Value +---- | ----- +justSymbol | >=, $ + + + +## Enum: array_enum +Name | Value +---- | ----- +arrayEnum | fish, crab + + + diff --git a/samples/openapi3/client/petstore/kotlin-multiplatform/docs/EnumClass.md b/samples/openapi3/client/petstore/kotlin-multiplatform/docs/EnumClass.md new file mode 100644 index 00000000000..5ddb262871f --- /dev/null +++ b/samples/openapi3/client/petstore/kotlin-multiplatform/docs/EnumClass.md @@ -0,0 +1,14 @@ + +# EnumClass + +## Enum + + + * `abc` (value: `"_abc"`) + + * `minusEfg` (value: `"-efg"`) + + * `leftParenthesisXyzRightParenthesis` (value: `"(xyz)"`) + + + diff --git a/samples/openapi3/client/petstore/kotlin-multiplatform/docs/EnumTest.md b/samples/openapi3/client/petstore/kotlin-multiplatform/docs/EnumTest.md new file mode 100644 index 00000000000..bdef500a433 --- /dev/null +++ b/samples/openapi3/client/petstore/kotlin-multiplatform/docs/EnumTest.md @@ -0,0 +1,45 @@ + +# EnumTest + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**enumString** | [**inline**](#EnumStringEnum) | | [optional] +**enumStringRequired** | [**inline**](#EnumStringRequiredEnum) | | +**enumInteger** | [**inline**](#EnumIntegerEnum) | | [optional] +**enumNumber** | [**inline**](#EnumNumberEnum) | | [optional] +**outerEnum** | [**OuterEnum**](OuterEnum.md) | | [optional] +**outerEnumInteger** | [**OuterEnumInteger**](OuterEnumInteger.md) | | [optional] +**outerEnumDefaultValue** | [**OuterEnumDefaultValue**](OuterEnumDefaultValue.md) | | [optional] +**outerEnumIntegerDefaultValue** | [**OuterEnumIntegerDefaultValue**](OuterEnumIntegerDefaultValue.md) | | [optional] + + + +## Enum: enum_string +Name | Value +---- | ----- +enumString | UPPER, lower, + + + +## Enum: enum_string_required +Name | Value +---- | ----- +enumStringRequired | UPPER, lower, + + + +## Enum: enum_integer +Name | Value +---- | ----- +enumInteger | 1, -1 + + + +## Enum: enum_number +Name | Value +---- | ----- +enumNumber | 1.1, -1.2 + + + diff --git a/samples/openapi3/client/petstore/kotlin-multiplatform/docs/FakeApi.md b/samples/openapi3/client/petstore/kotlin-multiplatform/docs/FakeApi.md new file mode 100644 index 00000000000..88394442015 --- /dev/null +++ b/samples/openapi3/client/petstore/kotlin-multiplatform/docs/FakeApi.md @@ -0,0 +1,727 @@ +# FakeApi + +All URIs are relative to *http://petstore.swagger.io:80/v2* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**fakeHealthGet**](FakeApi.md#fakeHealthGet) | **GET** /fake/health | Health check endpoint +[**fakeOuterBooleanSerialize**](FakeApi.md#fakeOuterBooleanSerialize) | **POST** /fake/outer/boolean | +[**fakeOuterCompositeSerialize**](FakeApi.md#fakeOuterCompositeSerialize) | **POST** /fake/outer/composite | +[**fakeOuterNumberSerialize**](FakeApi.md#fakeOuterNumberSerialize) | **POST** /fake/outer/number | +[**fakeOuterStringSerialize**](FakeApi.md#fakeOuterStringSerialize) | **POST** /fake/outer/string | +[**testBodyWithFileSchema**](FakeApi.md#testBodyWithFileSchema) | **PUT** /fake/body-with-file-schema | +[**testBodyWithQueryParams**](FakeApi.md#testBodyWithQueryParams) | **PUT** /fake/body-with-query-params | +[**testClientModel**](FakeApi.md#testClientModel) | **PATCH** /fake | To test \"client\" model +[**testEndpointParameters**](FakeApi.md#testEndpointParameters) | **POST** /fake | Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 +[**testEnumParameters**](FakeApi.md#testEnumParameters) | **GET** /fake | To test enum parameters +[**testGroupParameters**](FakeApi.md#testGroupParameters) | **DELETE** /fake | Fake endpoint to test group parameters (optional) +[**testInlineAdditionalProperties**](FakeApi.md#testInlineAdditionalProperties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties +[**testJsonFormData**](FakeApi.md#testJsonFormData) | **GET** /fake/jsonFormData | test json serialization of form data +[**testQueryParameterCollectionFormat**](FakeApi.md#testQueryParameterCollectionFormat) | **PUT** /fake/test-query-paramters | + + + +# **fakeHealthGet** +> HealthCheckResult fakeHealthGet() + +Health check endpoint + +### Example +```kotlin +// Import classes: +//import org.openapitools.client.infrastructure.* +//import org.openapitools.client.models.* + +val apiInstance = FakeApi() +try { + val result : HealthCheckResult = apiInstance.fakeHealthGet() + println(result) +} catch (e: ClientException) { + println("4xx response calling FakeApi#fakeHealthGet") + e.printStackTrace() +} catch (e: ServerException) { + println("5xx response calling FakeApi#fakeHealthGet") + e.printStackTrace() +} +``` + +### Parameters +This endpoint does not need any parameter. + +### Return type + +[**HealthCheckResult**](HealthCheckResult.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + + +# **fakeOuterBooleanSerialize** +> kotlin.Boolean fakeOuterBooleanSerialize(body) + + + +Test serialization of outer boolean types + +### Example +```kotlin +// Import classes: +//import org.openapitools.client.infrastructure.* +//import org.openapitools.client.models.* + +val apiInstance = FakeApi() +val body : kotlin.Boolean = true // kotlin.Boolean | Input boolean as post body +try { + val result : kotlin.Boolean = apiInstance.fakeOuterBooleanSerialize(body) + println(result) +} catch (e: ClientException) { + println("4xx response calling FakeApi#fakeOuterBooleanSerialize") + e.printStackTrace() +} catch (e: ServerException) { + println("5xx response calling FakeApi#fakeOuterBooleanSerialize") + e.printStackTrace() +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | **kotlin.Boolean**| Input boolean as post body | [optional] + +### Return type + +**kotlin.Boolean** + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: */* + + +# **fakeOuterCompositeSerialize** +> OuterComposite fakeOuterCompositeSerialize(outerComposite) + + + +Test serialization of object with outer number type + +### Example +```kotlin +// Import classes: +//import org.openapitools.client.infrastructure.* +//import org.openapitools.client.models.* + +val apiInstance = FakeApi() +val outerComposite : OuterComposite = // OuterComposite | Input composite as post body +try { + val result : OuterComposite = apiInstance.fakeOuterCompositeSerialize(outerComposite) + println(result) +} catch (e: ClientException) { + println("4xx response calling FakeApi#fakeOuterCompositeSerialize") + e.printStackTrace() +} catch (e: ServerException) { + println("5xx response calling FakeApi#fakeOuterCompositeSerialize") + e.printStackTrace() +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **outerComposite** | [**OuterComposite**](OuterComposite.md)| Input composite as post body | [optional] + +### Return type + +[**OuterComposite**](OuterComposite.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: */* + + +# **fakeOuterNumberSerialize** +> kotlin.Double fakeOuterNumberSerialize(body) + + + +Test serialization of outer number types + +### Example +```kotlin +// Import classes: +//import org.openapitools.client.infrastructure.* +//import org.openapitools.client.models.* + +val apiInstance = FakeApi() +val body : kotlin.Double = 8.14 // kotlin.Double | Input number as post body +try { + val result : kotlin.Double = apiInstance.fakeOuterNumberSerialize(body) + println(result) +} catch (e: ClientException) { + println("4xx response calling FakeApi#fakeOuterNumberSerialize") + e.printStackTrace() +} catch (e: ServerException) { + println("5xx response calling FakeApi#fakeOuterNumberSerialize") + e.printStackTrace() +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | **kotlin.Double**| Input number as post body | [optional] + +### Return type + +**kotlin.Double** + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: */* + + +# **fakeOuterStringSerialize** +> kotlin.String fakeOuterStringSerialize(body) + + + +Test serialization of outer string types + +### Example +```kotlin +// Import classes: +//import org.openapitools.client.infrastructure.* +//import org.openapitools.client.models.* + +val apiInstance = FakeApi() +val body : kotlin.String = body_example // kotlin.String | Input string as post body +try { + val result : kotlin.String = apiInstance.fakeOuterStringSerialize(body) + println(result) +} catch (e: ClientException) { + println("4xx response calling FakeApi#fakeOuterStringSerialize") + e.printStackTrace() +} catch (e: ServerException) { + println("5xx response calling FakeApi#fakeOuterStringSerialize") + e.printStackTrace() +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | **kotlin.String**| Input string as post body | [optional] + +### Return type + +**kotlin.String** + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: */* + + +# **testBodyWithFileSchema** +> testBodyWithFileSchema(fileSchemaTestClass) + + + +For this test, the body for this request much reference a schema named `File`. + +### Example +```kotlin +// Import classes: +//import org.openapitools.client.infrastructure.* +//import org.openapitools.client.models.* + +val apiInstance = FakeApi() +val fileSchemaTestClass : FileSchemaTestClass = // FileSchemaTestClass | +try { + apiInstance.testBodyWithFileSchema(fileSchemaTestClass) +} catch (e: ClientException) { + println("4xx response calling FakeApi#testBodyWithFileSchema") + e.printStackTrace() +} catch (e: ServerException) { + println("5xx response calling FakeApi#testBodyWithFileSchema") + e.printStackTrace() +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **fileSchemaTestClass** | [**FileSchemaTestClass**](FileSchemaTestClass.md)| | + +### Return type + +null (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: Not defined + + +# **testBodyWithQueryParams** +> testBodyWithQueryParams(query, user) + + + +### Example +```kotlin +// Import classes: +//import org.openapitools.client.infrastructure.* +//import org.openapitools.client.models.* + +val apiInstance = FakeApi() +val query : kotlin.String = query_example // kotlin.String | +val user : User = // User | +try { + apiInstance.testBodyWithQueryParams(query, user) +} catch (e: ClientException) { + println("4xx response calling FakeApi#testBodyWithQueryParams") + e.printStackTrace() +} catch (e: ServerException) { + println("5xx response calling FakeApi#testBodyWithQueryParams") + e.printStackTrace() +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **query** | **kotlin.String**| | + **user** | [**User**](User.md)| | + +### Return type + +null (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: Not defined + + +# **testClientModel** +> Client testClientModel(client) + +To test \"client\" model + +To test \"client\" model + +### Example +```kotlin +// Import classes: +//import org.openapitools.client.infrastructure.* +//import org.openapitools.client.models.* + +val apiInstance = FakeApi() +val client : Client = // Client | client model +try { + val result : Client = apiInstance.testClientModel(client) + println(result) +} catch (e: ClientException) { + println("4xx response calling FakeApi#testClientModel") + e.printStackTrace() +} catch (e: ServerException) { + println("5xx response calling FakeApi#testClientModel") + e.printStackTrace() +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **client** | [**Client**](Client.md)| client model | + +### Return type + +[**Client**](Client.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: application/json + + +# **testEndpointParameters** +> testEndpointParameters(number, double, patternWithoutDelimiter, byte, integer, int32, int64, float, string, binary, date, dateTime, password, paramCallback) + +Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 + +Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 + +### Example +```kotlin +// Import classes: +//import org.openapitools.client.infrastructure.* +//import org.openapitools.client.models.* + +val apiInstance = FakeApi() +val number : kotlin.Double = 8.14 // kotlin.Double | None +val double : kotlin.Double = 1.2 // kotlin.Double | None +val patternWithoutDelimiter : kotlin.String = patternWithoutDelimiter_example // kotlin.String | None +val byte : kotlin.ByteArray = BYTE_ARRAY_DATA_HERE // kotlin.ByteArray | None +val integer : kotlin.Int = 56 // kotlin.Int | None +val int32 : kotlin.Int = 56 // kotlin.Int | None +val int64 : kotlin.Long = 789 // kotlin.Long | None +val float : kotlin.Float = 3.4 // kotlin.Float | None +val string : kotlin.String = string_example // kotlin.String | None +val binary : io.ktor.client.request.forms.InputProvider = BINARY_DATA_HERE // io.ktor.client.request.forms.InputProvider | None +val date : kotlin.String = 2013-10-20 // kotlin.String | None +val dateTime : kotlin.String = 2013-10-20T19:20:30+01:00 // kotlin.String | None +val password : kotlin.String = password_example // kotlin.String | None +val paramCallback : kotlin.String = paramCallback_example // kotlin.String | None +try { + apiInstance.testEndpointParameters(number, double, patternWithoutDelimiter, byte, integer, int32, int64, float, string, binary, date, dateTime, password, paramCallback) +} catch (e: ClientException) { + println("4xx response calling FakeApi#testEndpointParameters") + e.printStackTrace() +} catch (e: ServerException) { + println("5xx response calling FakeApi#testEndpointParameters") + e.printStackTrace() +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **number** | **kotlin.Double**| None | + **double** | **kotlin.Double**| None | + **patternWithoutDelimiter** | **kotlin.String**| None | + **byte** | **kotlin.ByteArray**| None | + **integer** | **kotlin.Int**| None | [optional] + **int32** | **kotlin.Int**| None | [optional] + **int64** | **kotlin.Long**| None | [optional] + **float** | **kotlin.Float**| None | [optional] + **string** | **kotlin.String**| None | [optional] + **binary** | **io.ktor.client.request.forms.InputProvider**| None | [optional] + **date** | **kotlin.String**| None | [optional] + **dateTime** | **kotlin.String**| None | [optional] + **password** | **kotlin.String**| None | [optional] + **paramCallback** | **kotlin.String**| None | [optional] + +### Return type + +null (empty response body) + +### Authorization + + +Configure http_basic_test: + ApiClient.username = "" + ApiClient.password = "" + +### HTTP request headers + + - **Content-Type**: application/x-www-form-urlencoded + - **Accept**: Not defined + + +# **testEnumParameters** +> testEnumParameters(enumHeaderStringArray, enumHeaderString, enumQueryStringArray, enumQueryString, enumQueryInteger, enumQueryDouble, enumFormStringArray, enumFormString) + +To test enum parameters + +To test enum parameters + +### Example +```kotlin +// Import classes: +//import org.openapitools.client.infrastructure.* +//import org.openapitools.client.models.* + +val apiInstance = FakeApi() +val enumHeaderStringArray : kotlin.Array = // kotlin.Array | Header parameter enum test (string array) +val enumHeaderString : kotlin.String = enumHeaderString_example // kotlin.String | Header parameter enum test (string) +val enumQueryStringArray : kotlin.Array = // kotlin.Array | Query parameter enum test (string array) +val enumQueryString : kotlin.String = enumQueryString_example // kotlin.String | Query parameter enum test (string) +val enumQueryInteger : kotlin.Int = 56 // kotlin.Int | Query parameter enum test (double) +val enumQueryDouble : kotlin.Double = 1.2 // kotlin.Double | Query parameter enum test (double) +val enumFormStringArray : kotlin.Array = enumFormStringArray_example // kotlin.Array | Form parameter enum test (string array) +val enumFormString : kotlin.String = enumFormString_example // kotlin.String | Form parameter enum test (string) +try { + apiInstance.testEnumParameters(enumHeaderStringArray, enumHeaderString, enumQueryStringArray, enumQueryString, enumQueryInteger, enumQueryDouble, enumFormStringArray, enumFormString) +} catch (e: ClientException) { + println("4xx response calling FakeApi#testEnumParameters") + e.printStackTrace() +} catch (e: ServerException) { + println("5xx response calling FakeApi#testEnumParameters") + e.printStackTrace() +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **enumHeaderStringArray** | [**kotlin.Array<kotlin.String>**](kotlin.String.md)| Header parameter enum test (string array) | [optional] [enum: >, $] + **enumHeaderString** | **kotlin.String**| Header parameter enum test (string) | [optional] [default to '-efg'] [enum: _abc, -efg, (xyz)] + **enumQueryStringArray** | [**kotlin.Array<kotlin.String>**](kotlin.String.md)| Query parameter enum test (string array) | [optional] [enum: >, $] + **enumQueryString** | **kotlin.String**| Query parameter enum test (string) | [optional] [default to '-efg'] [enum: _abc, -efg, (xyz)] + **enumQueryInteger** | **kotlin.Int**| Query parameter enum test (double) | [optional] [enum: 1, -2] + **enumQueryDouble** | **kotlin.Double**| Query parameter enum test (double) | [optional] [enum: 1.1, -1.2] + **enumFormStringArray** | [**kotlin.Array<kotlin.String>**](kotlin.String.md)| Form parameter enum test (string array) | [optional] [default to '$'] [enum: >, $] + **enumFormString** | **kotlin.String**| Form parameter enum test (string) | [optional] [default to '-efg'] [enum: _abc, -efg, (xyz)] + +### Return type + +null (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/x-www-form-urlencoded + - **Accept**: Not defined + + +# **testGroupParameters** +> testGroupParameters(requiredStringGroup, requiredBooleanGroup, requiredInt64Group, stringGroup, booleanGroup, int64Group) + +Fake endpoint to test group parameters (optional) + +Fake endpoint to test group parameters (optional) + +### Example +```kotlin +// Import classes: +//import org.openapitools.client.infrastructure.* +//import org.openapitools.client.models.* + +val apiInstance = FakeApi() +val requiredStringGroup : kotlin.Int = 56 // kotlin.Int | Required String in group parameters +val requiredBooleanGroup : kotlin.Boolean = true // kotlin.Boolean | Required Boolean in group parameters +val requiredInt64Group : kotlin.Long = 789 // kotlin.Long | Required Integer in group parameters +val stringGroup : kotlin.Int = 56 // kotlin.Int | String in group parameters +val booleanGroup : kotlin.Boolean = true // kotlin.Boolean | Boolean in group parameters +val int64Group : kotlin.Long = 789 // kotlin.Long | Integer in group parameters +try { + apiInstance.testGroupParameters(requiredStringGroup, requiredBooleanGroup, requiredInt64Group, stringGroup, booleanGroup, int64Group) +} catch (e: ClientException) { + println("4xx response calling FakeApi#testGroupParameters") + e.printStackTrace() +} catch (e: ServerException) { + println("5xx response calling FakeApi#testGroupParameters") + e.printStackTrace() +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **requiredStringGroup** | **kotlin.Int**| Required String in group parameters | + **requiredBooleanGroup** | **kotlin.Boolean**| Required Boolean in group parameters | + **requiredInt64Group** | **kotlin.Long**| Required Integer in group parameters | + **stringGroup** | **kotlin.Int**| String in group parameters | [optional] + **booleanGroup** | **kotlin.Boolean**| Boolean in group parameters | [optional] + **int64Group** | **kotlin.Long**| Integer in group parameters | [optional] + +### Return type + +null (empty response body) + +### Authorization + + +Configure bearer_test: + ApiClient.accessToken = "" + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: Not defined + + +# **testInlineAdditionalProperties** +> testInlineAdditionalProperties(requestBody) + +test inline additionalProperties + +### Example +```kotlin +// Import classes: +//import org.openapitools.client.infrastructure.* +//import org.openapitools.client.models.* + +val apiInstance = FakeApi() +val requestBody : kotlin.collections.Map = // kotlin.collections.Map | request body +try { + apiInstance.testInlineAdditionalProperties(requestBody) +} catch (e: ClientException) { + println("4xx response calling FakeApi#testInlineAdditionalProperties") + e.printStackTrace() +} catch (e: ServerException) { + println("5xx response calling FakeApi#testInlineAdditionalProperties") + e.printStackTrace() +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **requestBody** | [**kotlin.collections.Map<kotlin.String, kotlin.String>**](kotlin.String.md)| request body | + +### Return type + +null (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: Not defined + + +# **testJsonFormData** +> testJsonFormData(param, param2) + +test json serialization of form data + +### Example +```kotlin +// Import classes: +//import org.openapitools.client.infrastructure.* +//import org.openapitools.client.models.* + +val apiInstance = FakeApi() +val param : kotlin.String = param_example // kotlin.String | field1 +val param2 : kotlin.String = param2_example // kotlin.String | field2 +try { + apiInstance.testJsonFormData(param, param2) +} catch (e: ClientException) { + println("4xx response calling FakeApi#testJsonFormData") + e.printStackTrace() +} catch (e: ServerException) { + println("5xx response calling FakeApi#testJsonFormData") + e.printStackTrace() +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **param** | **kotlin.String**| field1 | + **param2** | **kotlin.String**| field2 | + +### Return type + +null (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/x-www-form-urlencoded + - **Accept**: Not defined + + +# **testQueryParameterCollectionFormat** +> testQueryParameterCollectionFormat(pipe, ioutil, http, url, context) + + + +To test the collection format in query parameters + +### Example +```kotlin +// Import classes: +//import org.openapitools.client.infrastructure.* +//import org.openapitools.client.models.* + +val apiInstance = FakeApi() +val pipe : kotlin.Array = // kotlin.Array | +val ioutil : kotlin.Array = // kotlin.Array | +val http : kotlin.Array = // kotlin.Array | +val url : kotlin.Array = // kotlin.Array | +val context : kotlin.Array = // kotlin.Array | +try { + apiInstance.testQueryParameterCollectionFormat(pipe, ioutil, http, url, context) +} catch (e: ClientException) { + println("4xx response calling FakeApi#testQueryParameterCollectionFormat") + e.printStackTrace() +} catch (e: ServerException) { + println("5xx response calling FakeApi#testQueryParameterCollectionFormat") + e.printStackTrace() +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **pipe** | [**kotlin.Array<kotlin.String>**](kotlin.String.md)| | + **ioutil** | [**kotlin.Array<kotlin.String>**](kotlin.String.md)| | + **http** | [**kotlin.Array<kotlin.String>**](kotlin.String.md)| | + **url** | [**kotlin.Array<kotlin.String>**](kotlin.String.md)| | + **context** | [**kotlin.Array<kotlin.String>**](kotlin.String.md)| | + +### Return type + +null (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: Not defined + diff --git a/samples/openapi3/client/petstore/kotlin-multiplatform/docs/FakeClassnameTags123Api.md b/samples/openapi3/client/petstore/kotlin-multiplatform/docs/FakeClassnameTags123Api.md new file mode 100644 index 00000000000..962dfd4d2dc --- /dev/null +++ b/samples/openapi3/client/petstore/kotlin-multiplatform/docs/FakeClassnameTags123Api.md @@ -0,0 +1,59 @@ +# FakeClassnameTags123Api + +All URIs are relative to *http://petstore.swagger.io:80/v2* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**testClassname**](FakeClassnameTags123Api.md#testClassname) | **PATCH** /fake_classname_test | To test class name in snake case + + + +# **testClassname** +> Client testClassname(client) + +To test class name in snake case + +To test class name in snake case + +### Example +```kotlin +// Import classes: +//import org.openapitools.client.infrastructure.* +//import org.openapitools.client.models.* + +val apiInstance = FakeClassnameTags123Api() +val client : Client = // Client | client model +try { + val result : Client = apiInstance.testClassname(client) + println(result) +} catch (e: ClientException) { + println("4xx response calling FakeClassnameTags123Api#testClassname") + e.printStackTrace() +} catch (e: ServerException) { + println("5xx response calling FakeClassnameTags123Api#testClassname") + e.printStackTrace() +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **client** | [**Client**](Client.md)| client model | + +### Return type + +[**Client**](Client.md) + +### Authorization + + +Configure api_key_query: + ApiClient.apiKey["api_key_query"] = "" + ApiClient.apiKeyPrefix["api_key_query"] = "" + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: application/json + diff --git a/samples/openapi3/client/petstore/kotlin-multiplatform/docs/FileSchemaTestClass.md b/samples/openapi3/client/petstore/kotlin-multiplatform/docs/FileSchemaTestClass.md new file mode 100644 index 00000000000..089e61862c2 --- /dev/null +++ b/samples/openapi3/client/petstore/kotlin-multiplatform/docs/FileSchemaTestClass.md @@ -0,0 +1,11 @@ + +# FileSchemaTestClass + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**file** | [**java.io.File**](java.io.File.md) | | [optional] +**files** | [**kotlin.Array<java.io.File>**](java.io.File.md) | | [optional] + + + diff --git a/samples/openapi3/client/petstore/kotlin-multiplatform/docs/Foo.md b/samples/openapi3/client/petstore/kotlin-multiplatform/docs/Foo.md new file mode 100644 index 00000000000..e3e9918872b --- /dev/null +++ b/samples/openapi3/client/petstore/kotlin-multiplatform/docs/Foo.md @@ -0,0 +1,10 @@ + +# Foo + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**bar** | **kotlin.String** | | [optional] + + + diff --git a/samples/openapi3/client/petstore/kotlin-multiplatform/docs/FormatTest.md b/samples/openapi3/client/petstore/kotlin-multiplatform/docs/FormatTest.md new file mode 100644 index 00000000000..b37c9f5f549 --- /dev/null +++ b/samples/openapi3/client/petstore/kotlin-multiplatform/docs/FormatTest.md @@ -0,0 +1,24 @@ + +# FormatTest + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**integer** | **kotlin.Int** | | [optional] +**int32** | **kotlin.Int** | | [optional] +**int64** | **kotlin.Long** | | [optional] +**number** | **kotlin.Double** | | +**float** | **kotlin.Float** | | [optional] +**double** | **kotlin.Double** | | [optional] +**string** | **kotlin.String** | | [optional] +**byte** | **kotlin.ByteArray** | | +**binary** | [**io.ktor.client.request.forms.InputProvider**](io.ktor.client.request.forms.InputProvider.md) | | [optional] +**date** | **kotlin.String** | | +**dateTime** | **kotlin.String** | | [optional] +**uuid** | [**java.util.UUID**](java.util.UUID.md) | | [optional] +**password** | **kotlin.String** | | +**patternWithDigits** | **kotlin.String** | A string that is a 10 digit number. Can have leading zeros. | [optional] +**patternWithDigitsAndDelimiter** | **kotlin.String** | A string starting with 'image_' (case insensitive) and one to three digits following i.e. Image_01. | [optional] + + + diff --git a/samples/openapi3/client/petstore/kotlin-multiplatform/docs/HasOnlyReadOnly.md b/samples/openapi3/client/petstore/kotlin-multiplatform/docs/HasOnlyReadOnly.md new file mode 100644 index 00000000000..22f5ebf5170 --- /dev/null +++ b/samples/openapi3/client/petstore/kotlin-multiplatform/docs/HasOnlyReadOnly.md @@ -0,0 +1,11 @@ + +# HasOnlyReadOnly + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**bar** | **kotlin.String** | | [optional] +**foo** | **kotlin.String** | | [optional] + + + diff --git a/samples/openapi3/client/petstore/kotlin-multiplatform/docs/HealthCheckResult.md b/samples/openapi3/client/petstore/kotlin-multiplatform/docs/HealthCheckResult.md new file mode 100644 index 00000000000..472dc310457 --- /dev/null +++ b/samples/openapi3/client/petstore/kotlin-multiplatform/docs/HealthCheckResult.md @@ -0,0 +1,10 @@ + +# HealthCheckResult + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**nullableMessage** | **kotlin.String** | | [optional] + + + diff --git a/samples/openapi3/client/petstore/kotlin-multiplatform/docs/InlineObject.md b/samples/openapi3/client/petstore/kotlin-multiplatform/docs/InlineObject.md new file mode 100644 index 00000000000..2156c70addf --- /dev/null +++ b/samples/openapi3/client/petstore/kotlin-multiplatform/docs/InlineObject.md @@ -0,0 +1,11 @@ + +# InlineObject + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**name** | **kotlin.String** | Updated name of the pet | [optional] +**status** | **kotlin.String** | Updated status of the pet | [optional] + + + diff --git a/samples/openapi3/client/petstore/kotlin-multiplatform/docs/InlineObject1.md b/samples/openapi3/client/petstore/kotlin-multiplatform/docs/InlineObject1.md new file mode 100644 index 00000000000..43c5b5f742c --- /dev/null +++ b/samples/openapi3/client/petstore/kotlin-multiplatform/docs/InlineObject1.md @@ -0,0 +1,11 @@ + +# InlineObject1 + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**additionalMetadata** | **kotlin.String** | Additional data to pass to server | [optional] +**file** | [**io.ktor.client.request.forms.InputProvider**](io.ktor.client.request.forms.InputProvider.md) | file to upload | [optional] + + + diff --git a/samples/openapi3/client/petstore/kotlin-multiplatform/docs/InlineObject2.md b/samples/openapi3/client/petstore/kotlin-multiplatform/docs/InlineObject2.md new file mode 100644 index 00000000000..0720925918b --- /dev/null +++ b/samples/openapi3/client/petstore/kotlin-multiplatform/docs/InlineObject2.md @@ -0,0 +1,25 @@ + +# InlineObject2 + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**enumFormStringArray** | [**inline**](#kotlin.Array<EnumFormStringArrayEnum>) | Form parameter enum test (string array) | [optional] +**enumFormString** | [**inline**](#EnumFormStringEnum) | Form parameter enum test (string) | [optional] + + + +## Enum: enum_form_string_array +Name | Value +---- | ----- +enumFormStringArray | >, $ + + + +## Enum: enum_form_string +Name | Value +---- | ----- +enumFormString | _abc, -efg, (xyz) + + + diff --git a/samples/openapi3/client/petstore/kotlin-multiplatform/docs/InlineObject3.md b/samples/openapi3/client/petstore/kotlin-multiplatform/docs/InlineObject3.md new file mode 100644 index 00000000000..82bf6d182b6 --- /dev/null +++ b/samples/openapi3/client/petstore/kotlin-multiplatform/docs/InlineObject3.md @@ -0,0 +1,23 @@ + +# InlineObject3 + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**integer** | **kotlin.Int** | None | [optional] +**int32** | **kotlin.Int** | None | [optional] +**int64** | **kotlin.Long** | None | [optional] +**number** | **kotlin.Double** | None | +**float** | **kotlin.Float** | None | [optional] +**double** | **kotlin.Double** | None | +**string** | **kotlin.String** | None | [optional] +**patternWithoutDelimiter** | **kotlin.String** | None | +**byte** | **kotlin.ByteArray** | None | +**binary** | [**io.ktor.client.request.forms.InputProvider**](io.ktor.client.request.forms.InputProvider.md) | None | [optional] +**date** | **kotlin.String** | None | [optional] +**dateTime** | **kotlin.String** | None | [optional] +**password** | **kotlin.String** | None | [optional] +**callback** | **kotlin.String** | None | [optional] + + + diff --git a/samples/openapi3/client/petstore/kotlin-multiplatform/docs/InlineObject4.md b/samples/openapi3/client/petstore/kotlin-multiplatform/docs/InlineObject4.md new file mode 100644 index 00000000000..03c4daa7631 --- /dev/null +++ b/samples/openapi3/client/petstore/kotlin-multiplatform/docs/InlineObject4.md @@ -0,0 +1,11 @@ + +# InlineObject4 + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**param** | **kotlin.String** | field1 | +**param2** | **kotlin.String** | field2 | + + + diff --git a/samples/openapi3/client/petstore/kotlin-multiplatform/docs/InlineObject5.md b/samples/openapi3/client/petstore/kotlin-multiplatform/docs/InlineObject5.md new file mode 100644 index 00000000000..9e7765c3aa6 --- /dev/null +++ b/samples/openapi3/client/petstore/kotlin-multiplatform/docs/InlineObject5.md @@ -0,0 +1,11 @@ + +# InlineObject5 + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**additionalMetadata** | **kotlin.String** | Additional data to pass to server | [optional] +**requiredFile** | [**io.ktor.client.request.forms.InputProvider**](io.ktor.client.request.forms.InputProvider.md) | file to upload | + + + diff --git a/samples/openapi3/client/petstore/kotlin-multiplatform/docs/InlineResponseDefault.md b/samples/openapi3/client/petstore/kotlin-multiplatform/docs/InlineResponseDefault.md new file mode 100644 index 00000000000..afdd81b1383 --- /dev/null +++ b/samples/openapi3/client/petstore/kotlin-multiplatform/docs/InlineResponseDefault.md @@ -0,0 +1,10 @@ + +# InlineResponseDefault + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**string** | [**Foo**](Foo.md) | | [optional] + + + diff --git a/samples/openapi3/client/petstore/kotlin-multiplatform/docs/List.md b/samples/openapi3/client/petstore/kotlin-multiplatform/docs/List.md new file mode 100644 index 00000000000..13a09a4c414 --- /dev/null +++ b/samples/openapi3/client/petstore/kotlin-multiplatform/docs/List.md @@ -0,0 +1,10 @@ + +# List + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**`123minusList`** | **kotlin.String** | | [optional] + + + diff --git a/samples/openapi3/client/petstore/kotlin-multiplatform/docs/MapTest.md b/samples/openapi3/client/petstore/kotlin-multiplatform/docs/MapTest.md new file mode 100644 index 00000000000..36a1d460467 --- /dev/null +++ b/samples/openapi3/client/petstore/kotlin-multiplatform/docs/MapTest.md @@ -0,0 +1,20 @@ + +# MapTest + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**mapMapOfString** | **kotlin.collections.Map<kotlin.String, kotlin.collections.Map<kotlin.String, kotlin.String>>** | | [optional] +**mapOfEnumString** | [**inline**](#kotlin.collections.Map<kotlin.String, `inner`Enum>) | | [optional] +**directMap** | **kotlin.collections.Map<kotlin.String, kotlin.Boolean>** | | [optional] +**indirectMap** | **kotlin.collections.Map<kotlin.String, kotlin.Boolean>** | | [optional] + + + +## Enum: map_of_enum_string +Name | Value +---- | ----- +mapOfEnumString | UPPER, lower + + + diff --git a/samples/openapi3/client/petstore/kotlin-multiplatform/docs/MixedPropertiesAndAdditionalPropertiesClass.md b/samples/openapi3/client/petstore/kotlin-multiplatform/docs/MixedPropertiesAndAdditionalPropertiesClass.md new file mode 100644 index 00000000000..9a08c9385c5 --- /dev/null +++ b/samples/openapi3/client/petstore/kotlin-multiplatform/docs/MixedPropertiesAndAdditionalPropertiesClass.md @@ -0,0 +1,12 @@ + +# MixedPropertiesAndAdditionalPropertiesClass + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**uuid** | [**java.util.UUID**](java.util.UUID.md) | | [optional] +**dateTime** | **kotlin.String** | | [optional] +**map** | [**kotlin.collections.Map<kotlin.String, Animal>**](Animal.md) | | [optional] + + + diff --git a/samples/openapi3/client/petstore/kotlin-multiplatform/docs/Name.md b/samples/openapi3/client/petstore/kotlin-multiplatform/docs/Name.md new file mode 100644 index 00000000000..7eb6f21121e --- /dev/null +++ b/samples/openapi3/client/petstore/kotlin-multiplatform/docs/Name.md @@ -0,0 +1,13 @@ + +# Name + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**name** | **kotlin.Int** | | +**snakeCase** | **kotlin.Int** | | [optional] +**property** | **kotlin.String** | | [optional] +**`123number`** | **kotlin.Int** | | [optional] + + + diff --git a/samples/openapi3/client/petstore/kotlin-multiplatform/docs/NullableClass.md b/samples/openapi3/client/petstore/kotlin-multiplatform/docs/NullableClass.md new file mode 100644 index 00000000000..7461cacac88 --- /dev/null +++ b/samples/openapi3/client/petstore/kotlin-multiplatform/docs/NullableClass.md @@ -0,0 +1,21 @@ + +# NullableClass + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**integerProp** | **kotlin.Int** | | [optional] +**numberProp** | **kotlin.Double** | | [optional] +**booleanProp** | **kotlin.Boolean** | | [optional] +**stringProp** | **kotlin.String** | | [optional] +**dateProp** | **kotlin.String** | | [optional] +**datetimeProp** | **kotlin.String** | | [optional] +**arrayNullableProp** | [**kotlin.Array<kotlin.Any>**](kotlin.Any.md) | | [optional] +**arrayAndItemsNullableProp** | [**kotlin.Array<kotlin.Any>**](kotlin.Any.md) | | [optional] +**arrayItemsNullable** | [**kotlin.Array<kotlin.Any>**](kotlin.Any.md) | | [optional] +**objectNullableProp** | [**kotlin.collections.Map<kotlin.String, kotlin.Any>**](kotlin.Any.md) | | [optional] +**objectAndItemsNullableProp** | [**kotlin.collections.Map<kotlin.String, kotlin.Any>**](kotlin.Any.md) | | [optional] +**objectItemsNullable** | [**kotlin.collections.Map<kotlin.String, kotlin.Any>**](kotlin.Any.md) | | [optional] + + + diff --git a/samples/openapi3/client/petstore/kotlin-multiplatform/docs/NumberOnly.md b/samples/openapi3/client/petstore/kotlin-multiplatform/docs/NumberOnly.md new file mode 100644 index 00000000000..c70c4304fbf --- /dev/null +++ b/samples/openapi3/client/petstore/kotlin-multiplatform/docs/NumberOnly.md @@ -0,0 +1,10 @@ + +# NumberOnly + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**justNumber** | **kotlin.Double** | | [optional] + + + diff --git a/samples/openapi3/client/petstore/kotlin-multiplatform/docs/Order.md b/samples/openapi3/client/petstore/kotlin-multiplatform/docs/Order.md new file mode 100644 index 00000000000..4683c14c1cb --- /dev/null +++ b/samples/openapi3/client/petstore/kotlin-multiplatform/docs/Order.md @@ -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] + + + +## Enum: status +Name | Value +---- | ----- +status | placed, approved, delivered + + + diff --git a/samples/openapi3/client/petstore/kotlin-multiplatform/docs/OuterComposite.md b/samples/openapi3/client/petstore/kotlin-multiplatform/docs/OuterComposite.md new file mode 100644 index 00000000000..6da2c5e7fb9 --- /dev/null +++ b/samples/openapi3/client/petstore/kotlin-multiplatform/docs/OuterComposite.md @@ -0,0 +1,12 @@ + +# OuterComposite + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**myNumber** | **kotlin.Double** | | [optional] +**myString** | **kotlin.String** | | [optional] +**myBoolean** | **kotlin.Boolean** | | [optional] + + + diff --git a/samples/openapi3/client/petstore/kotlin-multiplatform/docs/OuterEnum.md b/samples/openapi3/client/petstore/kotlin-multiplatform/docs/OuterEnum.md new file mode 100644 index 00000000000..9e7ecb9499a --- /dev/null +++ b/samples/openapi3/client/petstore/kotlin-multiplatform/docs/OuterEnum.md @@ -0,0 +1,14 @@ + +# OuterEnum + +## Enum + + + * `placed` (value: `"placed"`) + + * `approved` (value: `"approved"`) + + * `delivered` (value: `"delivered"`) + + + diff --git a/samples/openapi3/client/petstore/kotlin-multiplatform/docs/OuterEnumDefaultValue.md b/samples/openapi3/client/petstore/kotlin-multiplatform/docs/OuterEnumDefaultValue.md new file mode 100644 index 00000000000..821d297a001 --- /dev/null +++ b/samples/openapi3/client/petstore/kotlin-multiplatform/docs/OuterEnumDefaultValue.md @@ -0,0 +1,14 @@ + +# OuterEnumDefaultValue + +## Enum + + + * `placed` (value: `"placed"`) + + * `approved` (value: `"approved"`) + + * `delivered` (value: `"delivered"`) + + + diff --git a/samples/openapi3/client/petstore/kotlin-multiplatform/docs/OuterEnumInteger.md b/samples/openapi3/client/petstore/kotlin-multiplatform/docs/OuterEnumInteger.md new file mode 100644 index 00000000000..b40f6e4b7ef --- /dev/null +++ b/samples/openapi3/client/petstore/kotlin-multiplatform/docs/OuterEnumInteger.md @@ -0,0 +1,14 @@ + +# OuterEnumInteger + +## Enum + + + * `_0` (value: `0`) + + * `_1` (value: `1`) + + * `_2` (value: `2`) + + + diff --git a/samples/openapi3/client/petstore/kotlin-multiplatform/docs/OuterEnumIntegerDefaultValue.md b/samples/openapi3/client/petstore/kotlin-multiplatform/docs/OuterEnumIntegerDefaultValue.md new file mode 100644 index 00000000000..c2fb3ee41d7 --- /dev/null +++ b/samples/openapi3/client/petstore/kotlin-multiplatform/docs/OuterEnumIntegerDefaultValue.md @@ -0,0 +1,14 @@ + +# OuterEnumIntegerDefaultValue + +## Enum + + + * `_0` (value: `0`) + + * `_1` (value: `1`) + + * `_2` (value: `2`) + + + diff --git a/samples/openapi3/client/petstore/kotlin-multiplatform/docs/Pet.md b/samples/openapi3/client/petstore/kotlin-multiplatform/docs/Pet.md new file mode 100644 index 00000000000..ec775600737 --- /dev/null +++ b/samples/openapi3/client/petstore/kotlin-multiplatform/docs/Pet.md @@ -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<kotlin.String>** | | +**tags** | [**kotlin.Array<Tag>**](Tag.md) | | [optional] +**status** | [**inline**](#StatusEnum) | pet status in the store | [optional] + + + +## Enum: status +Name | Value +---- | ----- +status | available, pending, sold + + + diff --git a/samples/openapi3/client/petstore/kotlin-multiplatform/docs/PetApi.md b/samples/openapi3/client/petstore/kotlin-multiplatform/docs/PetApi.md new file mode 100644 index 00000000000..a07ff10e937 --- /dev/null +++ b/samples/openapi3/client/petstore/kotlin-multiplatform/docs/PetApi.md @@ -0,0 +1,457 @@ +# PetApi + +All URIs are relative to *http://petstore.swagger.io:80/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 +[**uploadFileWithRequiredFile**](PetApi.md#uploadFileWithRequiredFile) | **POST** /fake/{petId}/uploadImageWithRequiredFile | uploads an image (required) + + + +# **addPet** +> addPet(pet) + +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 pet : Pet = // Pet | Pet object that needs to be added to the store +try { + apiInstance.addPet(pet) +} 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 +------------- | ------------- | ------------- | ------------- + **pet** | [**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 + + +# **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 + + +# **findPetsByStatus** +> kotlin.Array<Pet> 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.Array | Status values that need to be considered for filter +try { + val result : kotlin.Array = 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<kotlin.String>**](kotlin.String.md)| Status values that need to be considered for filter | [enum: available, pending, sold] + +### Return type + +[**kotlin.Array<Pet>**](Pet.md) + +### Authorization + + +Configure petstore_auth: + ApiClient.accessToken = "" + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + + +# **findPetsByTags** +> kotlin.Array<Pet> 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.Array | Tags to filter by +try { + val result : kotlin.Array = 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<kotlin.String>**](kotlin.String.md)| Tags to filter by | + +### Return type + +[**kotlin.Array<Pet>**](Pet.md) + +### Authorization + + +Configure petstore_auth: + ApiClient.accessToken = "" + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + + +# **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 + + +# **updatePet** +> updatePet(pet) + +Update an existing pet + +### Example +```kotlin +// Import classes: +//import org.openapitools.client.infrastructure.* +//import org.openapitools.client.models.* + +val apiInstance = PetApi() +val pet : Pet = // Pet | Pet object that needs to be added to the store +try { + apiInstance.updatePet(pet) +} 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 +------------- | ------------- | ------------- | ------------- + **pet** | [**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 + + +# **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 + + +# **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 + + +# **uploadFileWithRequiredFile** +> ApiResponse uploadFileWithRequiredFile(petId, requiredFile, additionalMetadata) + +uploads an image (required) + +### 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 requiredFile : io.ktor.client.request.forms.InputProvider = BINARY_DATA_HERE // io.ktor.client.request.forms.InputProvider | file to upload +val additionalMetadata : kotlin.String = additionalMetadata_example // kotlin.String | Additional data to pass to server +try { + val result : ApiResponse = apiInstance.uploadFileWithRequiredFile(petId, requiredFile, additionalMetadata) + println(result) +} catch (e: ClientException) { + println("4xx response calling PetApi#uploadFileWithRequiredFile") + e.printStackTrace() +} catch (e: ServerException) { + println("5xx response calling PetApi#uploadFileWithRequiredFile") + e.printStackTrace() +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **petId** | **kotlin.Long**| ID of pet to update | + **requiredFile** | **io.ktor.client.request.forms.InputProvider**| file to upload | + **additionalMetadata** | **kotlin.String**| Additional data to pass to server | [optional] + +### Return type + +[**ApiResponse**](ApiResponse.md) + +### Authorization + + +Configure petstore_auth: + ApiClient.accessToken = "" + +### HTTP request headers + + - **Content-Type**: multipart/form-data + - **Accept**: application/json + diff --git a/samples/openapi3/client/petstore/kotlin-multiplatform/docs/ReadOnlyFirst.md b/samples/openapi3/client/petstore/kotlin-multiplatform/docs/ReadOnlyFirst.md new file mode 100644 index 00000000000..26aa9f3ac4d --- /dev/null +++ b/samples/openapi3/client/petstore/kotlin-multiplatform/docs/ReadOnlyFirst.md @@ -0,0 +1,11 @@ + +# ReadOnlyFirst + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**bar** | **kotlin.String** | | [optional] +**baz** | **kotlin.String** | | [optional] + + + diff --git a/samples/openapi3/client/petstore/kotlin-multiplatform/docs/Return.md b/samples/openapi3/client/petstore/kotlin-multiplatform/docs/Return.md new file mode 100644 index 00000000000..a5437240dc3 --- /dev/null +++ b/samples/openapi3/client/petstore/kotlin-multiplatform/docs/Return.md @@ -0,0 +1,10 @@ + +# Return + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**`return`** | **kotlin.Int** | | [optional] + + + diff --git a/samples/openapi3/client/petstore/kotlin-multiplatform/docs/SpecialModelName.md b/samples/openapi3/client/petstore/kotlin-multiplatform/docs/SpecialModelName.md new file mode 100644 index 00000000000..282649449d9 --- /dev/null +++ b/samples/openapi3/client/petstore/kotlin-multiplatform/docs/SpecialModelName.md @@ -0,0 +1,10 @@ + +# SpecialModelname + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**dollarSpecialLeftSquareBracketPropertyPeriodNameRightSquareBracket** | **kotlin.Long** | | [optional] + + + diff --git a/samples/openapi3/client/petstore/kotlin-multiplatform/docs/StoreApi.md b/samples/openapi3/client/petstore/kotlin-multiplatform/docs/StoreApi.md new file mode 100644 index 00000000000..55bd8afdbc0 --- /dev/null +++ b/samples/openapi3/client/petstore/kotlin-multiplatform/docs/StoreApi.md @@ -0,0 +1,196 @@ +# StoreApi + +All URIs are relative to *http://petstore.swagger.io:80/v2* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**deleteOrder**](StoreApi.md#deleteOrder) | **DELETE** /store/order/{order_id} | Delete purchase order by ID +[**getInventory**](StoreApi.md#getInventory) | **GET** /store/inventory | Returns pet inventories by status +[**getOrderById**](StoreApi.md#getOrderById) | **GET** /store/order/{order_id} | Find purchase order by ID +[**placeOrder**](StoreApi.md#placeOrder) | **POST** /store/order | Place an order for a pet + + + +# **deleteOrder** +> deleteOrder(orderId) + +Delete purchase order by ID + +For valid response try integer IDs with value < 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 + + +# **getInventory** +> kotlin.collections.Map<kotlin.String, kotlin.Int> 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 = 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<kotlin.String, kotlin.Int>** + +### Authorization + + +Configure api_key: + ApiClient.apiKey["api_key"] = "" + ApiClient.apiKeyPrefix["api_key"] = "" + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + + +# **getOrderById** +> Order getOrderById(orderId) + +Find purchase order by ID + +For valid response try integer IDs with value <= 5 or > 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 + + +# **placeOrder** +> Order placeOrder(order) + +Place an order for a pet + +### Example +```kotlin +// Import classes: +//import org.openapitools.client.infrastructure.* +//import org.openapitools.client.models.* + +val apiInstance = StoreApi() +val order : Order = // Order | order placed for purchasing the pet +try { + val result : Order = apiInstance.placeOrder(order) + 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 +------------- | ------------- | ------------- | ------------- + **order** | [**Order**](Order.md)| order placed for purchasing the pet | + +### Return type + +[**Order**](Order.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: application/xml, application/json + diff --git a/samples/openapi3/client/petstore/kotlin-multiplatform/docs/Tag.md b/samples/openapi3/client/petstore/kotlin-multiplatform/docs/Tag.md new file mode 100644 index 00000000000..60ce1bcdbad --- /dev/null +++ b/samples/openapi3/client/petstore/kotlin-multiplatform/docs/Tag.md @@ -0,0 +1,11 @@ + +# Tag + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **kotlin.Long** | | [optional] +**name** | **kotlin.String** | | [optional] + + + diff --git a/samples/openapi3/client/petstore/kotlin-multiplatform/docs/User.md b/samples/openapi3/client/petstore/kotlin-multiplatform/docs/User.md new file mode 100644 index 00000000000..e801729b5ed --- /dev/null +++ b/samples/openapi3/client/petstore/kotlin-multiplatform/docs/User.md @@ -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] + + + diff --git a/samples/openapi3/client/petstore/kotlin-multiplatform/docs/UserApi.md b/samples/openapi3/client/petstore/kotlin-multiplatform/docs/UserApi.md new file mode 100644 index 00000000000..dbf78e81eb2 --- /dev/null +++ b/samples/openapi3/client/petstore/kotlin-multiplatform/docs/UserApi.md @@ -0,0 +1,376 @@ +# UserApi + +All URIs are relative to *http://petstore.swagger.io:80/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 + + + +# **createUser** +> createUser(user) + +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 user : User = // User | Created user object +try { + apiInstance.createUser(user) +} 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 +------------- | ------------- | ------------- | ------------- + **user** | [**User**](User.md)| Created user object | + +### Return type + +null (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: Not defined + + +# **createUsersWithArrayInput** +> createUsersWithArrayInput(user) + +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 user : kotlin.Array = // kotlin.Array | List of user object +try { + apiInstance.createUsersWithArrayInput(user) +} 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 +------------- | ------------- | ------------- | ------------- + **user** | [**kotlin.Array<User>**](User.md)| List of user object | + +### Return type + +null (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: Not defined + + +# **createUsersWithListInput** +> createUsersWithListInput(user) + +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 user : kotlin.Array = // kotlin.Array | List of user object +try { + apiInstance.createUsersWithListInput(user) +} 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 +------------- | ------------- | ------------- | ------------- + **user** | [**kotlin.Array<User>**](User.md)| List of user object | + +### Return type + +null (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: Not defined + + +# **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 + + +# **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 + + +# **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 + + +# **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 + + +# **updateUser** +> updateUser(username, user) + +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 user : User = // User | Updated user object +try { + apiInstance.updateUser(username, user) +} 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 | + **user** | [**User**](User.md)| Updated user object | + +### Return type + +null (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: Not defined + diff --git a/samples/openapi3/client/petstore/kotlin-multiplatform/gradle/wrapper/gradle-wrapper.jar b/samples/openapi3/client/petstore/kotlin-multiplatform/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 00000000000..2c6137b8789 Binary files /dev/null and b/samples/openapi3/client/petstore/kotlin-multiplatform/gradle/wrapper/gradle-wrapper.jar differ diff --git a/samples/openapi3/client/petstore/kotlin-multiplatform/gradle/wrapper/gradle-wrapper.properties b/samples/openapi3/client/petstore/kotlin-multiplatform/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 00000000000..ce3ca77db54 --- /dev/null +++ b/samples/openapi3/client/petstore/kotlin-multiplatform/gradle/wrapper/gradle-wrapper.properties @@ -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 diff --git a/samples/openapi3/client/petstore/kotlin-multiplatform/gradlew b/samples/openapi3/client/petstore/kotlin-multiplatform/gradlew new file mode 100644 index 00000000000..9d82f789151 --- /dev/null +++ b/samples/openapi3/client/petstore/kotlin-multiplatform/gradlew @@ -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 "$@" diff --git a/samples/openapi3/client/petstore/kotlin-multiplatform/gradlew.bat b/samples/openapi3/client/petstore/kotlin-multiplatform/gradlew.bat new file mode 100644 index 00000000000..5f192121eb4 --- /dev/null +++ b/samples/openapi3/client/petstore/kotlin-multiplatform/gradlew.bat @@ -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 diff --git a/samples/openapi3/client/petstore/kotlin-multiplatform/settings.gradle b/samples/openapi3/client/petstore/kotlin-multiplatform/settings.gradle new file mode 100644 index 00000000000..b000833f485 --- /dev/null +++ b/samples/openapi3/client/petstore/kotlin-multiplatform/settings.gradle @@ -0,0 +1,2 @@ +enableFeaturePreview('GRADLE_METADATA') +rootProject.name = 'kotlin-client-petstore-multiplatform' \ No newline at end of file diff --git a/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/apis/AnotherFakeApi.kt b/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/apis/AnotherFakeApi.kt new file mode 100644 index 00000000000..9a828f015f7 --- /dev/null +++ b/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/apis/AnotherFakeApi.kt @@ -0,0 +1,81 @@ +/** +* OpenAPI Petstore +* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ +* +* 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.Client + +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 AnotherFakeApi @UseExperimental(UnstableDefault::class) constructor( + baseUrl: kotlin.String = "http://petstore.swagger.io:80/v2", + httpClientEngine: HttpClientEngine? = null, + serializer: KotlinxSerializer) + : ApiClient(baseUrl, httpClientEngine, serializer) { + + @UseExperimental(UnstableDefault::class) + constructor( + baseUrl: kotlin.String = "http://petstore.swagger.io:80/v2", + httpClientEngine: HttpClientEngine? = null, + jsonConfiguration: JsonConfiguration = JsonConfiguration.Default) + : this(baseUrl, httpClientEngine, KotlinxSerializer(Json(jsonConfiguration))) + + /** + * To test special tags + * To test special tags and operation ID starting with number + * @param client client model + * @return Client + */ + @Suppress("UNCHECKED_CAST") + suspend fun call123testSpecialTags(client: Client) : HttpResponse { + + val localVariableBody = client + + + val localVariableQuery = mutableMapOf>() + + + val localVariableHeaders = mutableMapOf() + + + val localVariableConfig = RequestConfig( + RequestMethod.PATCH, + "/another-fake/dummy", + query = localVariableQuery, + headers = localVariableHeaders + ) + + return jsonRequest( + localVariableConfig, + localVariableBody + ).wrap() + } + + + + + + companion object { + internal fun setMappers(serializer: KotlinxSerializer) { + + + } + } +} diff --git a/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/apis/DefaultApi.kt b/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/apis/DefaultApi.kt new file mode 100644 index 00000000000..41a5c5b7697 --- /dev/null +++ b/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/apis/DefaultApi.kt @@ -0,0 +1,80 @@ +/** +* OpenAPI Petstore +* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ +* +* 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.InlineResponseDefault + +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 DefaultApi @UseExperimental(UnstableDefault::class) constructor( + baseUrl: kotlin.String = "http://petstore.swagger.io:80/v2", + httpClientEngine: HttpClientEngine? = null, + serializer: KotlinxSerializer) + : ApiClient(baseUrl, httpClientEngine, serializer) { + + @UseExperimental(UnstableDefault::class) + constructor( + baseUrl: kotlin.String = "http://petstore.swagger.io:80/v2", + httpClientEngine: HttpClientEngine? = null, + jsonConfiguration: JsonConfiguration = JsonConfiguration.Default) + : this(baseUrl, httpClientEngine, KotlinxSerializer(Json(jsonConfiguration))) + + /** + * + * + * @return InlineResponseDefault + */ + @Suppress("UNCHECKED_CAST") + suspend fun fooGet() : HttpResponse { + + val localVariableBody = + io.ktor.client.utils.EmptyContent + + val localVariableQuery = mutableMapOf>() + + + val localVariableHeaders = mutableMapOf() + + + val localVariableConfig = RequestConfig( + RequestMethod.GET, + "/foo", + query = localVariableQuery, + headers = localVariableHeaders + ) + + return request( + localVariableConfig, + localVariableBody + ).wrap() + } + + + + + + companion object { + internal fun setMappers(serializer: KotlinxSerializer) { + + + } + } +} diff --git a/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/apis/FakeApi.kt b/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/apis/FakeApi.kt new file mode 100644 index 00000000000..e2fdd4fb8c3 --- /dev/null +++ b/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/apis/FakeApi.kt @@ -0,0 +1,641 @@ +/** +* OpenAPI Petstore +* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ +* +* 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.Client +import org.openapitools.client.models.FileSchemaTestClass +import org.openapitools.client.models.HealthCheckResult +import org.openapitools.client.models.OuterComposite +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 FakeApi @UseExperimental(UnstableDefault::class) constructor( + baseUrl: kotlin.String = "http://petstore.swagger.io:80/v2", + httpClientEngine: HttpClientEngine? = null, + serializer: KotlinxSerializer) + : ApiClient(baseUrl, httpClientEngine, serializer) { + + @UseExperimental(UnstableDefault::class) + constructor( + baseUrl: kotlin.String = "http://petstore.swagger.io:80/v2", + httpClientEngine: HttpClientEngine? = null, + jsonConfiguration: JsonConfiguration = JsonConfiguration.Default) + : this(baseUrl, httpClientEngine, KotlinxSerializer(Json(jsonConfiguration))) + + /** + * Health check endpoint + * + * @return HealthCheckResult + */ + @Suppress("UNCHECKED_CAST") + suspend fun fakeHealthGet() : HttpResponse { + + val localVariableBody = + io.ktor.client.utils.EmptyContent + + val localVariableQuery = mutableMapOf>() + + + val localVariableHeaders = mutableMapOf() + + + val localVariableConfig = RequestConfig( + RequestMethod.GET, + "/fake/health", + query = localVariableQuery, + headers = localVariableHeaders + ) + + return request( + localVariableConfig, + localVariableBody + ).wrap() + } + + + + + /** + * + * Test serialization of outer boolean types + * @param body Input boolean as post body (optional) + * @return kotlin.Boolean + */ + @Suppress("UNCHECKED_CAST") + suspend fun fakeOuterBooleanSerialize(body: kotlin.Boolean?) : HttpResponse { + + val localVariableBody = body + + + val localVariableQuery = mutableMapOf>() + + + val localVariableHeaders = mutableMapOf() + + + val localVariableConfig = RequestConfig( + RequestMethod.POST, + "/fake/outer/boolean", + query = localVariableQuery, + headers = localVariableHeaders + ) + + return jsonRequest( + localVariableConfig, + localVariableBody + ).wrap() + } + + + + + /** + * + * Test serialization of object with outer number type + * @param outerComposite Input composite as post body (optional) + * @return OuterComposite + */ + @Suppress("UNCHECKED_CAST") + suspend fun fakeOuterCompositeSerialize(outerComposite: OuterComposite?) : HttpResponse { + + val localVariableBody = outerComposite + + + val localVariableQuery = mutableMapOf>() + + + val localVariableHeaders = mutableMapOf() + + + val localVariableConfig = RequestConfig( + RequestMethod.POST, + "/fake/outer/composite", + query = localVariableQuery, + headers = localVariableHeaders + ) + + return jsonRequest( + localVariableConfig, + localVariableBody + ).wrap() + } + + + + + /** + * + * Test serialization of outer number types + * @param body Input number as post body (optional) + * @return kotlin.Double + */ + @Suppress("UNCHECKED_CAST") + suspend fun fakeOuterNumberSerialize(body: kotlin.Double?) : HttpResponse { + + val localVariableBody = body + + + val localVariableQuery = mutableMapOf>() + + + val localVariableHeaders = mutableMapOf() + + + val localVariableConfig = RequestConfig( + RequestMethod.POST, + "/fake/outer/number", + query = localVariableQuery, + headers = localVariableHeaders + ) + + return jsonRequest( + localVariableConfig, + localVariableBody + ).wrap() + } + + + + + /** + * + * Test serialization of outer string types + * @param body Input string as post body (optional) + * @return kotlin.String + */ + @Suppress("UNCHECKED_CAST") + suspend fun fakeOuterStringSerialize(body: kotlin.String?) : HttpResponse { + + val localVariableBody = body + + + val localVariableQuery = mutableMapOf>() + + + val localVariableHeaders = mutableMapOf() + + + val localVariableConfig = RequestConfig( + RequestMethod.POST, + "/fake/outer/string", + query = localVariableQuery, + headers = localVariableHeaders + ) + + return jsonRequest( + localVariableConfig, + localVariableBody + ).wrap() + } + + + + + /** + * + * For this test, the body for this request much reference a schema named `File`. + * @param fileSchemaTestClass + * @return void + */ + suspend fun testBodyWithFileSchema(fileSchemaTestClass: FileSchemaTestClass) : HttpResponse { + + val localVariableBody = fileSchemaTestClass + + + val localVariableQuery = mutableMapOf>() + + + val localVariableHeaders = mutableMapOf() + + + val localVariableConfig = RequestConfig( + RequestMethod.PUT, + "/fake/body-with-file-schema", + query = localVariableQuery, + headers = localVariableHeaders + ) + + return jsonRequest( + localVariableConfig, + localVariableBody + ).wrap() + } + + + + + /** + * + * + * @param query + * @param user + * @return void + */ + suspend fun testBodyWithQueryParams(query: kotlin.String, user: User) : HttpResponse { + + val localVariableBody = user + + + val localVariableQuery = mutableMapOf>() + + query?.apply { localVariableQuery["query"] = listOf("$query") } + + + val localVariableHeaders = mutableMapOf() + + + val localVariableConfig = RequestConfig( + RequestMethod.PUT, + "/fake/body-with-query-params", + query = localVariableQuery, + headers = localVariableHeaders + ) + + return jsonRequest( + localVariableConfig, + localVariableBody + ).wrap() + } + + + + + /** + * To test \"client\" model + * To test \"client\" model + * @param client client model + * @return Client + */ + @Suppress("UNCHECKED_CAST") + suspend fun testClientModel(client: Client) : HttpResponse { + + val localVariableBody = client + + + val localVariableQuery = mutableMapOf>() + + + val localVariableHeaders = mutableMapOf() + + + val localVariableConfig = RequestConfig( + RequestMethod.PATCH, + "/fake", + query = localVariableQuery, + headers = localVariableHeaders + ) + + return jsonRequest( + localVariableConfig, + localVariableBody + ).wrap() + } + + + + + /** + * Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 + * Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 + * @param number None + * @param double None + * @param patternWithoutDelimiter None + * @param byte None + * @param integer None (optional) + * @param int32 None (optional) + * @param int64 None (optional) + * @param float None (optional) + * @param string None (optional) + * @param binary None (optional) + * @param date None (optional) + * @param dateTime None (optional) + * @param password None (optional) + * @param paramCallback None (optional) + * @return void + */ + suspend fun testEndpointParameters(number: kotlin.Double, double: kotlin.Double, patternWithoutDelimiter: kotlin.String, byte: kotlin.ByteArray, integer: kotlin.Int?, int32: kotlin.Int?, int64: kotlin.Long?, float: kotlin.Float?, string: kotlin.String?, binary: io.ktor.client.request.forms.InputProvider?, date: kotlin.String?, dateTime: kotlin.String?, password: kotlin.String?, paramCallback: kotlin.String?) : HttpResponse { + + val localVariableBody = + ParametersBuilder().also { + integer?.apply { it.append("integer", integer.toString()) } + int32?.apply { it.append("int32", int32.toString()) } + int64?.apply { it.append("int64", int64.toString()) } + number?.apply { it.append("number", number.toString()) } + float?.apply { it.append("float", float.toString()) } + double?.apply { it.append("double", double.toString()) } + string?.apply { it.append("string", string.toString()) } + patternWithoutDelimiter?.apply { it.append("pattern_without_delimiter", patternWithoutDelimiter.toString()) } + byte?.apply { it.append("byte", byte.toString()) } + binary?.apply { it.append("binary", binary.toString()) } + date?.apply { it.append("date", date.toString()) } + dateTime?.apply { it.append("dateTime", dateTime.toString()) } + password?.apply { it.append("password", password.toString()) } + paramCallback?.apply { it.append("callback", paramCallback.toString()) } + }.build() + + val localVariableQuery = mutableMapOf>() + + + val localVariableHeaders = mutableMapOf() + + + val localVariableConfig = RequestConfig( + RequestMethod.POST, + "/fake", + query = localVariableQuery, + headers = localVariableHeaders + ) + + return urlEncodedFormRequest( + localVariableConfig, + localVariableBody + ).wrap() + } + + + + + /** + * To test enum parameters + * To test enum parameters + * @param enumHeaderStringArray Header parameter enum test (string array) (optional) + * @param enumHeaderString Header parameter enum test (string) (optional, default to '-efg') + * @param enumQueryStringArray Query parameter enum test (string array) (optional) + * @param enumQueryString Query parameter enum test (string) (optional, default to '-efg') + * @param enumQueryInteger Query parameter enum test (double) (optional) + * @param enumQueryDouble Query parameter enum test (double) (optional) + * @param enumFormStringArray Form parameter enum test (string array) (optional, default to '$') + * @param enumFormString Form parameter enum test (string) (optional, default to '-efg') + * @return void + */ + suspend fun testEnumParameters(enumHeaderStringArray: kotlin.Array?, enumHeaderString: kotlin.String?, enumQueryStringArray: kotlin.Array?, enumQueryString: kotlin.String?, enumQueryInteger: kotlin.Int?, enumQueryDouble: kotlin.Double?, enumFormStringArray: kotlin.Array?, enumFormString: kotlin.String?) : HttpResponse { + + val localVariableBody = + ParametersBuilder().also { + enumFormStringArray?.apply { it.append("enum_form_string_array", enumFormStringArray.toString()) } + enumFormString?.apply { it.append("enum_form_string", enumFormString.toString()) } + }.build() + + val localVariableQuery = mutableMapOf>() + + enumQueryStringArray?.apply { localVariableQuery["enum_query_string_array"] = toMultiValue(this, "multi") } + + enumQueryString?.apply { localVariableQuery["enum_query_string"] = listOf("$enumQueryString") } + + enumQueryInteger?.apply { localVariableQuery["enum_query_integer"] = listOf("$enumQueryInteger") } + + enumQueryDouble?.apply { localVariableQuery["enum_query_double"] = listOf("$enumQueryDouble") } + + + val localVariableHeaders = mutableMapOf() + + enumHeaderStringArray?.apply { localVariableHeaders["enum_header_string_array"] = this.joinToString(separator = collectionDelimiter("csv")) } + + enumHeaderString?.apply { localVariableHeaders["enum_header_string"] = this.toString() } + + + val localVariableConfig = RequestConfig( + RequestMethod.GET, + "/fake", + query = localVariableQuery, + headers = localVariableHeaders + ) + + return urlEncodedFormRequest( + localVariableConfig, + localVariableBody + ).wrap() + } + + + + + /** + * Fake endpoint to test group parameters (optional) + * Fake endpoint to test group parameters (optional) + * @param requiredStringGroup Required String in group parameters + * @param requiredBooleanGroup Required Boolean in group parameters + * @param requiredInt64Group Required Integer in group parameters + * @param stringGroup String in group parameters (optional) + * @param booleanGroup Boolean in group parameters (optional) + * @param int64Group Integer in group parameters (optional) + * @return void + */ + suspend fun testGroupParameters(requiredStringGroup: kotlin.Int, requiredBooleanGroup: kotlin.Boolean, requiredInt64Group: kotlin.Long, stringGroup: kotlin.Int?, booleanGroup: kotlin.Boolean?, int64Group: kotlin.Long?) : HttpResponse { + + val localVariableBody = + io.ktor.client.utils.EmptyContent + + val localVariableQuery = mutableMapOf>() + + requiredStringGroup?.apply { localVariableQuery["required_string_group"] = listOf("$requiredStringGroup") } + + requiredInt64Group?.apply { localVariableQuery["required_int64_group"] = listOf("$requiredInt64Group") } + + stringGroup?.apply { localVariableQuery["string_group"] = listOf("$stringGroup") } + + int64Group?.apply { localVariableQuery["int64_group"] = listOf("$int64Group") } + + + val localVariableHeaders = mutableMapOf() + + requiredBooleanGroup?.apply { localVariableHeaders["required_boolean_group"] = this.toString() } + + booleanGroup?.apply { localVariableHeaders["boolean_group"] = this.toString() } + + + val localVariableConfig = RequestConfig( + RequestMethod.DELETE, + "/fake", + query = localVariableQuery, + headers = localVariableHeaders + ) + + return request( + localVariableConfig, + localVariableBody + ).wrap() + } + + + + + /** + * test inline additionalProperties + * + * @param requestBody request body + * @return void + */ + suspend fun testInlineAdditionalProperties(requestBody: kotlin.collections.Map) : HttpResponse { + + val localVariableBody = TestInlineAdditionalPropertiesRequest(requestBody) + + + val localVariableQuery = mutableMapOf>() + + + val localVariableHeaders = mutableMapOf() + + + val localVariableConfig = RequestConfig( + RequestMethod.POST, + "/fake/inline-additionalProperties", + query = localVariableQuery, + headers = localVariableHeaders + ) + + return jsonRequest( + localVariableConfig, + localVariableBody + ).wrap() + } + + @Serializable +private class TestInlineAdditionalPropertiesRequest(val value: Map) { + @Serializer(TestInlineAdditionalPropertiesRequest::class) + companion object : KSerializer { + private val serializer: KSerializer> = (kotlin.String.serializer() to kotlin.String.serializer()).map + override val descriptor = StringDescriptor.withName("TestInlineAdditionalPropertiesRequest") + override fun serialize(encoder: Encoder, obj: TestInlineAdditionalPropertiesRequest) = serializer.serialize(encoder, obj.value) + override fun deserialize(decoder: Decoder) = TestInlineAdditionalPropertiesRequest(serializer.deserialize(decoder)) + } +} + + + /** + * test json serialization of form data + * + * @param param field1 + * @param param2 field2 + * @return void + */ + suspend fun testJsonFormData(param: kotlin.String, param2: kotlin.String) : HttpResponse { + + val localVariableBody = + ParametersBuilder().also { + param?.apply { it.append("param", param.toString()) } + param2?.apply { it.append("param2", param2.toString()) } + }.build() + + val localVariableQuery = mutableMapOf>() + + + val localVariableHeaders = mutableMapOf() + + + val localVariableConfig = RequestConfig( + RequestMethod.GET, + "/fake/jsonFormData", + query = localVariableQuery, + headers = localVariableHeaders + ) + + return urlEncodedFormRequest( + localVariableConfig, + localVariableBody + ).wrap() + } + + + + + /** + * + * To test the collection format in query parameters + * @param pipe + * @param ioutil + * @param http + * @param url + * @param context + * @return void + */ + suspend fun testQueryParameterCollectionFormat(pipe: kotlin.Array, ioutil: kotlin.Array, http: kotlin.Array, url: kotlin.Array, context: kotlin.Array) : HttpResponse { + + val localVariableBody = + io.ktor.client.utils.EmptyContent + + val localVariableQuery = mutableMapOf>() + + pipe?.apply { localVariableQuery["pipe"] = toMultiValue(this, "multi") } + + ioutil?.apply { localVariableQuery["ioutil"] = toMultiValue(this, "csv") } + + http?.apply { localVariableQuery["http"] = toMultiValue(this, "space") } + + url?.apply { localVariableQuery["url"] = toMultiValue(this, "csv") } + + context?.apply { localVariableQuery["context"] = toMultiValue(this, "multi") } + + + val localVariableHeaders = mutableMapOf() + + + val localVariableConfig = RequestConfig( + RequestMethod.PUT, + "/fake/test-query-paramters", + query = localVariableQuery, + headers = localVariableHeaders + ) + + return request( + localVariableConfig, + localVariableBody + ).wrap() + } + + + + + + companion object { + internal fun setMappers(serializer: KotlinxSerializer) { + + + + + + + + + + + + + + + + + + + + + + + serializer.setMapper(TestInlineAdditionalPropertiesRequest::class, TestInlineAdditionalPropertiesRequest.serializer()) + + + + + + } + } +} diff --git a/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/apis/FakeClassnameTags123Api.kt b/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/apis/FakeClassnameTags123Api.kt new file mode 100644 index 00000000000..33efbbe086c --- /dev/null +++ b/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/apis/FakeClassnameTags123Api.kt @@ -0,0 +1,81 @@ +/** +* OpenAPI Petstore +* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ +* +* 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.Client + +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 FakeClassnameTags123Api @UseExperimental(UnstableDefault::class) constructor( + baseUrl: kotlin.String = "http://petstore.swagger.io:80/v2", + httpClientEngine: HttpClientEngine? = null, + serializer: KotlinxSerializer) + : ApiClient(baseUrl, httpClientEngine, serializer) { + + @UseExperimental(UnstableDefault::class) + constructor( + baseUrl: kotlin.String = "http://petstore.swagger.io:80/v2", + httpClientEngine: HttpClientEngine? = null, + jsonConfiguration: JsonConfiguration = JsonConfiguration.Default) + : this(baseUrl, httpClientEngine, KotlinxSerializer(Json(jsonConfiguration))) + + /** + * To test class name in snake case + * To test class name in snake case + * @param client client model + * @return Client + */ + @Suppress("UNCHECKED_CAST") + suspend fun testClassname(client: Client) : HttpResponse { + + val localVariableBody = client + + + val localVariableQuery = mutableMapOf>() + + + val localVariableHeaders = mutableMapOf() + + + val localVariableConfig = RequestConfig( + RequestMethod.PATCH, + "/fake_classname_test", + query = localVariableQuery, + headers = localVariableHeaders + ) + + return jsonRequest( + localVariableConfig, + localVariableBody + ).wrap() + } + + + + + + companion object { + internal fun setMappers(serializer: KotlinxSerializer) { + + + } + } +} diff --git a/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/apis/PetApi.kt b/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/apis/PetApi.kt new file mode 100644 index 00000000000..b0bb39f630d --- /dev/null +++ b/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/apis/PetApi.kt @@ -0,0 +1,406 @@ +/** +* OpenAPI Petstore +* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ +* +* 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:80/v2", + httpClientEngine: HttpClientEngine? = null, + serializer: KotlinxSerializer) + : ApiClient(baseUrl, httpClientEngine, serializer) { + + @UseExperimental(UnstableDefault::class) + constructor( + baseUrl: kotlin.String = "http://petstore.swagger.io:80/v2", + httpClientEngine: HttpClientEngine? = null, + jsonConfiguration: JsonConfiguration = JsonConfiguration.Default) + : this(baseUrl, httpClientEngine, KotlinxSerializer(Json(jsonConfiguration))) + + /** + * Add a new pet to the store + * + * @param pet Pet object that needs to be added to the store + * @return void + */ + suspend fun addPet(pet: Pet) : HttpResponse { + + val localVariableBody = pet + + + val localVariableQuery = mutableMapOf>() + + + val localVariableHeaders = mutableMapOf() + + + 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 { + + val localVariableBody = + io.ktor.client.utils.EmptyContent + + val localVariableQuery = mutableMapOf>() + + + val localVariableHeaders = mutableMapOf() + + 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 + */ + @Suppress("UNCHECKED_CAST") + suspend fun findPetsByStatus(status: kotlin.Array) : HttpResponse> { + + val localVariableBody = + io.ktor.client.utils.EmptyContent + + val localVariableQuery = mutableMapOf>() + + status?.apply { localVariableQuery["status"] = toMultiValue(this, "csv") } + + + val localVariableHeaders = mutableMapOf() + + + val localVariableConfig = RequestConfig( + RequestMethod.GET, + "/pet/findByStatus", + query = localVariableQuery, + headers = localVariableHeaders + ) + + return request( + localVariableConfig, + localVariableBody + ).wrap().map { value.toTypedArray() } + } + + + @Serializable +private class FindPetsByStatusResponse(val value: List) { + @Serializer(FindPetsByStatusResponse::class) + companion object : KSerializer { + private val serializer: KSerializer> = 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 + */ + @Suppress("UNCHECKED_CAST") + suspend fun findPetsByTags(tags: kotlin.Array) : HttpResponse> { + + val localVariableBody = + io.ktor.client.utils.EmptyContent + + val localVariableQuery = mutableMapOf>() + + tags?.apply { localVariableQuery["tags"] = toMultiValue(this, "csv") } + + + val localVariableHeaders = mutableMapOf() + + + val localVariableConfig = RequestConfig( + RequestMethod.GET, + "/pet/findByTags", + query = localVariableQuery, + headers = localVariableHeaders + ) + + return request( + localVariableConfig, + localVariableBody + ).wrap().map { value.toTypedArray() } + } + + + @Serializable +private class FindPetsByTagsResponse(val value: List) { + @Serializer(FindPetsByTagsResponse::class) + companion object : KSerializer { + private val serializer: KSerializer> = 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 { + + val localVariableBody = + io.ktor.client.utils.EmptyContent + + val localVariableQuery = mutableMapOf>() + + + val localVariableHeaders = mutableMapOf() + + + val localVariableConfig = RequestConfig( + RequestMethod.GET, + "/pet/{petId}".replace("{"+"petId"+"}", "$petId"), + query = localVariableQuery, + headers = localVariableHeaders + ) + + return request( + localVariableConfig, + localVariableBody + ).wrap() + } + + + + + /** + * Update an existing pet + * + * @param pet Pet object that needs to be added to the store + * @return void + */ + suspend fun updatePet(pet: Pet) : HttpResponse { + + val localVariableBody = pet + + + val localVariableQuery = mutableMapOf>() + + + val localVariableHeaders = mutableMapOf() + + + 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 { + + val localVariableBody = + ParametersBuilder().also { + name?.apply { it.append("name", name.toString()) } + status?.apply { it.append("status", status.toString()) } + }.build() + + val localVariableQuery = mutableMapOf>() + + + val localVariableHeaders = mutableMapOf() + + + 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 { + + val localVariableBody = + formData { + additionalMetadata?.apply { append("additionalMetadata", additionalMetadata) } + file?.apply { append("file", file) } + } + + val localVariableQuery = mutableMapOf>() + + + val localVariableHeaders = mutableMapOf() + + + val localVariableConfig = RequestConfig( + RequestMethod.POST, + "/pet/{petId}/uploadImage".replace("{"+"petId"+"}", "$petId"), + query = localVariableQuery, + headers = localVariableHeaders + ) + + return multipartFormRequest( + localVariableConfig, + localVariableBody + ).wrap() + } + + + + + /** + * uploads an image (required) + * + * @param petId ID of pet to update + * @param requiredFile file to upload + * @param additionalMetadata Additional data to pass to server (optional) + * @return ApiResponse + */ + @Suppress("UNCHECKED_CAST") + suspend fun uploadFileWithRequiredFile(petId: kotlin.Long, requiredFile: io.ktor.client.request.forms.InputProvider, additionalMetadata: kotlin.String?) : HttpResponse { + + val localVariableBody = + formData { + additionalMetadata?.apply { append("additionalMetadata", additionalMetadata) } + requiredFile?.apply { append("requiredFile", requiredFile) } + } + + val localVariableQuery = mutableMapOf>() + + + val localVariableHeaders = mutableMapOf() + + + val localVariableConfig = RequestConfig( + RequestMethod.POST, + "/fake/{petId}/uploadImageWithRequiredFile".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()) + + + + + + + + + + + } + } +} diff --git a/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/apis/StoreApi.kt b/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/apis/StoreApi.kt new file mode 100644 index 00000000000..5edfea034c6 --- /dev/null +++ b/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/apis/StoreApi.kt @@ -0,0 +1,196 @@ +/** +* OpenAPI Petstore +* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ +* +* 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:80/v2", + httpClientEngine: HttpClientEngine? = null, + serializer: KotlinxSerializer) + : ApiClient(baseUrl, httpClientEngine, serializer) { + + @UseExperimental(UnstableDefault::class) + constructor( + baseUrl: kotlin.String = "http://petstore.swagger.io:80/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 < 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 { + + val localVariableBody = + io.ktor.client.utils.EmptyContent + + val localVariableQuery = mutableMapOf>() + + + val localVariableHeaders = mutableMapOf() + + + val localVariableConfig = RequestConfig( + RequestMethod.DELETE, + "/store/order/{order_id}".replace("{"+"order_id"+"}", "$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 + */ + @Suppress("UNCHECKED_CAST") + suspend fun getInventory() : HttpResponse> { + + val localVariableBody = + io.ktor.client.utils.EmptyContent + + val localVariableQuery = mutableMapOf>() + + + val localVariableHeaders = mutableMapOf() + + + val localVariableConfig = RequestConfig( + RequestMethod.GET, + "/store/inventory", + query = localVariableQuery, + headers = localVariableHeaders + ) + + return request( + localVariableConfig, + localVariableBody + ).wrap().map { value } + } + + + @Serializable +private class GetInventoryResponse(val value: Map) { + @Serializer(GetInventoryResponse::class) + companion object : KSerializer { + private val serializer: KSerializer> = (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 <= 5 or > 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 { + + val localVariableBody = + io.ktor.client.utils.EmptyContent + + val localVariableQuery = mutableMapOf>() + + + val localVariableHeaders = mutableMapOf() + + + val localVariableConfig = RequestConfig( + RequestMethod.GET, + "/store/order/{order_id}".replace("{"+"order_id"+"}", "$orderId"), + query = localVariableQuery, + headers = localVariableHeaders + ) + + return request( + localVariableConfig, + localVariableBody + ).wrap() + } + + + + + /** + * Place an order for a pet + * + * @param order order placed for purchasing the pet + * @return Order + */ + @Suppress("UNCHECKED_CAST") + suspend fun placeOrder(order: Order) : HttpResponse { + + val localVariableBody = order + + + val localVariableQuery = mutableMapOf>() + + + val localVariableHeaders = mutableMapOf() + + + 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()) + + + + + } + } +} diff --git a/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/apis/UserApi.kt b/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/apis/UserApi.kt new file mode 100644 index 00000000000..439d09a2b5f --- /dev/null +++ b/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/apis/UserApi.kt @@ -0,0 +1,350 @@ +/** +* OpenAPI Petstore +* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ +* +* 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:80/v2", + httpClientEngine: HttpClientEngine? = null, + serializer: KotlinxSerializer) + : ApiClient(baseUrl, httpClientEngine, serializer) { + + @UseExperimental(UnstableDefault::class) + constructor( + baseUrl: kotlin.String = "http://petstore.swagger.io:80/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 user Created user object + * @return void + */ + suspend fun createUser(user: User) : HttpResponse { + + val localVariableBody = user + + + val localVariableQuery = mutableMapOf>() + + + val localVariableHeaders = mutableMapOf() + + + val localVariableConfig = RequestConfig( + RequestMethod.POST, + "/user", + query = localVariableQuery, + headers = localVariableHeaders + ) + + return jsonRequest( + localVariableConfig, + localVariableBody + ).wrap() + } + + + + + /** + * Creates list of users with given input array + * + * @param user List of user object + * @return void + */ + suspend fun createUsersWithArrayInput(user: kotlin.Array) : HttpResponse { + + val localVariableBody = CreateUsersWithArrayInputRequest(user.asList()) + + + val localVariableQuery = mutableMapOf>() + + + val localVariableHeaders = mutableMapOf() + + + val localVariableConfig = RequestConfig( + RequestMethod.POST, + "/user/createWithArray", + query = localVariableQuery, + headers = localVariableHeaders + ) + + return jsonRequest( + localVariableConfig, + localVariableBody + ).wrap() + } + + @Serializable +private class CreateUsersWithArrayInputRequest(val value: List) { + @Serializer(CreateUsersWithArrayInputRequest::class) + companion object : KSerializer { + private val serializer: KSerializer> = 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 user List of user object + * @return void + */ + suspend fun createUsersWithListInput(user: kotlin.Array) : HttpResponse { + + val localVariableBody = CreateUsersWithListInputRequest(user.asList()) + + + val localVariableQuery = mutableMapOf>() + + + val localVariableHeaders = mutableMapOf() + + + val localVariableConfig = RequestConfig( + RequestMethod.POST, + "/user/createWithList", + query = localVariableQuery, + headers = localVariableHeaders + ) + + return jsonRequest( + localVariableConfig, + localVariableBody + ).wrap() + } + + @Serializable +private class CreateUsersWithListInputRequest(val value: List) { + @Serializer(CreateUsersWithListInputRequest::class) + companion object : KSerializer { + private val serializer: KSerializer> = 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 { + + val localVariableBody = + io.ktor.client.utils.EmptyContent + + val localVariableQuery = mutableMapOf>() + + + val localVariableHeaders = mutableMapOf() + + + 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 { + + val localVariableBody = + io.ktor.client.utils.EmptyContent + + val localVariableQuery = mutableMapOf>() + + + val localVariableHeaders = mutableMapOf() + + + 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 { + + val localVariableBody = + io.ktor.client.utils.EmptyContent + + val localVariableQuery = mutableMapOf>() + + username?.apply { localVariableQuery["username"] = listOf("$username") } + + password?.apply { localVariableQuery["password"] = listOf("$password") } + + + val localVariableHeaders = mutableMapOf() + + + 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 { + + val localVariableBody = + io.ktor.client.utils.EmptyContent + + val localVariableQuery = mutableMapOf>() + + + val localVariableHeaders = mutableMapOf() + + + 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 user Updated user object + * @return void + */ + suspend fun updateUser(username: kotlin.String, user: User) : HttpResponse { + + val localVariableBody = user + + + val localVariableQuery = mutableMapOf>() + + + val localVariableHeaders = mutableMapOf() + + + 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()) + + + + + + + + + + + + } + } +} diff --git a/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/infrastructure/ApiAbstractions.kt b/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/infrastructure/ApiAbstractions.kt new file mode 100644 index 00000000000..f97cb88d233 --- /dev/null +++ b/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/infrastructure/ApiAbstractions.kt @@ -0,0 +1,23 @@ +package org.openapitools.client.infrastructure + +typealias MultiValueMap = Map> + +fun collectionDelimiter(collectionFormat: String) = when(collectionFormat) { + "csv" -> "," + "tsv" -> "\t" + "pipes" -> "|" + "ssv" -> " " + else -> "" +} + +val defaultMultiValueConverter: (item: Any?) -> String = { item -> "$item" } + +fun toMultiValue(items: Array, collectionFormat: String, map: (item: T) -> String = defaultMultiValueConverter) + = toMultiValue(items.asIterable(), collectionFormat, map) + +fun toMultiValue(items: Iterable, collectionFormat: String, map: (item: T) -> String = defaultMultiValueConverter): List { + return when(collectionFormat) { + "multi" -> items.map(map) + else -> listOf(items.joinToString(separator = collectionDelimiter(collectionFormat), transform = map)) + } +} \ No newline at end of file diff --git a/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/infrastructure/ApiClient.kt b/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/infrastructure/ApiClient.kt new file mode 100644 index 00000000000..e87eecb1b88 --- /dev/null +++ b/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/infrastructure/ApiClient.kt @@ -0,0 +1,179 @@ +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) { + + AnotherFakeApi.setMappers(serializer) + + DefaultApi.setMappers(serializer) + + FakeApi.setMappers(serializer) + + FakeClassnameTags123Api.setMappers(serializer) + + PetApi.setMappers(serializer) + + StoreApi.setMappers(serializer) + + UserApi.setMappers(serializer) + + serializer.setMapper(AdditionalPropertiesClass::class, AdditionalPropertiesClass.serializer()) + serializer.setMapper(Animal::class, Animal.serializer()) + serializer.setMapper(ApiResponse::class, ApiResponse.serializer()) + serializer.setMapper(ArrayOfArrayOfNumberOnly::class, ArrayOfArrayOfNumberOnly.serializer()) + serializer.setMapper(ArrayOfNumberOnly::class, ArrayOfNumberOnly.serializer()) + serializer.setMapper(ArrayTest::class, ArrayTest.serializer()) + serializer.setMapper(Capitalization::class, Capitalization.serializer()) + serializer.setMapper(Cat::class, Cat.serializer()) + serializer.setMapper(CatAllOf::class, CatAllOf.serializer()) + serializer.setMapper(Category::class, Category.serializer()) + serializer.setMapper(ClassModel::class, ClassModel.serializer()) + serializer.setMapper(Client::class, Client.serializer()) + serializer.setMapper(Dog::class, Dog.serializer()) + serializer.setMapper(DogAllOf::class, DogAllOf.serializer()) + serializer.setMapper(EnumArrays::class, EnumArrays.serializer()) + serializer.setMapper(EnumClass::class, EnumClass.serializer()) + serializer.setMapper(EnumTest::class, EnumTest.serializer()) + serializer.setMapper(FileSchemaTestClass::class, FileSchemaTestClass.serializer()) + serializer.setMapper(Foo::class, Foo.serializer()) + serializer.setMapper(FormatTest::class, FormatTest.serializer()) + serializer.setMapper(HasOnlyReadOnly::class, HasOnlyReadOnly.serializer()) + serializer.setMapper(HealthCheckResult::class, HealthCheckResult.serializer()) + serializer.setMapper(InlineObject::class, InlineObject.serializer()) + serializer.setMapper(InlineObject1::class, InlineObject1.serializer()) + serializer.setMapper(InlineObject2::class, InlineObject2.serializer()) + serializer.setMapper(InlineObject3::class, InlineObject3.serializer()) + serializer.setMapper(InlineObject4::class, InlineObject4.serializer()) + serializer.setMapper(InlineObject5::class, InlineObject5.serializer()) + serializer.setMapper(InlineResponseDefault::class, InlineResponseDefault.serializer()) + serializer.setMapper(List::class, List.serializer()) + serializer.setMapper(MapTest::class, MapTest.serializer()) + serializer.setMapper(MixedPropertiesAndAdditionalPropertiesClass::class, MixedPropertiesAndAdditionalPropertiesClass.serializer()) + serializer.setMapper(Model200Response::class, Model200Response.serializer()) + serializer.setMapper(Name::class, Name.serializer()) + serializer.setMapper(NullableClass::class, NullableClass.serializer()) + serializer.setMapper(NumberOnly::class, NumberOnly.serializer()) + serializer.setMapper(Order::class, Order.serializer()) + serializer.setMapper(OuterComposite::class, OuterComposite.serializer()) + serializer.setMapper(OuterEnum::class, OuterEnum.serializer()) + serializer.setMapper(OuterEnumDefaultValue::class, OuterEnumDefaultValue.serializer()) + serializer.setMapper(OuterEnumInteger::class, OuterEnumInteger.serializer()) + serializer.setMapper(OuterEnumIntegerDefaultValue::class, OuterEnumIntegerDefaultValue.serializer()) + serializer.setMapper(Pet::class, Pet.serializer()) + serializer.setMapper(ReadOnlyFirst::class, ReadOnlyFirst.serializer()) + serializer.setMapper(Return::class, Return.serializer()) + serializer.setMapper(SpecialModelname::class, SpecialModelname.serializer()) + serializer.setMapper(Tag::class, Tag.serializer()) + serializer.setMapper(User::class, User.serializer()) + } + } + + protected suspend fun multipartFormRequest(requestConfig: RequestConfig, body: List?): 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): 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) + } +} diff --git a/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/infrastructure/HttpResponse.kt b/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/infrastructure/HttpResponse.kt new file mode 100644 index 00000000000..c457eb4bce0 --- /dev/null +++ b/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/infrastructure/HttpResponse.kt @@ -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(val response: io.ktor.client.response.HttpResponse, val provider: BodyProvider) { + val status: Int = response.status.value + val success: Boolean = response.status.isSuccess() + val headers: Map> = response.headers.mapEntries() + suspend fun body(): T = provider.body(response) + suspend fun typedBody(type: TypeInfo): V = provider.typedBody(response, type) + + companion object { + private fun Headers.mapEntries(): Map> { + val result = mutableMapOf>() + entries().forEach { result[it.key] = it.value } + return result + } + } +} + +interface BodyProvider { + suspend fun body(response: io.ktor.client.response.HttpResponse): T + suspend fun typedBody(response: io.ktor.client.response.HttpResponse, type: TypeInfo): V +} + +class TypedBodyProvider(private val type: TypeInfo) : BodyProvider { + @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 typedBody(response: io.ktor.client.response.HttpResponse, type: TypeInfo): V = + response.call.receive(type) as V +} + +class MappedBodyProvider(private val provider: BodyProvider, private val block: S.() -> T) : BodyProvider { + override suspend fun body(response: io.ktor.client.response.HttpResponse): T = + block(provider.body(response)) + + override suspend fun typedBody(response: io.ktor.client.response.HttpResponse, type: TypeInfo): V = + provider.typedBody(response, type) +} + +inline fun io.ktor.client.response.HttpResponse.wrap(): HttpResponse = + HttpResponse(this, TypedBodyProvider(typeInfo())) + +fun HttpResponse.map(block: T.() -> V): HttpResponse = + HttpResponse(response, MappedBodyProvider(provider, block)) diff --git a/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/infrastructure/RequestConfig.kt b/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/infrastructure/RequestConfig.kt new file mode 100644 index 00000000000..53e689237d7 --- /dev/null +++ b/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/infrastructure/RequestConfig.kt @@ -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 because rfc2616 defines + * multi-valued headers as csv-only. + */ +data class RequestConfig( + val method: RequestMethod, + val path: String, + val headers: MutableMap = mutableMapOf(), + val query: Map> = mapOf() +) \ No newline at end of file diff --git a/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/infrastructure/RequestMethod.kt b/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/infrastructure/RequestMethod.kt new file mode 100644 index 00000000000..931b12b8bd7 --- /dev/null +++ b/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/infrastructure/RequestMethod.kt @@ -0,0 +1,8 @@ +package org.openapitools.client.infrastructure + +/** + * Provides enumerated HTTP verbs + */ +enum class RequestMethod { + GET, DELETE, HEAD, OPTIONS, PATCH, POST, PUT +} \ No newline at end of file diff --git a/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/models/AdditionalPropertiesClass.kt b/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/models/AdditionalPropertiesClass.kt new file mode 100644 index 00000000000..d64bb86cf67 --- /dev/null +++ b/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/models/AdditionalPropertiesClass.kt @@ -0,0 +1,28 @@ +/** +* OpenAPI Petstore +* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ +* +* 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 +/** + * + * @param mapProperty + * @param mapOfMapProperty + */ +@Serializable +data class AdditionalPropertiesClass ( + @SerialName(value = "mapProperty") val mapProperty: kotlin.collections.Map? = null, + @SerialName(value = "mapOfMapProperty") val mapOfMapProperty: kotlin.collections.Map>? = null +) + + diff --git a/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/models/Animal.kt b/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/models/Animal.kt new file mode 100644 index 00000000000..cd0ad3923ce --- /dev/null +++ b/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/models/Animal.kt @@ -0,0 +1,28 @@ +/** +* OpenAPI Petstore +* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ +* +* 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 +/** + * + * @param className + * @param color + */ +@Serializable +data class Animal ( + @SerialName(value = "className") @Required val className: kotlin.String, + @SerialName(value = "color") val color: kotlin.String? = null +) + + diff --git a/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/models/ApiResponse.kt b/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/models/ApiResponse.kt new file mode 100644 index 00000000000..40d7935e64b --- /dev/null +++ b/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/models/ApiResponse.kt @@ -0,0 +1,30 @@ +/** +* OpenAPI Petstore +* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ +* +* 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 +/** + * + * @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 +) + + diff --git a/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/models/ArrayOfArrayOfNumberOnly.kt b/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/models/ArrayOfArrayOfNumberOnly.kt new file mode 100644 index 00000000000..900776f3917 --- /dev/null +++ b/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/models/ArrayOfArrayOfNumberOnly.kt @@ -0,0 +1,26 @@ +/** +* OpenAPI Petstore +* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ +* +* 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 +/** + * + * @param arrayArrayNumber + */ +@Serializable +data class ArrayOfArrayOfNumberOnly ( + @SerialName(value = "arrayArrayNumber") val arrayArrayNumber: kotlin.Array>? = null +) + + diff --git a/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/models/ArrayOfNumberOnly.kt b/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/models/ArrayOfNumberOnly.kt new file mode 100644 index 00000000000..c86e32ea404 --- /dev/null +++ b/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/models/ArrayOfNumberOnly.kt @@ -0,0 +1,26 @@ +/** +* OpenAPI Petstore +* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ +* +* 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 +/** + * + * @param arrayNumber + */ +@Serializable +data class ArrayOfNumberOnly ( + @SerialName(value = "arrayNumber") val arrayNumber: kotlin.Array? = null +) + + diff --git a/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/models/ArrayTest.kt b/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/models/ArrayTest.kt new file mode 100644 index 00000000000..be4852526be --- /dev/null +++ b/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/models/ArrayTest.kt @@ -0,0 +1,31 @@ +/** +* OpenAPI Petstore +* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ +* +* 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.ReadOnlyFirst + +import kotlinx.serialization.* +import kotlinx.serialization.internal.CommonEnumSerializer +/** + * + * @param arrayOfString + * @param arrayArrayOfInteger + * @param arrayArrayOfModel + */ +@Serializable +data class ArrayTest ( + @SerialName(value = "arrayOfString") val arrayOfString: kotlin.Array? = null, + @SerialName(value = "arrayArrayOfInteger") val arrayArrayOfInteger: kotlin.Array>? = null, + @SerialName(value = "arrayArrayOfModel") val arrayArrayOfModel: kotlin.Array>? = null +) + + diff --git a/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/models/Capitalization.kt b/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/models/Capitalization.kt new file mode 100644 index 00000000000..615dde676ff --- /dev/null +++ b/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/models/Capitalization.kt @@ -0,0 +1,37 @@ +/** +* OpenAPI Petstore +* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ +* +* 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 +/** + * + * @param smallCamel + * @param capitalCamel + * @param smallSnake + * @param capitalSnake + * @param scAETHFlowPoints + * @param ATT_NAME Name of the pet + */ +@Serializable +data class Capitalization ( + @SerialName(value = "smallCamel") val smallCamel: kotlin.String? = null, + @SerialName(value = "capitalCamel") val capitalCamel: kotlin.String? = null, + @SerialName(value = "smallSnake") val smallSnake: kotlin.String? = null, + @SerialName(value = "capitalSnake") val capitalSnake: kotlin.String? = null, + @SerialName(value = "scAETHFlowPoints") val scAETHFlowPoints: kotlin.String? = null, + /* Name of the pet */ + @SerialName(value = "ATT_NAME") val ATT_NAME: kotlin.String? = null +) + + diff --git a/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/models/Cat.kt b/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/models/Cat.kt new file mode 100644 index 00000000000..9cd22bae0ed --- /dev/null +++ b/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/models/Cat.kt @@ -0,0 +1,30 @@ +/** +* OpenAPI Petstore +* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ +* +* 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.Animal +import org.openapitools.client.models.CatAllOf + +import kotlinx.serialization.* +import kotlinx.serialization.internal.CommonEnumSerializer +/** + * + * @param declawed + */ +@Serializable +data class Cat ( + @SerialName(value = "className") @Required val className: kotlin.String, + @SerialName(value = "declawed") val declawed: kotlin.Boolean? = null, + @SerialName(value = "color") val color: kotlin.String? = null +) + + diff --git a/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/models/CatAllOf.kt b/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/models/CatAllOf.kt new file mode 100644 index 00000000000..741ea5fe78c --- /dev/null +++ b/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/models/CatAllOf.kt @@ -0,0 +1,26 @@ +/** +* OpenAPI Petstore +* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ +* +* 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 +/** + * + * @param declawed + */ +@Serializable +data class CatAllOf ( + @SerialName(value = "declawed") val declawed: kotlin.Boolean? = null +) + + diff --git a/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/models/Category.kt b/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/models/Category.kt new file mode 100644 index 00000000000..679dc2ee2e9 --- /dev/null +++ b/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/models/Category.kt @@ -0,0 +1,28 @@ +/** +* OpenAPI Petstore +* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ +* +* 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 +/** + * + * @param id + * @param name + */ +@Serializable +data class Category ( + @SerialName(value = "name") @Required val name: kotlin.String, + @SerialName(value = "id") val id: kotlin.Long? = null +) + + diff --git a/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/models/ClassModel.kt b/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/models/ClassModel.kt new file mode 100644 index 00000000000..50b08153c2c --- /dev/null +++ b/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/models/ClassModel.kt @@ -0,0 +1,26 @@ +/** +* OpenAPI Petstore +* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ +* +* 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 +/** + * Model for testing model with \"_class\" property + * @param propertyClass + */ +@Serializable +data class ClassModel ( + @SerialName(value = "propertyClass") val propertyClass: kotlin.String? = null +) + + diff --git a/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/models/Client.kt b/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/models/Client.kt new file mode 100644 index 00000000000..aec9b147f17 --- /dev/null +++ b/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/models/Client.kt @@ -0,0 +1,26 @@ +/** +* OpenAPI Petstore +* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ +* +* 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 +/** + * + * @param client + */ +@Serializable +data class Client ( + @SerialName(value = "client") val client: kotlin.String? = null +) + + diff --git a/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/models/Dog.kt b/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/models/Dog.kt new file mode 100644 index 00000000000..1a3daca006c --- /dev/null +++ b/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/models/Dog.kt @@ -0,0 +1,30 @@ +/** +* OpenAPI Petstore +* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ +* +* 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.Animal +import org.openapitools.client.models.DogAllOf + +import kotlinx.serialization.* +import kotlinx.serialization.internal.CommonEnumSerializer +/** + * + * @param breed + */ +@Serializable +data class Dog ( + @SerialName(value = "className") @Required val className: kotlin.String, + @SerialName(value = "breed") val breed: kotlin.String? = null, + @SerialName(value = "color") val color: kotlin.String? = null +) + + diff --git a/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/models/DogAllOf.kt b/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/models/DogAllOf.kt new file mode 100644 index 00000000000..b9061237b07 --- /dev/null +++ b/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/models/DogAllOf.kt @@ -0,0 +1,26 @@ +/** +* OpenAPI Petstore +* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ +* +* 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 +/** + * + * @param breed + */ +@Serializable +data class DogAllOf ( + @SerialName(value = "breed") val breed: kotlin.String? = null +) + + diff --git a/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/models/EnumArrays.kt b/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/models/EnumArrays.kt new file mode 100644 index 00000000000..8e8c9d871c1 --- /dev/null +++ b/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/models/EnumArrays.kt @@ -0,0 +1,62 @@ +/** +* OpenAPI Petstore +* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ +* +* 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 +/** + * + * @param justSymbol + * @param arrayEnum + */ +@Serializable +data class EnumArrays ( + @SerialName(value = "justSymbol") val justSymbol: EnumArrays.JustSymbol? = null, + @SerialName(value = "arrayEnum") val arrayEnum: kotlin.Array? = null +) + +{ + /** + * + * Values: greaterThanEqual,dollar + */ + @Serializable(with = JustSymbol.Serializer::class) + enum class JustSymbol(val value: kotlin.String){ + + greaterThanEqual(">="), + + dollar("$"); + + + object Serializer : CommonEnumSerializer("JustSymbol", values(), values().map { it.value }.toTypedArray()) + } +} + +{ + /** + * + * Values: fish,crab + */ + @Serializable(with = ArrayEnum.Serializer::class) + enum class ArrayEnum(val value: kotlin.String){ + + fish("fish"), + + crab("crab"); + + + object Serializer : CommonEnumSerializer("ArrayEnum", values(), values().map { it.value }.toTypedArray()) + } +} + + diff --git a/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/models/EnumClass.kt b/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/models/EnumClass.kt new file mode 100644 index 00000000000..ad529883550 --- /dev/null +++ b/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/models/EnumClass.kt @@ -0,0 +1,38 @@ +/** +* OpenAPI Petstore +* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ +* +* 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 + +/** +* +* Values: abc,minusEfg,leftParenthesisXyzRightParenthesis +*/ +@Serializable(with = EnumClass.Serializer::class) +enum class EnumClass(val value: kotlin.String){ + + + abc("_abc"), + + + minusEfg("-efg"), + + + leftParenthesisXyzRightParenthesis("(xyz)"); + + + + object Serializer : CommonEnumSerializer("EnumClass", values(), values().map { it.value }.toTypedArray()) +} + diff --git a/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/models/EnumTest.kt b/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/models/EnumTest.kt new file mode 100644 index 00000000000..0760f498b14 --- /dev/null +++ b/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/models/EnumTest.kt @@ -0,0 +1,116 @@ +/** +* OpenAPI Petstore +* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ +* +* 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.OuterEnum +import org.openapitools.client.models.OuterEnumDefaultValue +import org.openapitools.client.models.OuterEnumInteger +import org.openapitools.client.models.OuterEnumIntegerDefaultValue + +import kotlinx.serialization.* +import kotlinx.serialization.internal.CommonEnumSerializer +/** + * + * @param enumString + * @param enumStringRequired + * @param enumInteger + * @param enumNumber + * @param outerEnum + * @param outerEnumInteger + * @param outerEnumDefaultValue + * @param outerEnumIntegerDefaultValue + */ +@Serializable +data class EnumTest ( + @SerialName(value = "enumStringRequired") @Required val enumStringRequired: EnumTest.EnumStringRequired, + @SerialName(value = "enumString") val enumString: EnumTest.EnumString? = null, + @SerialName(value = "enumInteger") val enumInteger: EnumTest.EnumInteger? = null, + @SerialName(value = "enumNumber") val enumNumber: EnumTest.EnumNumber? = null, + @SerialName(value = "outerEnum") val outerEnum: OuterEnum? = null, + @SerialName(value = "outerEnumInteger") val outerEnumInteger: OuterEnumInteger? = null, + @SerialName(value = "outerEnumDefaultValue") val outerEnumDefaultValue: OuterEnumDefaultValue? = null, + @SerialName(value = "outerEnumIntegerDefaultValue") val outerEnumIntegerDefaultValue: OuterEnumIntegerDefaultValue? = null +) + +{ + /** + * + * Values: uPPER,lower,eMPTY + */ + @Serializable(with = EnumString.Serializer::class) + enum class EnumString(val value: kotlin.String){ + + uPPER("UPPER"), + + lower("lower"), + + eMPTY(""); + + + object Serializer : CommonEnumSerializer("EnumString", values(), values().map { it.value }.toTypedArray()) + } +} + +{ + /** + * + * Values: uPPER,lower,eMPTY + */ + @Serializable(with = EnumStringRequired.Serializer::class) + enum class EnumStringRequired(val value: kotlin.String){ + + uPPER("UPPER"), + + lower("lower"), + + eMPTY(""); + + + object Serializer : CommonEnumSerializer("EnumStringRequired", values(), values().map { it.value }.toTypedArray()) + } +} + +{ + /** + * + * Values: _1,minus1 + */ + @Serializable(with = EnumInteger.Serializer::class) + enum class EnumInteger(val value: kotlin.Int){ + + _1(1), + + minus1(-1); + + + object Serializer : CommonEnumSerializer("EnumInteger", values(), values().map { it.value }.toTypedArray()) + } +} + +{ + /** + * + * Values: _1period1,minus1Period2 + */ + @Serializable(with = EnumNumber.Serializer::class) + enum class EnumNumber(val value: kotlin.Double){ + + _1period1(1.1), + + minus1Period2(-1.2); + + + object Serializer : CommonEnumSerializer("EnumNumber", values(), values().map { it.value }.toTypedArray()) + } +} + + diff --git a/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/models/FileSchemaTestClass.kt b/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/models/FileSchemaTestClass.kt new file mode 100644 index 00000000000..f735a16ff67 --- /dev/null +++ b/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/models/FileSchemaTestClass.kt @@ -0,0 +1,28 @@ +/** +* OpenAPI Petstore +* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ +* +* 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 +/** + * + * @param file + * @param files + */ +@Serializable +data class FileSchemaTestClass ( + @SerialName(value = "file") val file: java.io.File? = null, + @SerialName(value = "files") val files: kotlin.Array? = null +) + + diff --git a/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/models/Foo.kt b/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/models/Foo.kt new file mode 100644 index 00000000000..c80d542c9ee --- /dev/null +++ b/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/models/Foo.kt @@ -0,0 +1,26 @@ +/** +* OpenAPI Petstore +* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ +* +* 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 +/** + * + * @param bar + */ +@Serializable +data class Foo ( + @SerialName(value = "bar") val bar: kotlin.String? = null +) + + diff --git a/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/models/FormatTest.kt b/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/models/FormatTest.kt new file mode 100644 index 00000000000..688c8fd9a11 --- /dev/null +++ b/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/models/FormatTest.kt @@ -0,0 +1,56 @@ +/** +* OpenAPI Petstore +* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ +* +* 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 +/** + * + * @param integer + * @param int32 + * @param int64 + * @param number + * @param float + * @param double + * @param string + * @param byte + * @param binary + * @param date + * @param dateTime + * @param uuid + * @param password + * @param patternWithDigits A string that is a 10 digit number. Can have leading zeros. + * @param patternWithDigitsAndDelimiter A string starting with 'image_' (case insensitive) and one to three digits following i.e. Image_01. + */ +@Serializable +data class FormatTest ( + @SerialName(value = "number") @Required val number: kotlin.Double, + @SerialName(value = "byte") @Required val byte: kotlin.ByteArray, + @SerialName(value = "date") @Required val date: kotlin.String, + @SerialName(value = "password") @Required val password: kotlin.String, + @SerialName(value = "integer") val integer: kotlin.Int? = null, + @SerialName(value = "int32") val int32: kotlin.Int? = null, + @SerialName(value = "int64") val int64: kotlin.Long? = null, + @SerialName(value = "float") val float: kotlin.Float? = null, + @SerialName(value = "double") val double: kotlin.Double? = null, + @SerialName(value = "string") val string: kotlin.String? = null, + @SerialName(value = "binary") val binary: io.ktor.client.request.forms.InputProvider? = null, + @SerialName(value = "dateTime") val dateTime: kotlin.String? = null, + @SerialName(value = "uuid") val uuid: java.util.UUID? = null, + /* A string that is a 10 digit number. Can have leading zeros. */ + @SerialName(value = "patternWithDigits") val patternWithDigits: kotlin.String? = null, + /* A string starting with 'image_' (case insensitive) and one to three digits following i.e. Image_01. */ + @SerialName(value = "patternWithDigitsAndDelimiter") val patternWithDigitsAndDelimiter: kotlin.String? = null +) + + diff --git a/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/models/HasOnlyReadOnly.kt b/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/models/HasOnlyReadOnly.kt new file mode 100644 index 00000000000..481b222ed96 --- /dev/null +++ b/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/models/HasOnlyReadOnly.kt @@ -0,0 +1,28 @@ +/** +* OpenAPI Petstore +* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ +* +* 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 +/** + * + * @param bar + * @param foo + */ +@Serializable +data class HasOnlyReadOnly ( + @SerialName(value = "bar") val bar: kotlin.String? = null, + @SerialName(value = "foo") val foo: kotlin.String? = null +) + + diff --git a/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/models/HealthCheckResult.kt b/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/models/HealthCheckResult.kt new file mode 100644 index 00000000000..2b83b05c136 --- /dev/null +++ b/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/models/HealthCheckResult.kt @@ -0,0 +1,26 @@ +/** +* OpenAPI Petstore +* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ +* +* 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 +/** + * Just a string to inform instance is up and running. Make it nullable in hope to get it as pointer in generated model. + * @param nullableMessage + */ +@Serializable +data class HealthCheckResult ( + @SerialName(value = "nullableMessage") val nullableMessage: kotlin.String? = null +) + + diff --git a/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/models/InlineObject.kt b/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/models/InlineObject.kt new file mode 100644 index 00000000000..f0b61ce6f35 --- /dev/null +++ b/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/models/InlineObject.kt @@ -0,0 +1,30 @@ +/** +* OpenAPI Petstore +* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ +* +* 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 +/** + * + * @param name Updated name of the pet + * @param status Updated status of the pet + */ +@Serializable +data class InlineObject ( + /* Updated name of the pet */ + @SerialName(value = "name") val name: kotlin.String? = null, + /* Updated status of the pet */ + @SerialName(value = "status") val status: kotlin.String? = null +) + + diff --git a/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/models/InlineObject1.kt b/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/models/InlineObject1.kt new file mode 100644 index 00000000000..144ac2e51ec --- /dev/null +++ b/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/models/InlineObject1.kt @@ -0,0 +1,30 @@ +/** +* OpenAPI Petstore +* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ +* +* 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 +/** + * + * @param additionalMetadata Additional data to pass to server + * @param file file to upload + */ +@Serializable +data class InlineObject1 ( + /* Additional data to pass to server */ + @SerialName(value = "additionalMetadata") val additionalMetadata: kotlin.String? = null, + /* file to upload */ + @SerialName(value = "file") val file: io.ktor.client.request.forms.InputProvider? = null +) + + diff --git a/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/models/InlineObject2.kt b/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/models/InlineObject2.kt new file mode 100644 index 00000000000..4a0d1ab7a23 --- /dev/null +++ b/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/models/InlineObject2.kt @@ -0,0 +1,66 @@ +/** +* OpenAPI Petstore +* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ +* +* 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 +/** + * + * @param enumFormStringArray Form parameter enum test (string array) + * @param enumFormString Form parameter enum test (string) + */ +@Serializable +data class InlineObject2 ( + /* Form parameter enum test (string array) */ + @SerialName(value = "enumFormStringArray") val enumFormStringArray: kotlin.Array? = null, + /* Form parameter enum test (string) */ + @SerialName(value = "enumFormString") val enumFormString: InlineObject2.EnumFormString? = null +) + +{ + /** + * Form parameter enum test (string array) + * Values: greaterThan,dollar + */ + @Serializable(with = EnumFormStringArray.Serializer::class) + enum class EnumFormStringArray(val value: kotlin.String){ + + greaterThan(">"), + + dollar("$"); + + + object Serializer : CommonEnumSerializer("EnumFormStringArray", values(), values().map { it.value }.toTypedArray()) + } +} + +{ + /** + * Form parameter enum test (string) + * Values: abc,minusEfg,leftParenthesisXyzRightParenthesis + */ + @Serializable(with = EnumFormString.Serializer::class) + enum class EnumFormString(val value: kotlin.String){ + + abc("_abc"), + + minusEfg("-efg"), + + leftParenthesisXyzRightParenthesis("(xyz)"); + + + object Serializer : CommonEnumSerializer("EnumFormString", values(), values().map { it.value }.toTypedArray()) + } +} + + diff --git a/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/models/InlineObject3.kt b/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/models/InlineObject3.kt new file mode 100644 index 00000000000..feb084ffeba --- /dev/null +++ b/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/models/InlineObject3.kt @@ -0,0 +1,66 @@ +/** +* OpenAPI Petstore +* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ +* +* 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 +/** + * + * @param integer None + * @param int32 None + * @param int64 None + * @param number None + * @param float None + * @param double None + * @param string None + * @param patternWithoutDelimiter None + * @param byte None + * @param binary None + * @param date None + * @param dateTime None + * @param password None + * @param callback None + */ +@Serializable +data class InlineObject3 ( + /* None */ + @SerialName(value = "number") @Required val number: kotlin.Double, + /* None */ + @SerialName(value = "double") @Required val double: kotlin.Double, + /* None */ + @SerialName(value = "patternWithoutDelimiter") @Required val patternWithoutDelimiter: kotlin.String, + /* None */ + @SerialName(value = "byte") @Required val byte: kotlin.ByteArray, + /* None */ + @SerialName(value = "integer") val integer: kotlin.Int? = null, + /* None */ + @SerialName(value = "int32") val int32: kotlin.Int? = null, + /* None */ + @SerialName(value = "int64") val int64: kotlin.Long? = null, + /* None */ + @SerialName(value = "float") val float: kotlin.Float? = null, + /* None */ + @SerialName(value = "string") val string: kotlin.String? = null, + /* None */ + @SerialName(value = "binary") val binary: io.ktor.client.request.forms.InputProvider? = null, + /* None */ + @SerialName(value = "date") val date: kotlin.String? = null, + /* None */ + @SerialName(value = "dateTime") val dateTime: kotlin.String? = null, + /* None */ + @SerialName(value = "password") val password: kotlin.String? = null, + /* None */ + @SerialName(value = "callback") val callback: kotlin.String? = null +) + + diff --git a/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/models/InlineObject4.kt b/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/models/InlineObject4.kt new file mode 100644 index 00000000000..a696b8c90e3 --- /dev/null +++ b/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/models/InlineObject4.kt @@ -0,0 +1,30 @@ +/** +* OpenAPI Petstore +* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ +* +* 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 +/** + * + * @param param field1 + * @param param2 field2 + */ +@Serializable +data class InlineObject4 ( + /* field1 */ + @SerialName(value = "param") @Required val param: kotlin.String, + /* field2 */ + @SerialName(value = "param2") @Required val param2: kotlin.String +) + + diff --git a/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/models/InlineObject5.kt b/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/models/InlineObject5.kt new file mode 100644 index 00000000000..146ab1a8879 --- /dev/null +++ b/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/models/InlineObject5.kt @@ -0,0 +1,30 @@ +/** +* OpenAPI Petstore +* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ +* +* 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 +/** + * + * @param additionalMetadata Additional data to pass to server + * @param requiredFile file to upload + */ +@Serializable +data class InlineObject5 ( + /* file to upload */ + @SerialName(value = "requiredFile") @Required val requiredFile: io.ktor.client.request.forms.InputProvider, + /* Additional data to pass to server */ + @SerialName(value = "additionalMetadata") val additionalMetadata: kotlin.String? = null +) + + diff --git a/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/models/InlineResponseDefault.kt b/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/models/InlineResponseDefault.kt new file mode 100644 index 00000000000..fd5b6600278 --- /dev/null +++ b/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/models/InlineResponseDefault.kt @@ -0,0 +1,27 @@ +/** +* OpenAPI Petstore +* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ +* +* 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.Foo + +import kotlinx.serialization.* +import kotlinx.serialization.internal.CommonEnumSerializer +/** + * + * @param string + */ +@Serializable +data class InlineResponseDefault ( + @SerialName(value = "string") val string: Foo? = null +) + + diff --git a/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/models/List.kt b/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/models/List.kt new file mode 100644 index 00000000000..d0d3e59f102 --- /dev/null +++ b/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/models/List.kt @@ -0,0 +1,26 @@ +/** +* OpenAPI Petstore +* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ +* +* 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 +/** + * + * @param ``123minusList`` + */ +@Serializable +data class List ( + @SerialName(value = "`123minusList`") val ``123minusList``: kotlin.String? = null +) + + diff --git a/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/models/MapTest.kt b/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/models/MapTest.kt new file mode 100644 index 00000000000..ab3bc869a6d --- /dev/null +++ b/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/models/MapTest.kt @@ -0,0 +1,49 @@ +/** +* OpenAPI Petstore +* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ +* +* 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 +/** + * + * @param mapMapOfString + * @param mapOfEnumString + * @param directMap + * @param indirectMap + */ +@Serializable +data class MapTest ( + @SerialName(value = "mapMapOfString") val mapMapOfString: kotlin.collections.Map>? = null, + @SerialName(value = "mapOfEnumString") val mapOfEnumString: MapTest.MapOfEnumString? = null, + @SerialName(value = "directMap") val directMap: kotlin.collections.Map? = null, + @SerialName(value = "indirectMap") val indirectMap: kotlin.collections.Map? = null +) + +{ + /** + * + * Values: uPPER,lower + */ + @Serializable(with = MapOfEnumString.Serializer::class) + enum class MapOfEnumString(val value: kotlin.collections.Map){ + + uPPER("UPPER"), + + lower("lower"); + + + object Serializer : CommonEnumSerializer("MapOfEnumString", values(), values().map { it.value }.toTypedArray()) + } +} + + diff --git a/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/models/MixedPropertiesAndAdditionalPropertiesClass.kt b/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/models/MixedPropertiesAndAdditionalPropertiesClass.kt new file mode 100644 index 00000000000..022359bc92a --- /dev/null +++ b/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/models/MixedPropertiesAndAdditionalPropertiesClass.kt @@ -0,0 +1,31 @@ +/** +* OpenAPI Petstore +* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ +* +* 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.Animal + +import kotlinx.serialization.* +import kotlinx.serialization.internal.CommonEnumSerializer +/** + * + * @param uuid + * @param dateTime + * @param map + */ +@Serializable +data class MixedPropertiesAndAdditionalPropertiesClass ( + @SerialName(value = "uuid") val uuid: java.util.UUID? = null, + @SerialName(value = "dateTime") val dateTime: kotlin.String? = null, + @SerialName(value = "map") val map: kotlin.collections.Map? = null +) + + diff --git a/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/models/Model200Response.kt b/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/models/Model200Response.kt new file mode 100644 index 00000000000..9acea028946 --- /dev/null +++ b/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/models/Model200Response.kt @@ -0,0 +1,28 @@ +/** +* OpenAPI Petstore +* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ +* +* 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 +/** + * Model for testing model name starting with number + * @param name + * @param propertyClass + */ +@Serializable +data class Model200Response ( + @SerialName(value = "name") val name: kotlin.Int? = null, + @SerialName(value = "propertyClass") val propertyClass: kotlin.String? = null +) + + diff --git a/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/models/Name.kt b/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/models/Name.kt new file mode 100644 index 00000000000..e4fc149660a --- /dev/null +++ b/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/models/Name.kt @@ -0,0 +1,32 @@ +/** +* OpenAPI Petstore +* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ +* +* 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 +/** + * Model for testing model name same as property name + * @param name + * @param snakeCase + * @param property + * @param ``123number`` + */ +@Serializable +data class Name ( + @SerialName(value = "name") @Required val name: kotlin.Int, + @SerialName(value = "snakeCase") val snakeCase: kotlin.Int? = null, + @SerialName(value = "property") val property: kotlin.String? = null, + @SerialName(value = "`123number`") val ``123number``: kotlin.Int? = null +) + + diff --git a/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/models/NullableClass.kt b/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/models/NullableClass.kt new file mode 100644 index 00000000000..cc0b5d3599f --- /dev/null +++ b/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/models/NullableClass.kt @@ -0,0 +1,48 @@ +/** +* OpenAPI Petstore +* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ +* +* 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 +/** + * + * @param integerProp + * @param numberProp + * @param booleanProp + * @param stringProp + * @param dateProp + * @param datetimeProp + * @param arrayNullableProp + * @param arrayAndItemsNullableProp + * @param arrayItemsNullable + * @param objectNullableProp + * @param objectAndItemsNullableProp + * @param objectItemsNullable + */ +@Serializable +data class NullableClass ( + @SerialName(value = "integerProp") val integerProp: kotlin.Int? = null, + @SerialName(value = "numberProp") val numberProp: kotlin.Double? = null, + @SerialName(value = "booleanProp") val booleanProp: kotlin.Boolean? = null, + @SerialName(value = "stringProp") val stringProp: kotlin.String? = null, + @SerialName(value = "dateProp") val dateProp: kotlin.String? = null, + @SerialName(value = "datetimeProp") val datetimeProp: kotlin.String? = null, + @SerialName(value = "arrayNullableProp") val arrayNullableProp: kotlin.Array? = null, + @SerialName(value = "arrayAndItemsNullableProp") val arrayAndItemsNullableProp: kotlin.Array? = null, + @SerialName(value = "arrayItemsNullable") val arrayItemsNullable: kotlin.Array? = null, + @SerialName(value = "objectNullableProp") val objectNullableProp: kotlin.collections.Map? = null, + @SerialName(value = "objectAndItemsNullableProp") val objectAndItemsNullableProp: kotlin.collections.Map? = null, + @SerialName(value = "objectItemsNullable") val objectItemsNullable: kotlin.collections.Map? = null +) + + diff --git a/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/models/NumberOnly.kt b/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/models/NumberOnly.kt new file mode 100644 index 00000000000..cb3d58233a5 --- /dev/null +++ b/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/models/NumberOnly.kt @@ -0,0 +1,26 @@ +/** +* OpenAPI Petstore +* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ +* +* 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 +/** + * + * @param justNumber + */ +@Serializable +data class NumberOnly ( + @SerialName(value = "justNumber") val justNumber: kotlin.Double? = null +) + + diff --git a/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/models/Order.kt b/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/models/Order.kt new file mode 100644 index 00000000000..a3f24b72035 --- /dev/null +++ b/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/models/Order.kt @@ -0,0 +1,56 @@ +/** +* OpenAPI Petstore +* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ +* +* 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 +/** + * + * @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", values(), values().map { it.value }.toTypedArray()) + } +} + + diff --git a/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/models/OuterComposite.kt b/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/models/OuterComposite.kt new file mode 100644 index 00000000000..c4430f07e08 --- /dev/null +++ b/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/models/OuterComposite.kt @@ -0,0 +1,30 @@ +/** +* OpenAPI Petstore +* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ +* +* 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 +/** + * + * @param myNumber + * @param myString + * @param myBoolean + */ +@Serializable +data class OuterComposite ( + @SerialName(value = "myNumber") val myNumber: kotlin.Double? = null, + @SerialName(value = "myString") val myString: kotlin.String? = null, + @SerialName(value = "myBoolean") val myBoolean: kotlin.Boolean? = null +) + + diff --git a/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/models/OuterEnum.kt b/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/models/OuterEnum.kt new file mode 100644 index 00000000000..51e77cc5ac6 --- /dev/null +++ b/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/models/OuterEnum.kt @@ -0,0 +1,38 @@ +/** +* OpenAPI Petstore +* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ +* +* 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 + +/** +* +* Values: placed,approved,delivered +*/ +@Serializable(with = OuterEnum.Serializer::class) +enum class OuterEnum(val value: kotlin.String){ + + + placed("placed"), + + + approved("approved"), + + + delivered("delivered"); + + + + object Serializer : CommonEnumSerializer("OuterEnum", values(), values().map { it.value }.toTypedArray()) +} + diff --git a/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/models/OuterEnumDefaultValue.kt b/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/models/OuterEnumDefaultValue.kt new file mode 100644 index 00000000000..0380a542738 --- /dev/null +++ b/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/models/OuterEnumDefaultValue.kt @@ -0,0 +1,38 @@ +/** +* OpenAPI Petstore +* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ +* +* 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 + +/** +* +* Values: placed,approved,delivered +*/ +@Serializable(with = OuterEnumDefaultValue.Serializer::class) +enum class OuterEnumDefaultValue(val value: kotlin.String){ + + + placed("placed"), + + + approved("approved"), + + + delivered("delivered"); + + + + object Serializer : CommonEnumSerializer("OuterEnumDefaultValue", values(), values().map { it.value }.toTypedArray()) +} + diff --git a/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/models/OuterEnumInteger.kt b/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/models/OuterEnumInteger.kt new file mode 100644 index 00000000000..70389422113 --- /dev/null +++ b/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/models/OuterEnumInteger.kt @@ -0,0 +1,38 @@ +/** +* OpenAPI Petstore +* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ +* +* 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 + +/** +* +* Values: _0,_1,_2 +*/ +@Serializable(with = OuterEnumInteger.Serializer::class) +enum class OuterEnumInteger(val value: kotlin.Int){ + + + _0(0), + + + _1(1), + + + _2(2); + + + + object Serializer : CommonEnumSerializer("OuterEnumInteger", values(), values().map { it.value }.toTypedArray()) +} + diff --git a/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/models/OuterEnumIntegerDefaultValue.kt b/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/models/OuterEnumIntegerDefaultValue.kt new file mode 100644 index 00000000000..d80ab91475a --- /dev/null +++ b/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/models/OuterEnumIntegerDefaultValue.kt @@ -0,0 +1,38 @@ +/** +* OpenAPI Petstore +* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ +* +* 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 + +/** +* +* Values: _0,_1,_2 +*/ +@Serializable(with = OuterEnumIntegerDefaultValue.Serializer::class) +enum class OuterEnumIntegerDefaultValue(val value: kotlin.Int){ + + + _0(0), + + + _1(1), + + + _2(2); + + + + object Serializer : CommonEnumSerializer("OuterEnumIntegerDefaultValue", values(), values().map { it.value }.toTypedArray()) +} + diff --git a/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/models/Pet.kt b/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/models/Pet.kt new file mode 100644 index 00000000000..84c0f8daf9d --- /dev/null +++ b/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/models/Pet.kt @@ -0,0 +1,58 @@ +/** +* OpenAPI Petstore +* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ +* +* 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 +/** + * + * @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, + @SerialName(value = "id") val id: kotlin.Long? = null, + @SerialName(value = "category") val category: Category? = null, + @SerialName(value = "tags") val tags: kotlin.Array? = 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", values(), values().map { it.value }.toTypedArray()) + } +} + + diff --git a/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/models/ReadOnlyFirst.kt b/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/models/ReadOnlyFirst.kt new file mode 100644 index 00000000000..9adbc159af1 --- /dev/null +++ b/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/models/ReadOnlyFirst.kt @@ -0,0 +1,28 @@ +/** +* OpenAPI Petstore +* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ +* +* 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 +/** + * + * @param bar + * @param baz + */ +@Serializable +data class ReadOnlyFirst ( + @SerialName(value = "bar") val bar: kotlin.String? = null, + @SerialName(value = "baz") val baz: kotlin.String? = null +) + + diff --git a/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/models/Return.kt b/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/models/Return.kt new file mode 100644 index 00000000000..1ab847c2a16 --- /dev/null +++ b/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/models/Return.kt @@ -0,0 +1,26 @@ +/** +* OpenAPI Petstore +* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ +* +* 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 +/** + * Model for testing reserved words + * @param ``return`` + */ +@Serializable +data class Return ( + @SerialName(value = "`return`") val ``return``: kotlin.Int? = null +) + + diff --git a/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/models/SpecialModelname.kt b/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/models/SpecialModelname.kt new file mode 100644 index 00000000000..515ceca44ae --- /dev/null +++ b/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/models/SpecialModelname.kt @@ -0,0 +1,26 @@ +/** +* OpenAPI Petstore +* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ +* +* 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 +/** + * + * @param dollarSpecialLeftSquareBracketPropertyPeriodNameRightSquareBracket + */ +@Serializable +data class SpecialModelname ( + @SerialName(value = "dollarSpecialLeftSquareBracketPropertyPeriodNameRightSquareBracket") val dollarSpecialLeftSquareBracketPropertyPeriodNameRightSquareBracket: kotlin.Long? = null +) + + diff --git a/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/models/Tag.kt b/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/models/Tag.kt new file mode 100644 index 00000000000..8249ebd41bb --- /dev/null +++ b/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/models/Tag.kt @@ -0,0 +1,28 @@ +/** +* OpenAPI Petstore +* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ +* +* 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 +/** + * + * @param id + * @param name + */ +@Serializable +data class Tag ( + @SerialName(value = "id") val id: kotlin.Long? = null, + @SerialName(value = "name") val name: kotlin.String? = null +) + + diff --git a/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/models/User.kt b/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/models/User.kt new file mode 100644 index 00000000000..fb882946719 --- /dev/null +++ b/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/models/User.kt @@ -0,0 +1,41 @@ +/** +* OpenAPI Petstore +* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ +* +* 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 +/** + * + * @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 +) + + diff --git a/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonTest/kotlin/util/Coroutine.kt b/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonTest/kotlin/util/Coroutine.kt new file mode 100644 index 00000000000..5be963e41b8 --- /dev/null +++ b/samples/openapi3/client/petstore/kotlin-multiplatform/src/commonTest/kotlin/util/Coroutine.kt @@ -0,0 +1,23 @@ +/** +* OpenAPI Petstore +* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ +* +* 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 runTest(block: suspend CoroutineScope.() -> T): T diff --git a/samples/openapi3/client/petstore/kotlin-multiplatform/src/iosTest/kotlin/util/Coroutine.kt b/samples/openapi3/client/petstore/kotlin-multiplatform/src/iosTest/kotlin/util/Coroutine.kt new file mode 100644 index 00000000000..ebcc320dbbb --- /dev/null +++ b/samples/openapi3/client/petstore/kotlin-multiplatform/src/iosTest/kotlin/util/Coroutine.kt @@ -0,0 +1,18 @@ +/** +* OpenAPI Petstore +* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ +* +* 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 runTest(block: suspend CoroutineScope.() -> T): T = kotlinx.coroutines.runBlocking(EmptyCoroutineContext, block) diff --git a/samples/openapi3/client/petstore/kotlin-multiplatform/src/jvmTest/kotlin/util/Coroutine.kt b/samples/openapi3/client/petstore/kotlin-multiplatform/src/jvmTest/kotlin/util/Coroutine.kt new file mode 100644 index 00000000000..ebcc320dbbb --- /dev/null +++ b/samples/openapi3/client/petstore/kotlin-multiplatform/src/jvmTest/kotlin/util/Coroutine.kt @@ -0,0 +1,18 @@ +/** +* OpenAPI Petstore +* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ +* +* 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 runTest(block: suspend CoroutineScope.() -> T): T = kotlinx.coroutines.runBlocking(EmptyCoroutineContext, block)