diff --git a/.github/workflows/samples-kotlin-client.yaml b/.github/workflows/samples-kotlin-client.yaml index 78faf118c1..ab5b2c91b5 100644 --- a/.github/workflows/samples-kotlin-client.yaml +++ b/.github/workflows/samples-kotlin-client.yaml @@ -25,6 +25,7 @@ jobs: - samples/client/petstore/kotlin - samples/client/petstore/kotlin-gson - samples/client/petstore/kotlin-jackson + - samples/client/petstore/kotlin-model-prefix-type-mappings # needs Android configured #- samples/client/petstore/kotlin-json-request-string - samples/client/petstore/kotlin-jvm-okhttp4-coroutines diff --git a/.github/workflows/samples-kotlin-echo-api.yaml b/.github/workflows/samples-kotlin-echo-api.yaml index ec7c27c549..f4fc53d0c5 100644 --- a/.github/workflows/samples-kotlin-echo-api.yaml +++ b/.github/workflows/samples-kotlin-echo-api.yaml @@ -19,6 +19,7 @@ jobs: sample: # clients - samples/client/echo_api/kotlin-jvm-spring-3-restclient + - samples/client/echo_api/kotlin-model-prefix-type-mappings steps: - uses: actions/checkout@v4 - uses: actions/setup-java@v4 diff --git a/bin/configs/kotlin-model-prefix-type-mapping-echo-api.yaml b/bin/configs/kotlin-model-prefix-type-mapping-echo-api.yaml new file mode 100644 index 0000000000..b790566ee4 --- /dev/null +++ b/bin/configs/kotlin-model-prefix-type-mapping-echo-api.yaml @@ -0,0 +1,15 @@ +generatorName: kotlin +outputDir: samples/client/echo_api/kotlin-model-prefix-type-mappings +inputSpec: modules/openapi-generator/src/test/resources/3_0/kotlin/echo_api.yaml +templateDir: modules/openapi-generator/src/main/resources/kotlin-client +typeMappings: + java.io.File: RequestBody +modelNamePrefix: Api +additionalProperties: + artifactId: kotlin-client-prefix-mapping + useCoroutines: true + library: jvm-retrofit2 + enumPropertyNaming: UPPERCASE + serializationLibrary: gson +openapiNormalizer: + SIMPLIFY_ONEOF_ANYOF=false diff --git a/bin/configs/kotlin-model-prefix-type-mapping.yaml b/bin/configs/kotlin-model-prefix-type-mapping.yaml new file mode 100644 index 0000000000..993e0f197c --- /dev/null +++ b/bin/configs/kotlin-model-prefix-type-mapping.yaml @@ -0,0 +1,15 @@ +generatorName: kotlin +outputDir: samples/client/petstore/kotlin-model-prefix-type-mappings +inputSpec: modules/openapi-generator/src/test/resources/3_0/kotlin/petstore.yaml +templateDir: modules/openapi-generator/src/main/resources/kotlin-client +typeMappings: + java.io.File: RequestBody +modelNamePrefix: Api +additionalProperties: + artifactId: kotlin-client-prefix-mapping + useCoroutines: true + library: jvm-retrofit2 + enumPropertyNaming: UPPERCASE + serializationLibrary: gson +openapiNormalizer: + SIMPLIFY_ONEOF_ANYOF=false 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 35774e198e..c2dd6a4051 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 @@ -953,6 +953,12 @@ public class KotlinClientCodegen extends AbstractKotlinCodegen { if (Boolean.TRUE.equals(param.isFile)) { operations.put("x-kotlin-multipart-import", true); } + + if (param.isQueryParam && "form".equals(param.style) && param.isExplode && param.isModel) { + // query parameter (style: form, explode) referencing models need to import + // models defined in the properties of the models + operations.put("x-koltin-import-models", true); + } } if (usesRetrofit2Library() && StringUtils.isNotEmpty(operation.path) && operation.path.startsWith("/")) { diff --git a/modules/openapi-generator/src/main/resources/kotlin-client/libraries/jvm-retrofit2/api.mustache b/modules/openapi-generator/src/main/resources/kotlin-client/libraries/jvm-retrofit2/api.mustache index 7368ed2976..8576bee5b4 100644 --- a/modules/openapi-generator/src/main/resources/kotlin-client/libraries/jvm-retrofit2/api.mustache +++ b/modules/openapi-generator/src/main/resources/kotlin-client/libraries/jvm-retrofit2/api.mustache @@ -59,6 +59,10 @@ import kotlinx.serialization.* {{/imports}} {{#operations}} +{{#x-koltin-import-models}} +import {{{packageName}}}.models.* + +{{/x-koltin-import-models}} {{#x-kotlin-multipart-import}} {{^isMultipart}} import okhttp3.MultipartBody diff --git a/samples/client/echo_api/kotlin-model-prefix-type-mappings/.openapi-generator-ignore b/samples/client/echo_api/kotlin-model-prefix-type-mappings/.openapi-generator-ignore new file mode 100644 index 0000000000..7484ee590a --- /dev/null +++ b/samples/client/echo_api/kotlin-model-prefix-type-mappings/.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/echo_api/kotlin-model-prefix-type-mappings/.openapi-generator/FILES b/samples/client/echo_api/kotlin-model-prefix-type-mappings/.openapi-generator/FILES new file mode 100644 index 0000000000..f0ac80519d --- /dev/null +++ b/samples/client/echo_api/kotlin-model-prefix-type-mappings/.openapi-generator/FILES @@ -0,0 +1,47 @@ +README.md +build.gradle +docs/AuthApi.md +docs/Bird.md +docs/BodyApi.md +docs/Category.md +docs/DefaultValue.md +docs/FormApi.md +docs/HeaderApi.md +docs/NumberPropertiesOnly.md +docs/PathApi.md +docs/Pet.md +docs/Query.md +docs/QueryApi.md +docs/StringEnumRef.md +docs/Tag.md +docs/TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter.md +gradle/wrapper/gradle-wrapper.jar +gradle/wrapper/gradle-wrapper.properties +gradlew +gradlew.bat +settings.gradle +src/main/kotlin/org/openapitools/client/apis/AuthApi.kt +src/main/kotlin/org/openapitools/client/apis/BodyApi.kt +src/main/kotlin/org/openapitools/client/apis/FormApi.kt +src/main/kotlin/org/openapitools/client/apis/HeaderApi.kt +src/main/kotlin/org/openapitools/client/apis/PathApi.kt +src/main/kotlin/org/openapitools/client/apis/QueryApi.kt +src/main/kotlin/org/openapitools/client/auth/HttpBasicAuth.kt +src/main/kotlin/org/openapitools/client/auth/HttpBearerAuth.kt +src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt +src/main/kotlin/org/openapitools/client/infrastructure/ByteArrayAdapter.kt +src/main/kotlin/org/openapitools/client/infrastructure/CollectionFormats.kt +src/main/kotlin/org/openapitools/client/infrastructure/LocalDateAdapter.kt +src/main/kotlin/org/openapitools/client/infrastructure/LocalDateTimeAdapter.kt +src/main/kotlin/org/openapitools/client/infrastructure/OffsetDateTimeAdapter.kt +src/main/kotlin/org/openapitools/client/infrastructure/ResponseExt.kt +src/main/kotlin/org/openapitools/client/infrastructure/Serializer.kt +src/main/kotlin/org/openapitools/client/models/ApiBird.kt +src/main/kotlin/org/openapitools/client/models/ApiCategory.kt +src/main/kotlin/org/openapitools/client/models/ApiDefaultValue.kt +src/main/kotlin/org/openapitools/client/models/ApiNumberPropertiesOnly.kt +src/main/kotlin/org/openapitools/client/models/ApiPet.kt +src/main/kotlin/org/openapitools/client/models/ApiQuery.kt +src/main/kotlin/org/openapitools/client/models/ApiStringEnumRef.kt +src/main/kotlin/org/openapitools/client/models/ApiTag.kt +src/main/kotlin/org/openapitools/client/models/ApiTestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter.kt diff --git a/samples/client/echo_api/kotlin-model-prefix-type-mappings/.openapi-generator/VERSION b/samples/client/echo_api/kotlin-model-prefix-type-mappings/.openapi-generator/VERSION new file mode 100644 index 0000000000..08bfd0643b --- /dev/null +++ b/samples/client/echo_api/kotlin-model-prefix-type-mappings/.openapi-generator/VERSION @@ -0,0 +1 @@ +7.5.0-SNAPSHOT diff --git a/samples/client/echo_api/kotlin-model-prefix-type-mappings/README.md b/samples/client/echo_api/kotlin-model-prefix-type-mappings/README.md new file mode 100644 index 0000000000..1369fc7935 --- /dev/null +++ b/samples/client/echo_api/kotlin-model-prefix-type-mappings/README.md @@ -0,0 +1,103 @@ +# org.openapitools.client - Kotlin client library for Echo Server API + +Echo Server API + +## Overview +This API client was generated by the [OpenAPI Generator](https://openapi-generator.tech) project. By using the [openapi-spec](https://github.com/OAI/OpenAPI-Specification) from a remote server, you can easily generate an API client. + +- API version: 0.1.0 +- Package version: +- Generator version: 7.5.0-SNAPSHOT +- Build package: org.openapitools.codegen.languages.KotlinClientCodegen + +## Requires + +* Kotlin 1.7.21 +* Gradle 7.5 + +## Build + +First, create the gradle wrapper script: + +``` +gradle wrapper +``` + +Then, run: + +``` +./gradlew check assemble +``` + +This runs all tests and packages the library. + +## Features/Implementation Notes + +* Supports JSON inputs/outputs, File inputs, and Form inputs. +* Supports collection formats for query parameters: csv, tsv, ssv, pipes. +* Some Kotlin and Java types are fully qualified to avoid conflicts with types defined in OpenAPI definitions. +* Implementation of ApiClient is intended to reduce method counts, specifically to benefit Android targets. + + +## Documentation for API Endpoints + +All URIs are relative to *http://localhost:3000* + +Class | Method | HTTP request | Description +------------ | ------------- | ------------- | ------------- +*AuthApi* | [**testAuthHttpBasic**](docs/AuthApi.md#testauthhttpbasic) | **POST** auth/http/basic | To test HTTP basic authentication +*AuthApi* | [**testAuthHttpBearer**](docs/AuthApi.md#testauthhttpbearer) | **POST** auth/http/bearer | To test HTTP bearer authentication +*BodyApi* | [**testBinaryGif**](docs/BodyApi.md#testbinarygif) | **POST** binary/gif | Test binary (gif) response body +*BodyApi* | [**testBodyApplicationOctetstreamBinary**](docs/BodyApi.md#testbodyapplicationoctetstreambinary) | **POST** body/application/octetstream/binary | Test body parameter(s) +*BodyApi* | [**testBodyMultipartFormdataArrayOfBinary**](docs/BodyApi.md#testbodymultipartformdataarrayofbinary) | **POST** body/application/octetstream/array_of_binary | Test array of binary in multipart mime +*BodyApi* | [**testBodyMultipartFormdataSingleBinary**](docs/BodyApi.md#testbodymultipartformdatasinglebinary) | **POST** body/application/octetstream/single_binary | Test single binary in multipart mime +*BodyApi* | [**testEchoBodyFreeFormObjectResponseString**](docs/BodyApi.md#testechobodyfreeformobjectresponsestring) | **POST** echo/body/FreeFormObject/response_string | Test free form object +*BodyApi* | [**testEchoBodyPet**](docs/BodyApi.md#testechobodypet) | **POST** echo/body/Pet | Test body parameter(s) +*BodyApi* | [**testEchoBodyPetResponseString**](docs/BodyApi.md#testechobodypetresponsestring) | **POST** echo/body/Pet/response_string | Test empty response body +*BodyApi* | [**testEchoBodyTagResponseString**](docs/BodyApi.md#testechobodytagresponsestring) | **POST** echo/body/Tag/response_string | Test empty json (request body) +*FormApi* | [**testFormIntegerBooleanString**](docs/FormApi.md#testformintegerbooleanstring) | **POST** form/integer/boolean/string | Test form parameter(s) +*FormApi* | [**testFormOneof**](docs/FormApi.md#testformoneof) | **POST** form/oneof | Test form parameter(s) for oneOf schema +*HeaderApi* | [**testHeaderIntegerBooleanStringEnums**](docs/HeaderApi.md#testheaderintegerbooleanstringenums) | **GET** header/integer/boolean/string/enums | Test header parameter(s) +*PathApi* | [**testsPathStringPathStringIntegerPathIntegerEnumNonrefStringPathEnumRefStringPath**](docs/PathApi.md#testspathstringpathstringintegerpathintegerenumnonrefstringpathenumrefstringpath) | **GET** path/string/{path_string}/integer/{path_integer}/{enum_nonref_string_path}/{enum_ref_string_path} | Test path parameter(s) +*QueryApi* | [**testEnumRefString**](docs/QueryApi.md#testenumrefstring) | **GET** query/enum_ref_string | Test query parameter(s) +*QueryApi* | [**testQueryDatetimeDateString**](docs/QueryApi.md#testquerydatetimedatestring) | **GET** query/datetime/date/string | Test query parameter(s) +*QueryApi* | [**testQueryIntegerBooleanString**](docs/QueryApi.md#testqueryintegerbooleanstring) | **GET** query/integer/boolean/string | Test query parameter(s) +*QueryApi* | [**testQueryStyleDeepObjectExplodeTrueObject**](docs/QueryApi.md#testquerystyledeepobjectexplodetrueobject) | **GET** query/style_deepObject/explode_true/object | Test query parameter(s) +*QueryApi* | [**testQueryStyleFormExplodeTrueArrayString**](docs/QueryApi.md#testquerystyleformexplodetruearraystring) | **GET** query/style_form/explode_true/array_string | Test query parameter(s) +*QueryApi* | [**testQueryStyleFormExplodeTrueObject**](docs/QueryApi.md#testquerystyleformexplodetrueobject) | **GET** query/style_form/explode_true/object | Test query parameter(s) + + + +## Documentation for Models + + - [org.openapitools.client.models.ApiBird](docs/ApiBird.md) + - [org.openapitools.client.models.ApiCategory](docs/ApiCategory.md) + - [org.openapitools.client.models.ApiDefaultValue](docs/ApiDefaultValue.md) + - [org.openapitools.client.models.ApiNumberPropertiesOnly](docs/ApiNumberPropertiesOnly.md) + - [org.openapitools.client.models.ApiPet](docs/ApiPet.md) + - [org.openapitools.client.models.ApiQuery](docs/ApiQuery.md) + - [org.openapitools.client.models.ApiStringEnumRef](docs/ApiStringEnumRef.md) + - [org.openapitools.client.models.ApiTag](docs/ApiTag.md) + - [org.openapitools.client.models.ApiTestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter](docs/ApiTestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter.md) + + + +## Documentation for Authorization + + +Authentication schemes defined for the API: + +### http_auth + +- **Type**: HTTP basic authentication + + +### http_bearer_auth + +- **Type**: HTTP Bearer Token authentication + + + +## Author + +team@openapitools.org diff --git a/samples/client/echo_api/kotlin-model-prefix-type-mappings/build.gradle b/samples/client/echo_api/kotlin-model-prefix-type-mappings/build.gradle new file mode 100644 index 0000000000..3fb89b6c91 --- /dev/null +++ b/samples/client/echo_api/kotlin-model-prefix-type-mappings/build.gradle @@ -0,0 +1,65 @@ +group 'org.openapitools' +version '1.0.0' + +wrapper { + gradleVersion = '7.5' + distributionUrl = "https://services.gradle.org/distributions/gradle-$gradleVersion-all.zip" +} + +buildscript { + ext.kotlin_version = '1.8.10' + ext.retrofitVersion = '2.9.0' + ext.spotless_version = "6.13.0" + + repositories { + maven { url "https://repo1.maven.org/maven2" } + } + dependencies { + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" + classpath "com.diffplug.spotless:spotless-plugin-gradle:$spotless_version" + } +} + +apply plugin: 'kotlin' +apply plugin: 'maven-publish' +apply plugin: 'com.diffplug.spotless' + +repositories { + maven { url "https://repo1.maven.org/maven2" } +} + +// Use spotless plugin to automatically format code, remove unused import, etc +// To apply changes directly to the file, run `gradlew spotlessApply` +// Ref: https://github.com/diffplug/spotless/tree/main/plugin-gradle +spotless { + // comment out below to run spotless as part of the `check` task + enforceCheck false + + format 'misc', { + // define the files (e.g. '*.gradle', '*.md') to apply `misc` to + target '.gitignore' + + // define the steps to apply to those files + trimTrailingWhitespace() + indentWithSpaces() // Takes an integer argument if you don't like 4 + endWithNewline() + } + kotlin { + ktfmt() + } +} + +test { + useJUnitPlatform() +} + +dependencies { + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" + implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4" + implementation "com.google.code.gson:gson:2.9.0" + implementation "com.squareup.okhttp3:logging-interceptor:4.10.0" + implementation "com.squareup.retrofit2:retrofit:$retrofitVersion" + implementation "com.squareup.retrofit2:converter-gson:$retrofitVersion" + implementation "com.squareup.retrofit2:converter-scalars:$retrofitVersion" + testImplementation "io.kotlintest:kotlintest-runner-junit5:3.4.2" +} diff --git a/samples/client/echo_api/kotlin-model-prefix-type-mappings/docs/AuthApi.md b/samples/client/echo_api/kotlin-model-prefix-type-mappings/docs/AuthApi.md new file mode 100644 index 0000000000..fc2aacf431 --- /dev/null +++ b/samples/client/echo_api/kotlin-model-prefix-type-mappings/docs/AuthApi.md @@ -0,0 +1,88 @@ +# AuthApi + +All URIs are relative to *http://localhost:3000* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**testAuthHttpBasic**](AuthApi.md#testAuthHttpBasic) | **POST** auth/http/basic | To test HTTP basic authentication +[**testAuthHttpBearer**](AuthApi.md#testAuthHttpBearer) | **POST** auth/http/bearer | To test HTTP bearer authentication + + + +To test HTTP basic authentication + +To test HTTP basic authentication + +### Example +```kotlin +// Import classes: +//import org.openapitools.client.* +//import org.openapitools.client.infrastructure.* +//import org.openapitools.client.models.* + +val apiClient = ApiClient() +apiClient.setCredentials("USERNAME", "PASSWORD") +val webService = apiClient.createWebservice(AuthApi::class.java) + +launch(Dispatchers.IO) { + val result : kotlin.String = webService.testAuthHttpBasic() +} +``` + +### Parameters +This endpoint does not need any parameter. + +### Return type + +**kotlin.String** + +### Authorization + + +Configure http_auth: + ApiClient().setCredentials("USERNAME", "PASSWORD") + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: text/plain + + +To test HTTP bearer authentication + +To test HTTP bearer authentication + +### Example +```kotlin +// Import classes: +//import org.openapitools.client.* +//import org.openapitools.client.infrastructure.* +//import org.openapitools.client.models.* + +val apiClient = ApiClient() +apiClient.setBearerToken("TOKEN") +val webService = apiClient.createWebservice(AuthApi::class.java) + +launch(Dispatchers.IO) { + val result : kotlin.String = webService.testAuthHttpBearer() +} +``` + +### Parameters +This endpoint does not need any parameter. + +### Return type + +**kotlin.String** + +### Authorization + + +Configure http_bearer_auth: + ApiClient().setBearerToken("TOKEN") + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: text/plain + diff --git a/samples/client/echo_api/kotlin-model-prefix-type-mappings/docs/Bird.md b/samples/client/echo_api/kotlin-model-prefix-type-mappings/docs/Bird.md new file mode 100644 index 0000000000..24ab8ec1e1 --- /dev/null +++ b/samples/client/echo_api/kotlin-model-prefix-type-mappings/docs/Bird.md @@ -0,0 +1,11 @@ + +# ApiBird + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**propertySize** | **kotlin.String** | | [optional] +**color** | **kotlin.String** | | [optional] + + + diff --git a/samples/client/echo_api/kotlin-model-prefix-type-mappings/docs/BodyApi.md b/samples/client/echo_api/kotlin-model-prefix-type-mappings/docs/BodyApi.md new file mode 100644 index 0000000000..ec76bd7d9c --- /dev/null +++ b/samples/client/echo_api/kotlin-model-prefix-type-mappings/docs/BodyApi.md @@ -0,0 +1,332 @@ +# BodyApi + +All URIs are relative to *http://localhost:3000* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**testBinaryGif**](BodyApi.md#testBinaryGif) | **POST** binary/gif | Test binary (gif) response body +[**testBodyApplicationOctetstreamBinary**](BodyApi.md#testBodyApplicationOctetstreamBinary) | **POST** body/application/octetstream/binary | Test body parameter(s) +[**testBodyMultipartFormdataArrayOfBinary**](BodyApi.md#testBodyMultipartFormdataArrayOfBinary) | **POST** body/application/octetstream/array_of_binary | Test array of binary in multipart mime +[**testBodyMultipartFormdataSingleBinary**](BodyApi.md#testBodyMultipartFormdataSingleBinary) | **POST** body/application/octetstream/single_binary | Test single binary in multipart mime +[**testEchoBodyFreeFormObjectResponseString**](BodyApi.md#testEchoBodyFreeFormObjectResponseString) | **POST** echo/body/FreeFormObject/response_string | Test free form object +[**testEchoBodyPet**](BodyApi.md#testEchoBodyPet) | **POST** echo/body/Pet | Test body parameter(s) +[**testEchoBodyPetResponseString**](BodyApi.md#testEchoBodyPetResponseString) | **POST** echo/body/Pet/response_string | Test empty response body +[**testEchoBodyTagResponseString**](BodyApi.md#testEchoBodyTagResponseString) | **POST** echo/body/Tag/response_string | Test empty json (request body) + + + +Test binary (gif) response body + +Test binary (gif) response body + +### Example +```kotlin +// Import classes: +//import org.openapitools.client.* +//import org.openapitools.client.infrastructure.* +//import org.openapitools.client.models.* + +val apiClient = ApiClient() +val webService = apiClient.createWebservice(BodyApi::class.java) + +launch(Dispatchers.IO) { + val result : RequestBody = webService.testBinaryGif() +} +``` + +### Parameters +This endpoint does not need any parameter. + +### Return type + +[**RequestBody**](java.io.File.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: image/gif + + +Test body parameter(s) + +Test body parameter(s) + +### Example +```kotlin +// Import classes: +//import org.openapitools.client.* +//import org.openapitools.client.infrastructure.* +//import org.openapitools.client.models.* + +val apiClient = ApiClient() +val webService = apiClient.createWebservice(BodyApi::class.java) +val body : RequestBody = BINARY_DATA_HERE // RequestBody | + +launch(Dispatchers.IO) { + val result : kotlin.String = webService.testBodyApplicationOctetstreamBinary(body) +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | **RequestBody**| | [optional] + +### Return type + +**kotlin.String** + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/octet-stream + - **Accept**: text/plain + + +Test array of binary in multipart mime + +Test array of binary in multipart mime + +### Example +```kotlin +// Import classes: +//import org.openapitools.client.* +//import org.openapitools.client.infrastructure.* +//import org.openapitools.client.models.* + +val apiClient = ApiClient() +val webService = apiClient.createWebservice(BodyApi::class.java) +val files : kotlin.collections.List = /path/to/file.txt // kotlin.collections.List | + +launch(Dispatchers.IO) { + val result : kotlin.String = webService.testBodyMultipartFormdataArrayOfBinary(files) +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **files** | **kotlin.collections.List<RequestBody>**| | + +### Return type + +**kotlin.String** + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: multipart/form-data + - **Accept**: text/plain + + +Test single binary in multipart mime + +Test single binary in multipart mime + +### Example +```kotlin +// Import classes: +//import org.openapitools.client.* +//import org.openapitools.client.infrastructure.* +//import org.openapitools.client.models.* + +val apiClient = ApiClient() +val webService = apiClient.createWebservice(BodyApi::class.java) +val myFile : RequestBody = BINARY_DATA_HERE // RequestBody | + +launch(Dispatchers.IO) { + val result : kotlin.String = webService.testBodyMultipartFormdataSingleBinary(myFile) +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **myFile** | **RequestBody**| | [optional] + +### Return type + +**kotlin.String** + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: multipart/form-data + - **Accept**: text/plain + + +Test free form object + +Test free form object + +### Example +```kotlin +// Import classes: +//import org.openapitools.client.* +//import org.openapitools.client.infrastructure.* +//import org.openapitools.client.models.* + +val apiClient = ApiClient() +val webService = apiClient.createWebservice(BodyApi::class.java) +val body : kotlin.Any = Object // kotlin.Any | Free form object + +launch(Dispatchers.IO) { + val result : kotlin.String = webService.testEchoBodyFreeFormObjectResponseString(body) +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | **kotlin.Any**| Free form object | [optional] + +### Return type + +**kotlin.String** + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: text/plain + + +Test body parameter(s) + +Test body parameter(s) + +### Example +```kotlin +// Import classes: +//import org.openapitools.client.* +//import org.openapitools.client.infrastructure.* +//import org.openapitools.client.models.* + +val apiClient = ApiClient() +val webService = apiClient.createWebservice(BodyApi::class.java) +val apiPet : ApiPet = // ApiPet | Pet object that needs to be added to the store + +launch(Dispatchers.IO) { + val result : ApiPet = webService.testEchoBodyPet(apiPet) +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **apiPet** | [**ApiPet**](ApiPet.md)| Pet object that needs to be added to the store | [optional] + +### Return type + +[**ApiPet**](ApiPet.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: application/json + + +Test empty response body + +Test empty response body + +### Example +```kotlin +// Import classes: +//import org.openapitools.client.* +//import org.openapitools.client.infrastructure.* +//import org.openapitools.client.models.* + +val apiClient = ApiClient() +val webService = apiClient.createWebservice(BodyApi::class.java) +val apiPet : ApiPet = // ApiPet | Pet object that needs to be added to the store + +launch(Dispatchers.IO) { + val result : kotlin.String = webService.testEchoBodyPetResponseString(apiPet) +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **apiPet** | [**ApiPet**](ApiPet.md)| Pet object that needs to be added to the store | [optional] + +### Return type + +**kotlin.String** + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: text/plain + + +Test empty json (request body) + +Test empty json (request body) + +### Example +```kotlin +// Import classes: +//import org.openapitools.client.* +//import org.openapitools.client.infrastructure.* +//import org.openapitools.client.models.* + +val apiClient = ApiClient() +val webService = apiClient.createWebservice(BodyApi::class.java) +val apiTag : ApiTag = // ApiTag | Tag object + +launch(Dispatchers.IO) { + val result : kotlin.String = webService.testEchoBodyTagResponseString(apiTag) +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **apiTag** | [**ApiTag**](ApiTag.md)| Tag object | [optional] + +### Return type + +**kotlin.String** + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: text/plain + diff --git a/samples/client/echo_api/kotlin-model-prefix-type-mappings/docs/Category.md b/samples/client/echo_api/kotlin-model-prefix-type-mappings/docs/Category.md new file mode 100644 index 0000000000..4445602c2d --- /dev/null +++ b/samples/client/echo_api/kotlin-model-prefix-type-mappings/docs/Category.md @@ -0,0 +1,11 @@ + +# ApiCategory + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **kotlin.Long** | | [optional] +**name** | **kotlin.String** | | [optional] + + + diff --git a/samples/client/echo_api/kotlin-model-prefix-type-mappings/docs/DefaultValue.md b/samples/client/echo_api/kotlin-model-prefix-type-mappings/docs/DefaultValue.md new file mode 100644 index 0000000000..4775afddef --- /dev/null +++ b/samples/client/echo_api/kotlin-model-prefix-type-mappings/docs/DefaultValue.md @@ -0,0 +1,24 @@ + +# ApiDefaultValue + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**arrayStringEnumRefDefault** | [**kotlin.collections.List<ApiStringEnumRef>**](ApiStringEnumRef.md) | | [optional] +**arrayStringEnumDefault** | [**inline**](#kotlin.collections.List<ArrayStringEnumDefault>) | | [optional] +**arrayStringDefault** | **kotlin.collections.List<kotlin.String>** | | [optional] +**arrayIntegerDefault** | **kotlin.collections.List<kotlin.Int>** | | [optional] +**arrayString** | **kotlin.collections.List<kotlin.String>** | | [optional] +**arrayStringNullable** | **kotlin.collections.List<kotlin.String>** | | [optional] +**arrayStringExtensionNullable** | **kotlin.collections.List<kotlin.String>** | | [optional] +**stringNullable** | **kotlin.String** | | [optional] + + + +## Enum: array_string_enum_default +Name | Value +---- | ----- +arrayStringEnumDefault | success, failure, unclassified + + + diff --git a/samples/client/echo_api/kotlin-model-prefix-type-mappings/docs/FormApi.md b/samples/client/echo_api/kotlin-model-prefix-type-mappings/docs/FormApi.md new file mode 100644 index 0000000000..5b301ad360 --- /dev/null +++ b/samples/client/echo_api/kotlin-model-prefix-type-mappings/docs/FormApi.md @@ -0,0 +1,104 @@ +# FormApi + +All URIs are relative to *http://localhost:3000* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**testFormIntegerBooleanString**](FormApi.md#testFormIntegerBooleanString) | **POST** form/integer/boolean/string | Test form parameter(s) +[**testFormOneof**](FormApi.md#testFormOneof) | **POST** form/oneof | Test form parameter(s) for oneOf schema + + + +Test form parameter(s) + +Test form parameter(s) + +### Example +```kotlin +// Import classes: +//import org.openapitools.client.* +//import org.openapitools.client.infrastructure.* +//import org.openapitools.client.models.* + +val apiClient = ApiClient() +val webService = apiClient.createWebservice(FormApi::class.java) +val integerForm : kotlin.Int = 56 // kotlin.Int | +val booleanForm : kotlin.Boolean = true // kotlin.Boolean | +val stringForm : kotlin.String = stringForm_example // kotlin.String | + +launch(Dispatchers.IO) { + val result : kotlin.String = webService.testFormIntegerBooleanString(integerForm, booleanForm, stringForm) +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **integerForm** | **kotlin.Int**| | [optional] + **booleanForm** | **kotlin.Boolean**| | [optional] + **stringForm** | **kotlin.String**| | [optional] + +### Return type + +**kotlin.String** + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/x-www-form-urlencoded + - **Accept**: text/plain + + +Test form parameter(s) for oneOf schema + +Test form parameter(s) for oneOf schema + +### Example +```kotlin +// Import classes: +//import org.openapitools.client.* +//import org.openapitools.client.infrastructure.* +//import org.openapitools.client.models.* + +val apiClient = ApiClient() +val webService = apiClient.createWebservice(FormApi::class.java) +val form1 : kotlin.String = form1_example // kotlin.String | +val form2 : kotlin.Int = 56 // kotlin.Int | +val form3 : kotlin.String = form3_example // kotlin.String | +val form4 : kotlin.Boolean = true // kotlin.Boolean | +val id : kotlin.Long = 789 // kotlin.Long | +val name : kotlin.String = name_example // kotlin.String | + +launch(Dispatchers.IO) { + val result : kotlin.String = webService.testFormOneof(form1, form2, form3, form4, id, name) +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **form1** | **kotlin.String**| | [optional] + **form2** | **kotlin.Int**| | [optional] + **form3** | **kotlin.String**| | [optional] + **form4** | **kotlin.Boolean**| | [optional] + **id** | **kotlin.Long**| | [optional] + **name** | **kotlin.String**| | [optional] + +### Return type + +**kotlin.String** + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/x-www-form-urlencoded + - **Accept**: text/plain + diff --git a/samples/client/echo_api/kotlin-model-prefix-type-mappings/docs/HeaderApi.md b/samples/client/echo_api/kotlin-model-prefix-type-mappings/docs/HeaderApi.md new file mode 100644 index 0000000000..26fcb46bee --- /dev/null +++ b/samples/client/echo_api/kotlin-model-prefix-type-mappings/docs/HeaderApi.md @@ -0,0 +1,57 @@ +# HeaderApi + +All URIs are relative to *http://localhost:3000* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**testHeaderIntegerBooleanStringEnums**](HeaderApi.md#testHeaderIntegerBooleanStringEnums) | **GET** header/integer/boolean/string/enums | Test header parameter(s) + + + +Test header parameter(s) + +Test header parameter(s) + +### Example +```kotlin +// Import classes: +//import org.openapitools.client.* +//import org.openapitools.client.infrastructure.* +//import org.openapitools.client.models.* + +val apiClient = ApiClient() +val webService = apiClient.createWebservice(HeaderApi::class.java) +val integerHeader : kotlin.Int = 56 // kotlin.Int | +val booleanHeader : kotlin.Boolean = true // kotlin.Boolean | +val stringHeader : kotlin.String = stringHeader_example // kotlin.String | +val enumNonrefStringHeader : kotlin.String = enumNonrefStringHeader_example // kotlin.String | +val enumRefStringHeader : ApiStringEnumRef = // ApiStringEnumRef | + +launch(Dispatchers.IO) { + val result : kotlin.String = webService.testHeaderIntegerBooleanStringEnums(integerHeader, booleanHeader, stringHeader, enumNonrefStringHeader, enumRefStringHeader) +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **integerHeader** | **kotlin.Int**| | [optional] + **booleanHeader** | **kotlin.Boolean**| | [optional] + **stringHeader** | **kotlin.String**| | [optional] + **enumNonrefStringHeader** | **kotlin.String**| | [optional] [enum: success, failure, unclassified] + **enumRefStringHeader** | [**ApiStringEnumRef**](.md)| | [optional] [enum: success, failure, unclassified] + +### Return type + +**kotlin.String** + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: text/plain + diff --git a/samples/client/echo_api/kotlin-model-prefix-type-mappings/docs/NumberPropertiesOnly.md b/samples/client/echo_api/kotlin-model-prefix-type-mappings/docs/NumberPropertiesOnly.md new file mode 100644 index 0000000000..8741ec4ec1 --- /dev/null +++ b/samples/client/echo_api/kotlin-model-prefix-type-mappings/docs/NumberPropertiesOnly.md @@ -0,0 +1,12 @@ + +# ApiNumberPropertiesOnly + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**number** | [**java.math.BigDecimal**](java.math.BigDecimal.md) | | [optional] +**float** | **kotlin.Float** | | [optional] +**double** | **kotlin.Double** | | [optional] + + + diff --git a/samples/client/echo_api/kotlin-model-prefix-type-mappings/docs/PathApi.md b/samples/client/echo_api/kotlin-model-prefix-type-mappings/docs/PathApi.md new file mode 100644 index 0000000000..fc3ae5d8a5 --- /dev/null +++ b/samples/client/echo_api/kotlin-model-prefix-type-mappings/docs/PathApi.md @@ -0,0 +1,55 @@ +# PathApi + +All URIs are relative to *http://localhost:3000* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**testsPathStringPathStringIntegerPathIntegerEnumNonrefStringPathEnumRefStringPath**](PathApi.md#testsPathStringPathStringIntegerPathIntegerEnumNonrefStringPathEnumRefStringPath) | **GET** path/string/{path_string}/integer/{path_integer}/{enum_nonref_string_path}/{enum_ref_string_path} | Test path parameter(s) + + + +Test path parameter(s) + +Test path parameter(s) + +### Example +```kotlin +// Import classes: +//import org.openapitools.client.* +//import org.openapitools.client.infrastructure.* +//import org.openapitools.client.models.* + +val apiClient = ApiClient() +val webService = apiClient.createWebservice(PathApi::class.java) +val pathString : kotlin.String = pathString_example // kotlin.String | +val pathInteger : kotlin.Int = 56 // kotlin.Int | +val enumNonrefStringPath : kotlin.String = enumNonrefStringPath_example // kotlin.String | +val enumRefStringPath : ApiStringEnumRef = // ApiStringEnumRef | + +launch(Dispatchers.IO) { + val result : kotlin.String = webService.testsPathStringPathStringIntegerPathIntegerEnumNonrefStringPathEnumRefStringPath(pathString, pathInteger, enumNonrefStringPath, enumRefStringPath) +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **pathString** | **kotlin.String**| | + **pathInteger** | **kotlin.Int**| | + **enumNonrefStringPath** | **kotlin.String**| | [enum: success, failure, unclassified] + **enumRefStringPath** | [**ApiStringEnumRef**](.md)| | [enum: success, failure, unclassified] + +### Return type + +**kotlin.String** + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: text/plain + diff --git a/samples/client/echo_api/kotlin-model-prefix-type-mappings/docs/Pet.md b/samples/client/echo_api/kotlin-model-prefix-type-mappings/docs/Pet.md new file mode 100644 index 0000000000..f525df0ffd --- /dev/null +++ b/samples/client/echo_api/kotlin-model-prefix-type-mappings/docs/Pet.md @@ -0,0 +1,22 @@ + +# ApiPet + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**name** | **kotlin.String** | | +**photoUrls** | **kotlin.collections.List<kotlin.String>** | | +**id** | **kotlin.Long** | | [optional] +**category** | [**ApiCategory**](ApiCategory.md) | | [optional] +**tags** | [**kotlin.collections.List<ApiTag>**](ApiTag.md) | | [optional] +**status** | [**inline**](#Status) | pet status in the store | [optional] + + + +## Enum: status +Name | Value +---- | ----- +status | available, pending, sold + + + diff --git a/samples/client/echo_api/kotlin-model-prefix-type-mappings/docs/Query.md b/samples/client/echo_api/kotlin-model-prefix-type-mappings/docs/Query.md new file mode 100644 index 0000000000..973bc49a7d --- /dev/null +++ b/samples/client/echo_api/kotlin-model-prefix-type-mappings/docs/Query.md @@ -0,0 +1,18 @@ + +# ApiQuery + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **kotlin.Long** | Query | [optional] +**outcomes** | [**inline**](#kotlin.collections.List<Outcomes>) | | [optional] + + + +## Enum: outcomes +Name | Value +---- | ----- +outcomes | SUCCESS, FAILURE, SKIPPED + + + diff --git a/samples/client/echo_api/kotlin-model-prefix-type-mappings/docs/QueryApi.md b/samples/client/echo_api/kotlin-model-prefix-type-mappings/docs/QueryApi.md new file mode 100644 index 0000000000..f8dc4354cc --- /dev/null +++ b/samples/client/echo_api/kotlin-model-prefix-type-mappings/docs/QueryApi.md @@ -0,0 +1,264 @@ +# QueryApi + +All URIs are relative to *http://localhost:3000* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**testEnumRefString**](QueryApi.md#testEnumRefString) | **GET** query/enum_ref_string | Test query parameter(s) +[**testQueryDatetimeDateString**](QueryApi.md#testQueryDatetimeDateString) | **GET** query/datetime/date/string | Test query parameter(s) +[**testQueryIntegerBooleanString**](QueryApi.md#testQueryIntegerBooleanString) | **GET** query/integer/boolean/string | Test query parameter(s) +[**testQueryStyleDeepObjectExplodeTrueObject**](QueryApi.md#testQueryStyleDeepObjectExplodeTrueObject) | **GET** query/style_deepObject/explode_true/object | Test query parameter(s) +[**testQueryStyleFormExplodeTrueArrayString**](QueryApi.md#testQueryStyleFormExplodeTrueArrayString) | **GET** query/style_form/explode_true/array_string | Test query parameter(s) +[**testQueryStyleFormExplodeTrueObject**](QueryApi.md#testQueryStyleFormExplodeTrueObject) | **GET** query/style_form/explode_true/object | Test query parameter(s) + + + +Test query parameter(s) + +Test query parameter(s) + +### Example +```kotlin +// Import classes: +//import org.openapitools.client.* +//import org.openapitools.client.infrastructure.* +//import org.openapitools.client.models.* + +val apiClient = ApiClient() +val webService = apiClient.createWebservice(QueryApi::class.java) +val enumNonrefStringQuery : kotlin.String = enumNonrefStringQuery_example // kotlin.String | +val enumRefStringQuery : ApiStringEnumRef = // ApiStringEnumRef | + +launch(Dispatchers.IO) { + val result : kotlin.String = webService.testEnumRefString(enumNonrefStringQuery, enumRefStringQuery) +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **enumNonrefStringQuery** | **kotlin.String**| | [optional] [enum: success, failure, unclassified] + **enumRefStringQuery** | [**ApiStringEnumRef**](.md)| | [optional] [enum: success, failure, unclassified] + +### Return type + +**kotlin.String** + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: text/plain + + +Test query parameter(s) + +Test query parameter(s) + +### Example +```kotlin +// Import classes: +//import org.openapitools.client.* +//import org.openapitools.client.infrastructure.* +//import org.openapitools.client.models.* + +val apiClient = ApiClient() +val webService = apiClient.createWebservice(QueryApi::class.java) +val datetimeQuery : java.time.OffsetDateTime = 2013-10-20T19:20:30+01:00 // java.time.OffsetDateTime | +val dateQuery : java.time.LocalDate = 2013-10-20 // java.time.LocalDate | +val stringQuery : kotlin.String = stringQuery_example // kotlin.String | + +launch(Dispatchers.IO) { + val result : kotlin.String = webService.testQueryDatetimeDateString(datetimeQuery, dateQuery, stringQuery) +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **datetimeQuery** | **java.time.OffsetDateTime**| | [optional] + **dateQuery** | **java.time.LocalDate**| | [optional] + **stringQuery** | **kotlin.String**| | [optional] + +### Return type + +**kotlin.String** + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: text/plain + + +Test query parameter(s) + +Test query parameter(s) + +### Example +```kotlin +// Import classes: +//import org.openapitools.client.* +//import org.openapitools.client.infrastructure.* +//import org.openapitools.client.models.* + +val apiClient = ApiClient() +val webService = apiClient.createWebservice(QueryApi::class.java) +val integerQuery : kotlin.Int = 56 // kotlin.Int | +val booleanQuery : kotlin.Boolean = true // kotlin.Boolean | +val stringQuery : kotlin.String = stringQuery_example // kotlin.String | + +launch(Dispatchers.IO) { + val result : kotlin.String = webService.testQueryIntegerBooleanString(integerQuery, booleanQuery, stringQuery) +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **integerQuery** | **kotlin.Int**| | [optional] + **booleanQuery** | **kotlin.Boolean**| | [optional] + **stringQuery** | **kotlin.String**| | [optional] + +### Return type + +**kotlin.String** + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: text/plain + + +Test query parameter(s) + +Test query parameter(s) + +### Example +```kotlin +// Import classes: +//import org.openapitools.client.* +//import org.openapitools.client.infrastructure.* +//import org.openapitools.client.models.* + +val apiClient = ApiClient() +val webService = apiClient.createWebservice(QueryApi::class.java) +val queryObject : ApiPet = // ApiPet | + +launch(Dispatchers.IO) { + val result : kotlin.String = webService.testQueryStyleDeepObjectExplodeTrueObject(queryObject) +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **queryObject** | [**ApiPet**](.md)| | [optional] + +### Return type + +**kotlin.String** + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: text/plain + + +Test query parameter(s) + +Test query parameter(s) + +### Example +```kotlin +// Import classes: +//import org.openapitools.client.* +//import org.openapitools.client.infrastructure.* +//import org.openapitools.client.models.* + +val apiClient = ApiClient() +val webService = apiClient.createWebservice(QueryApi::class.java) +val queryObject : ApiTestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter = // ApiTestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter | + +launch(Dispatchers.IO) { + val result : kotlin.String = webService.testQueryStyleFormExplodeTrueArrayString(queryObject) +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **queryObject** | [**ApiTestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter**](.md)| | [optional] + +### Return type + +**kotlin.String** + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: text/plain + + +Test query parameter(s) + +Test query parameter(s) + +### Example +```kotlin +// Import classes: +//import org.openapitools.client.* +//import org.openapitools.client.infrastructure.* +//import org.openapitools.client.models.* + +val apiClient = ApiClient() +val webService = apiClient.createWebservice(QueryApi::class.java) +val queryObject : ApiPet = // ApiPet | + +launch(Dispatchers.IO) { + val result : kotlin.String = webService.testQueryStyleFormExplodeTrueObject(queryObject) +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **queryObject** | [**ApiPet**](.md)| | [optional] + +### Return type + +**kotlin.String** + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: text/plain + diff --git a/samples/client/echo_api/kotlin-model-prefix-type-mappings/docs/StringEnumRef.md b/samples/client/echo_api/kotlin-model-prefix-type-mappings/docs/StringEnumRef.md new file mode 100644 index 0000000000..d33c28cdbb --- /dev/null +++ b/samples/client/echo_api/kotlin-model-prefix-type-mappings/docs/StringEnumRef.md @@ -0,0 +1,14 @@ + +# ApiStringEnumRef + +## Enum + + + * `SUCCESS` (value: `"success"`) + + * `FAILURE` (value: `"failure"`) + + * `UNCLASSIFIED` (value: `"unclassified"`) + + + diff --git a/samples/client/echo_api/kotlin-model-prefix-type-mappings/docs/Tag.md b/samples/client/echo_api/kotlin-model-prefix-type-mappings/docs/Tag.md new file mode 100644 index 0000000000..91a171469a --- /dev/null +++ b/samples/client/echo_api/kotlin-model-prefix-type-mappings/docs/Tag.md @@ -0,0 +1,11 @@ + +# ApiTag + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **kotlin.Long** | | [optional] +**name** | **kotlin.String** | | [optional] + + + diff --git a/samples/client/echo_api/kotlin-model-prefix-type-mappings/docs/TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter.md b/samples/client/echo_api/kotlin-model-prefix-type-mappings/docs/TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter.md new file mode 100644 index 0000000000..f5b3cec9e2 --- /dev/null +++ b/samples/client/echo_api/kotlin-model-prefix-type-mappings/docs/TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter.md @@ -0,0 +1,10 @@ + +# ApiTestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**propertyValues** | **kotlin.collections.List<kotlin.String>** | | [optional] + + + diff --git a/samples/client/echo_api/kotlin-model-prefix-type-mappings/gradle/wrapper/gradle-wrapper.jar b/samples/client/echo_api/kotlin-model-prefix-type-mappings/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000000..c1962a79e2 Binary files /dev/null and b/samples/client/echo_api/kotlin-model-prefix-type-mappings/gradle/wrapper/gradle-wrapper.jar differ diff --git a/samples/client/echo_api/kotlin-model-prefix-type-mappings/gradle/wrapper/gradle-wrapper.properties b/samples/client/echo_api/kotlin-model-prefix-type-mappings/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000000..8707e8b506 --- /dev/null +++ b/samples/client/echo_api/kotlin-model-prefix-type-mappings/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-all.zip +networkTimeout=10000 +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/samples/client/echo_api/kotlin-model-prefix-type-mappings/gradlew b/samples/client/echo_api/kotlin-model-prefix-type-mappings/gradlew new file mode 100644 index 0000000000..aeb74cbb43 --- /dev/null +++ b/samples/client/echo_api/kotlin-model-prefix-type-mappings/gradlew @@ -0,0 +1,245 @@ +#!/bin/sh + +# +# Copyright © 2015-2021 the original authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +############################################################################## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# +############################################################################## + +# Attempt to set APP_HOME + +# Resolve links: $0 may be a link +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac +done + +# This is normally unused +# shellcheck disable=SC2034 +APP_BASE_NAME=${0##*/} +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD=maximum + +warn () { + echo "$*" +} >&2 + +die () { + echo + echo "$*" + echo + exit 1 +} >&2 + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD=$JAVA_HOME/jre/sh/java + else + JAVACMD=$JAVA_HOME/bin/java + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD=java + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC3045 + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC3045 + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac +fi + +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + + # Now convert the arguments - kludge to limit ourselves to /bin/sh + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) + fi + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg + done +fi + + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Collect all arguments for the java command; +# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of +# shell script including quotes and variable substitutions, so put them in +# double quotes to make sure that they get re-expanded; and +# * put everything else in single quotes, so that it's not re-expanded. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' + +exec "$JAVACMD" "$@" diff --git a/samples/client/echo_api/kotlin-model-prefix-type-mappings/gradlew.bat b/samples/client/echo_api/kotlin-model-prefix-type-mappings/gradlew.bat new file mode 100644 index 0000000000..93e3f59f13 --- /dev/null +++ b/samples/client/echo_api/kotlin-model-prefix-type-mappings/gradlew.bat @@ -0,0 +1,92 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%"=="" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if %ERRORLEVEL% equ 0 goto execute + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if %ERRORLEVEL% equ 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! +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/samples/client/echo_api/kotlin-model-prefix-type-mappings/settings.gradle b/samples/client/echo_api/kotlin-model-prefix-type-mappings/settings.gradle new file mode 100644 index 0000000000..4b38a2a52a --- /dev/null +++ b/samples/client/echo_api/kotlin-model-prefix-type-mappings/settings.gradle @@ -0,0 +1,2 @@ + +rootProject.name = 'kotlin-client-prefix-mapping' diff --git a/samples/client/echo_api/kotlin-model-prefix-type-mappings/src/main/kotlin/org/openapitools/client/apis/AuthApi.kt b/samples/client/echo_api/kotlin-model-prefix-type-mappings/src/main/kotlin/org/openapitools/client/apis/AuthApi.kt new file mode 100644 index 0000000000..559a0bfb0c --- /dev/null +++ b/samples/client/echo_api/kotlin-model-prefix-type-mappings/src/main/kotlin/org/openapitools/client/apis/AuthApi.kt @@ -0,0 +1,33 @@ +package org.openapitools.client.apis + +import org.openapitools.client.infrastructure.CollectionFormats.* +import retrofit2.http.* +import retrofit2.Response +import okhttp3.RequestBody +import com.google.gson.annotations.SerializedName + + +interface AuthApi { + /** + * To test HTTP basic authentication + * To test HTTP basic authentication + * Responses: + * - 200: Successful operation + * + * @return [kotlin.String] + */ + @POST("auth/http/basic") + suspend fun testAuthHttpBasic(): Response + + /** + * To test HTTP bearer authentication + * To test HTTP bearer authentication + * Responses: + * - 200: Successful operation + * + * @return [kotlin.String] + */ + @POST("auth/http/bearer") + suspend fun testAuthHttpBearer(): Response + +} diff --git a/samples/client/echo_api/kotlin-model-prefix-type-mappings/src/main/kotlin/org/openapitools/client/apis/BodyApi.kt b/samples/client/echo_api/kotlin-model-prefix-type-mappings/src/main/kotlin/org/openapitools/client/apis/BodyApi.kt new file mode 100644 index 0000000000..5cd52c1ba4 --- /dev/null +++ b/samples/client/echo_api/kotlin-model-prefix-type-mappings/src/main/kotlin/org/openapitools/client/apis/BodyApi.kt @@ -0,0 +1,113 @@ +package org.openapitools.client.apis + +import org.openapitools.client.infrastructure.CollectionFormats.* +import retrofit2.http.* +import retrofit2.Response +import okhttp3.RequestBody +import okhttp3.ResponseBody +import com.google.gson.annotations.SerializedName + +import org.openapitools.client.models.ApiPet +import org.openapitools.client.models.ApiTag + +import okhttp3.MultipartBody + +interface BodyApi { + /** + * Test binary (gif) response body + * Test binary (gif) response body + * Responses: + * - 200: Successful operation + * + * @return [ResponseBody] + */ + @POST("binary/gif") + suspend fun testBinaryGif(): Response + + /** + * Test body parameter(s) + * Test body parameter(s) + * Responses: + * - 200: Successful operation + * + * @param body (optional) + * @return [kotlin.String] + */ + @POST("body/application/octetstream/binary") + suspend fun testBodyApplicationOctetstreamBinary(@Body body: RequestBody? = null): Response + + /** + * Test array of binary in multipart mime + * Test array of binary in multipart mime + * Responses: + * - 200: Successful operation + * + * @param files + * @return [kotlin.String] + */ + @Multipart + @POST("body/application/octetstream/array_of_binary") + suspend fun testBodyMultipartFormdataArrayOfBinary(@Part files: MultipartBody.Part): Response + + /** + * Test single binary in multipart mime + * Test single binary in multipart mime + * Responses: + * - 200: Successful operation + * + * @param myFile (optional) + * @return [kotlin.String] + */ + @Multipart + @POST("body/application/octetstream/single_binary") + suspend fun testBodyMultipartFormdataSingleBinary(@Part myFile: MultipartBody.Part? = null): Response + + /** + * Test free form object + * Test free form object + * Responses: + * - 200: Successful operation + * + * @param body Free form object (optional) + * @return [kotlin.String] + */ + @POST("echo/body/FreeFormObject/response_string") + suspend fun testEchoBodyFreeFormObjectResponseString(@Body body: kotlin.Any? = null): Response + + /** + * Test body parameter(s) + * Test body parameter(s) + * Responses: + * - 200: Successful operation + * + * @param apiPet Pet object that needs to be added to the store (optional) + * @return [ApiPet] + */ + @POST("echo/body/Pet") + suspend fun testEchoBodyPet(@Body apiPet: ApiPet? = null): Response + + /** + * Test empty response body + * Test empty response body + * Responses: + * - 200: Successful operation + * + * @param apiPet Pet object that needs to be added to the store (optional) + * @return [kotlin.String] + */ + @POST("echo/body/Pet/response_string") + suspend fun testEchoBodyPetResponseString(@Body apiPet: ApiPet? = null): Response + + /** + * Test empty json (request body) + * Test empty json (request body) + * Responses: + * - 200: Successful operation + * + * @param apiTag Tag object (optional) + * @return [kotlin.String] + */ + @POST("echo/body/Tag/response_string") + suspend fun testEchoBodyTagResponseString(@Body apiTag: ApiTag? = null): Response + +} diff --git a/samples/client/echo_api/kotlin-model-prefix-type-mappings/src/main/kotlin/org/openapitools/client/apis/FormApi.kt b/samples/client/echo_api/kotlin-model-prefix-type-mappings/src/main/kotlin/org/openapitools/client/apis/FormApi.kt new file mode 100644 index 0000000000..e8a4aad6f2 --- /dev/null +++ b/samples/client/echo_api/kotlin-model-prefix-type-mappings/src/main/kotlin/org/openapitools/client/apis/FormApi.kt @@ -0,0 +1,44 @@ +package org.openapitools.client.apis + +import org.openapitools.client.infrastructure.CollectionFormats.* +import retrofit2.http.* +import retrofit2.Response +import okhttp3.RequestBody +import com.google.gson.annotations.SerializedName + + +interface FormApi { + /** + * Test form parameter(s) + * Test form parameter(s) + * Responses: + * - 200: Successful operation + * + * @param integerForm (optional) + * @param booleanForm (optional) + * @param stringForm (optional) + * @return [kotlin.String] + */ + @FormUrlEncoded + @POST("form/integer/boolean/string") + suspend fun testFormIntegerBooleanString(@Field("integer_form") integerForm: kotlin.Int? = null, @Field("boolean_form") booleanForm: kotlin.Boolean? = null, @Field("string_form") stringForm: kotlin.String? = null): Response + + /** + * Test form parameter(s) for oneOf schema + * Test form parameter(s) for oneOf schema + * Responses: + * - 200: Successful operation + * + * @param form1 (optional) + * @param form2 (optional) + * @param form3 (optional) + * @param form4 (optional) + * @param id (optional) + * @param name (optional) + * @return [kotlin.String] + */ + @FormUrlEncoded + @POST("form/oneof") + suspend fun testFormOneof(@Field("form1") form1: kotlin.String? = null, @Field("form2") form2: kotlin.Int? = null, @Field("form3") form3: kotlin.String? = null, @Field("form4") form4: kotlin.Boolean? = null, @Field("id") id: kotlin.Long? = null, @Field("name") name: kotlin.String? = null): Response + +} diff --git a/samples/client/echo_api/kotlin-model-prefix-type-mappings/src/main/kotlin/org/openapitools/client/apis/HeaderApi.kt b/samples/client/echo_api/kotlin-model-prefix-type-mappings/src/main/kotlin/org/openapitools/client/apis/HeaderApi.kt new file mode 100644 index 0000000000..ae81c98c68 --- /dev/null +++ b/samples/client/echo_api/kotlin-model-prefix-type-mappings/src/main/kotlin/org/openapitools/client/apis/HeaderApi.kt @@ -0,0 +1,38 @@ +package org.openapitools.client.apis + +import org.openapitools.client.infrastructure.CollectionFormats.* +import retrofit2.http.* +import retrofit2.Response +import okhttp3.RequestBody +import com.google.gson.annotations.SerializedName + +import org.openapitools.client.models.ApiStringEnumRef + +interface HeaderApi { + + /** + * enum for parameter enumNonrefStringHeader + */ + enum class EnumNonrefStringHeaderTestHeaderIntegerBooleanStringEnums(val value: kotlin.String) { + @SerializedName(value = "success") SUCCESS("success"), + @SerializedName(value = "failure") FAILURE("failure"), + @SerializedName(value = "unclassified") UNCLASSIFIED("unclassified") + } + + /** + * Test header parameter(s) + * Test header parameter(s) + * Responses: + * - 200: Successful operation + * + * @param integerHeader (optional) + * @param booleanHeader (optional) + * @param stringHeader (optional) + * @param enumNonrefStringHeader (optional) + * @param enumRefStringHeader (optional) + * @return [kotlin.String] + */ + @GET("header/integer/boolean/string/enums") + suspend fun testHeaderIntegerBooleanStringEnums(@Header("integer_header") integerHeader: kotlin.Int? = null, @Header("boolean_header") booleanHeader: kotlin.Boolean? = null, @Header("string_header") stringHeader: kotlin.String? = null, @Header("enum_nonref_string_header") enumNonrefStringHeader: EnumNonrefStringHeaderTestHeaderIntegerBooleanStringEnums? = null, @Header("enum_ref_string_header") enumRefStringHeader: ApiStringEnumRef? = null): Response + +} diff --git a/samples/client/echo_api/kotlin-model-prefix-type-mappings/src/main/kotlin/org/openapitools/client/apis/PathApi.kt b/samples/client/echo_api/kotlin-model-prefix-type-mappings/src/main/kotlin/org/openapitools/client/apis/PathApi.kt new file mode 100644 index 0000000000..2295661404 --- /dev/null +++ b/samples/client/echo_api/kotlin-model-prefix-type-mappings/src/main/kotlin/org/openapitools/client/apis/PathApi.kt @@ -0,0 +1,37 @@ +package org.openapitools.client.apis + +import org.openapitools.client.infrastructure.CollectionFormats.* +import retrofit2.http.* +import retrofit2.Response +import okhttp3.RequestBody +import com.google.gson.annotations.SerializedName + +import org.openapitools.client.models.ApiStringEnumRef + +interface PathApi { + + /** + * enum for parameter enumNonrefStringPath + */ + enum class EnumNonrefStringPathTestsPathStringPathStringIntegerPathIntegerEnumNonrefStringPathEnumRefStringPath(val value: kotlin.String) { + @SerializedName(value = "success") SUCCESS("success"), + @SerializedName(value = "failure") FAILURE("failure"), + @SerializedName(value = "unclassified") UNCLASSIFIED("unclassified") + } + + /** + * Test path parameter(s) + * Test path parameter(s) + * Responses: + * - 200: Successful operation + * + * @param pathString + * @param pathInteger + * @param enumNonrefStringPath + * @param enumRefStringPath + * @return [kotlin.String] + */ + @GET("path/string/{path_string}/integer/{path_integer}/{enum_nonref_string_path}/{enum_ref_string_path}") + suspend fun testsPathStringPathStringIntegerPathIntegerEnumNonrefStringPathEnumRefStringPath(@Path("path_string") pathString: kotlin.String, @Path("path_integer") pathInteger: kotlin.Int, @Path("enum_nonref_string_path") enumNonrefStringPath: kotlin.String, @Path("enum_ref_string_path") enumRefStringPath: ApiStringEnumRef): Response + +} diff --git a/samples/client/echo_api/kotlin-model-prefix-type-mappings/src/main/kotlin/org/openapitools/client/apis/QueryApi.kt b/samples/client/echo_api/kotlin-model-prefix-type-mappings/src/main/kotlin/org/openapitools/client/apis/QueryApi.kt new file mode 100644 index 0000000000..bc1fb16ff0 --- /dev/null +++ b/samples/client/echo_api/kotlin-model-prefix-type-mappings/src/main/kotlin/org/openapitools/client/apis/QueryApi.kt @@ -0,0 +1,108 @@ +package org.openapitools.client.apis + +import org.openapitools.client.infrastructure.CollectionFormats.* +import retrofit2.http.* +import retrofit2.Response +import okhttp3.RequestBody +import com.google.gson.annotations.SerializedName + +import org.openapitools.client.models.ApiPet +import org.openapitools.client.models.ApiStringEnumRef +import org.openapitools.client.models.ApiTestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter + +import org.openapitools.client.models.* + +interface QueryApi { + + /** + * enum for parameter enumNonrefStringQuery + */ + enum class EnumNonrefStringQueryTestEnumRefString(val value: kotlin.String) { + @SerializedName(value = "success") SUCCESS("success"), + @SerializedName(value = "failure") FAILURE("failure"), + @SerializedName(value = "unclassified") UNCLASSIFIED("unclassified") + } + + /** + * Test query parameter(s) + * Test query parameter(s) + * Responses: + * - 200: Successful operation + * + * @param enumNonrefStringQuery (optional) + * @param enumRefStringQuery (optional) + * @return [kotlin.String] + */ + @GET("query/enum_ref_string") + suspend fun testEnumRefString(@Query("enum_nonref_string_query") enumNonrefStringQuery: EnumNonrefStringQueryTestEnumRefString? = null, @Query("enum_ref_string_query") enumRefStringQuery: ApiStringEnumRef? = null): Response + + /** + * Test query parameter(s) + * Test query parameter(s) + * Responses: + * - 200: Successful operation + * + * @param datetimeQuery (optional) + * @param dateQuery (optional) + * @param stringQuery (optional) + * @return [kotlin.String] + */ + @GET("query/datetime/date/string") + suspend fun testQueryDatetimeDateString(@Query("datetime_query") datetimeQuery: java.time.OffsetDateTime? = null, @Query("date_query") dateQuery: java.time.LocalDate? = null, @Query("string_query") stringQuery: kotlin.String? = null): Response + + /** + * Test query parameter(s) + * Test query parameter(s) + * Responses: + * - 200: Successful operation + * + * @param integerQuery (optional) + * @param booleanQuery (optional) + * @param stringQuery (optional) + * @return [kotlin.String] + */ + @GET("query/integer/boolean/string") + suspend fun testQueryIntegerBooleanString(@Query("integer_query") integerQuery: kotlin.Int? = null, @Query("boolean_query") booleanQuery: kotlin.Boolean? = null, @Query("string_query") stringQuery: kotlin.String? = null): Response + + /** + * Test query parameter(s) + * Test query parameter(s) + * Responses: + * - 200: Successful operation + * + * @param queryObject (optional) + * @return [kotlin.String] + */ + @GET("query/style_deepObject/explode_true/object") + suspend fun testQueryStyleDeepObjectExplodeTrueObject(@Query("query_object") queryObject: ApiPet? = null): Response + + /** + * Test query parameter(s) + * Test query parameter(s) + * Responses: + * - 200: Successful operation + * + * @param values (optional) + * @return [kotlin.String] + */ + @GET("query/style_form/explode_true/array_string") + suspend fun testQueryStyleFormExplodeTrueArrayString(@Query("values") values: kotlin.collections.List? = null): Response + + /** + * Test query parameter(s) + * Test query parameter(s) + * Responses: + * - 200: Successful operation + * + * @param id (optional) + * @param name + * @param category (optional) + * @param photoUrls + * @param tags (optional) + * @param status pet status in the store (optional) + * @return [kotlin.String] + */ + @GET("query/style_form/explode_true/object") + suspend fun testQueryStyleFormExplodeTrueObject(@Query("id") id: kotlin.Long? = null, @Query("name") name: kotlin.String, @Query("category") category: ApiCategory? = null, @Query("photoUrls") photoUrls: kotlin.collections.List, @Query("tags") tags: kotlin.collections.List? = null, @Query("status") status: kotlin.String? = null): Response + +} diff --git a/samples/client/echo_api/kotlin-model-prefix-type-mappings/src/main/kotlin/org/openapitools/client/auth/HttpBasicAuth.kt b/samples/client/echo_api/kotlin-model-prefix-type-mappings/src/main/kotlin/org/openapitools/client/auth/HttpBasicAuth.kt new file mode 100644 index 0000000000..575bea1954 --- /dev/null +++ b/samples/client/echo_api/kotlin-model-prefix-type-mappings/src/main/kotlin/org/openapitools/client/auth/HttpBasicAuth.kt @@ -0,0 +1,33 @@ +package org.openapitools.client.auth + +import java.io.IOException + +import kotlin.jvm.Throws +import okhttp3.Interceptor +import okhttp3.Interceptor.Chain +import okhttp3.Response +import okhttp3.Credentials + +class HttpBasicAuth( + private var username: String = "", + private var password: String = "" +) : Interceptor { + + fun setCredentials(username: String, password: String) { + this.username = username + this.password = password + } + + @Throws(IOException::class) + override fun intercept(chain: Chain): Response { + var request = chain.request() + + // If the request already have an authorization (eg. Basic auth), do nothing + if (request.header("Authorization") == null && username.isNotBlank() && password.isNotBlank()) { + request = request.newBuilder() + .addHeader("Authorization", Credentials.basic(username, password)) + .build() + } + return chain.proceed(request) + } +} diff --git a/samples/client/echo_api/kotlin-model-prefix-type-mappings/src/main/kotlin/org/openapitools/client/auth/HttpBearerAuth.kt b/samples/client/echo_api/kotlin-model-prefix-type-mappings/src/main/kotlin/org/openapitools/client/auth/HttpBearerAuth.kt new file mode 100644 index 0000000000..aee6f3a13b --- /dev/null +++ b/samples/client/echo_api/kotlin-model-prefix-type-mappings/src/main/kotlin/org/openapitools/client/auth/HttpBearerAuth.kt @@ -0,0 +1,39 @@ +package org.openapitools.client.auth + +import java.io.IOException + +import okhttp3.Interceptor +import okhttp3.Interceptor.Chain +import okhttp3.Response + +class HttpBearerAuth( + private var schema: String = "", + var bearerToken: String = "" +) : Interceptor { + + @Throws(IOException::class) + override fun intercept(chain: Chain): Response { + var request = chain.request() + + // If the request already have an authorization (eg. Basic auth), do nothing + if (request.header("Authorization") == null && bearerToken.isNotBlank()) { + request = request.newBuilder() + .addHeader("Authorization", headerValue()) + .build() + } + return chain.proceed(request) + } + + private fun headerValue(): String { + return if (schema.isNotBlank()) { + "${upperCaseBearer()} $bearerToken" + } else { + bearerToken + } + } + + private fun upperCaseBearer(): String { + return if (schema.lowercase().equals("bearer")) "Bearer" else schema + } + +} diff --git a/samples/client/echo_api/kotlin-model-prefix-type-mappings/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt b/samples/client/echo_api/kotlin-model-prefix-type-mappings/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt new file mode 100644 index 0000000000..c207277e90 --- /dev/null +++ b/samples/client/echo_api/kotlin-model-prefix-type-mappings/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt @@ -0,0 +1,169 @@ +package org.openapitools.client.infrastructure + +import org.openapitools.client.auth.HttpBasicAuth +import org.openapitools.client.auth.HttpBearerAuth + +import okhttp3.Call +import okhttp3.Interceptor +import okhttp3.OkHttpClient +import retrofit2.Retrofit +import okhttp3.logging.HttpLoggingInterceptor +import retrofit2.Converter +import retrofit2.CallAdapter +import retrofit2.converter.scalars.ScalarsConverterFactory +import com.google.gson.Gson +import com.google.gson.GsonBuilder +import retrofit2.converter.gson.GsonConverterFactory + + +class ApiClient( + private var baseUrl: String = defaultBasePath, + private val okHttpClientBuilder: OkHttpClient.Builder? = null, + private val serializerBuilder: GsonBuilder = Serializer.gsonBuilder, + private val callFactory : Call.Factory? = null, + private val callAdapterFactories: List = listOf( + ), + private val converterFactories: List = listOf( + ScalarsConverterFactory.create(), + GsonConverterFactory.create(serializerBuilder.create()), + ) +) { + private val apiAuthorizations = mutableMapOf() + var logger: ((String) -> Unit)? = null + + private val retrofitBuilder: Retrofit.Builder by lazy { + Retrofit.Builder() + .baseUrl(baseUrl) + .apply { + callAdapterFactories.forEach { + addCallAdapterFactory(it) + } + } + .apply { + converterFactories.forEach { + addConverterFactory(it) + } + } + } + + private val clientBuilder: OkHttpClient.Builder by lazy { + okHttpClientBuilder ?: defaultClientBuilder + } + + private val defaultClientBuilder: OkHttpClient.Builder by lazy { + OkHttpClient() + .newBuilder() + .addInterceptor(HttpLoggingInterceptor { message -> logger?.invoke(message) } + .apply { level = HttpLoggingInterceptor.Level.BODY } + ) + } + + init { + normalizeBaseUrl() + } + + constructor( + baseUrl: String = defaultBasePath, + okHttpClientBuilder: OkHttpClient.Builder? = null, + serializerBuilder: GsonBuilder = Serializer.gsonBuilder, + authNames: Array + ) : this(baseUrl, okHttpClientBuilder, serializerBuilder) { + authNames.forEach { authName -> + val auth: Interceptor? = when (authName) { + "http_auth" -> HttpBasicAuth() + + "http_bearer_auth" -> HttpBearerAuth("bearer") + + else -> throw RuntimeException("auth name $authName not found in available auth names") + } + if (auth != null) { + addAuthorization(authName, auth) + } + } + } + + constructor( + baseUrl: String = defaultBasePath, + okHttpClientBuilder: OkHttpClient.Builder? = null, + serializerBuilder: GsonBuilder = Serializer.gsonBuilder, + authName: String, + username: String, + password: String + ) : this(baseUrl, okHttpClientBuilder, serializerBuilder, arrayOf(authName)) { + setCredentials(username, password) + } + + constructor( + baseUrl: String = defaultBasePath, + okHttpClientBuilder: OkHttpClient.Builder? = null, + serializerBuilder: GsonBuilder = Serializer.gsonBuilder, + authName: String, + bearerToken: String + ) : this(baseUrl, okHttpClientBuilder, serializerBuilder, arrayOf(authName)) { + setBearerToken(bearerToken) + } + + fun setCredentials(username: String, password: String): ApiClient { + apiAuthorizations.values.runOnFirst { + setCredentials(username, password) + } + return this + } + + fun setBearerToken(bearerToken: String): ApiClient { + apiAuthorizations.values.runOnFirst { + this.bearerToken = bearerToken + } + return this + } + + /** + * Adds an authorization to be used by the client + * @param authName Authentication name + * @param authorization Authorization interceptor + * @return ApiClient + */ + fun addAuthorization(authName: String, authorization: Interceptor): ApiClient { + if (apiAuthorizations.containsKey(authName)) { + throw RuntimeException("auth name $authName already in api authorizations") + } + apiAuthorizations[authName] = authorization + clientBuilder.addInterceptor(authorization) + return this + } + + fun setLogger(logger: (String) -> Unit): ApiClient { + this.logger = logger + return this + } + + fun createService(serviceClass: Class): S { + val usedCallFactory = this.callFactory ?: clientBuilder.build() + return retrofitBuilder.callFactory(usedCallFactory).build().create(serviceClass) + } + + private fun normalizeBaseUrl() { + if (!baseUrl.endsWith("/")) { + baseUrl += "/" + } + } + + private inline fun Iterable.runOnFirst(callback: U.() -> Unit) { + for (element in this) { + if (element is U) { + callback.invoke(element) + break + } + } + } + + companion object { + @JvmStatic + protected val baseUrlKey = "org.openapitools.client.baseUrl" + + @JvmStatic + val defaultBasePath: String by lazy { + System.getProperties().getProperty(baseUrlKey, "http://localhost:3000") + } + } +} diff --git a/samples/client/echo_api/kotlin-model-prefix-type-mappings/src/main/kotlin/org/openapitools/client/infrastructure/ByteArrayAdapter.kt b/samples/client/echo_api/kotlin-model-prefix-type-mappings/src/main/kotlin/org/openapitools/client/infrastructure/ByteArrayAdapter.kt new file mode 100644 index 0000000000..6120b08192 --- /dev/null +++ b/samples/client/echo_api/kotlin-model-prefix-type-mappings/src/main/kotlin/org/openapitools/client/infrastructure/ByteArrayAdapter.kt @@ -0,0 +1,33 @@ +package org.openapitools.client.infrastructure + +import com.google.gson.TypeAdapter +import com.google.gson.stream.JsonReader +import com.google.gson.stream.JsonWriter +import com.google.gson.stream.JsonToken.NULL +import java.io.IOException + +class ByteArrayAdapter : TypeAdapter() { + @Throws(IOException::class) + override fun write(out: JsonWriter?, value: ByteArray?) { + if (value == null) { + out?.nullValue() + } else { + out?.value(String(value)) + } + } + + @Throws(IOException::class) + override fun read(out: JsonReader?): ByteArray? { + out ?: return null + + when (out.peek()) { + NULL -> { + out.nextNull() + return null + } + else -> { + return out.nextString().toByteArray() + } + } + } +} diff --git a/samples/client/echo_api/kotlin-model-prefix-type-mappings/src/main/kotlin/org/openapitools/client/infrastructure/CollectionFormats.kt b/samples/client/echo_api/kotlin-model-prefix-type-mappings/src/main/kotlin/org/openapitools/client/infrastructure/CollectionFormats.kt new file mode 100644 index 0000000000..7f404da69e --- /dev/null +++ b/samples/client/echo_api/kotlin-model-prefix-type-mappings/src/main/kotlin/org/openapitools/client/infrastructure/CollectionFormats.kt @@ -0,0 +1,56 @@ +package org.openapitools.client.infrastructure + +class CollectionFormats { + + open class CSVParams { + + var params: List + + constructor(params: List) { + this.params = params + } + + constructor(vararg params: String) { + this.params = listOf(*params) + } + + override fun toString(): String { + return params.joinToString(",") + } + } + + open class SSVParams : CSVParams { + + constructor(params: List) : super(params) + + constructor(vararg params: String) : super(*params) + + override fun toString(): String { + return params.joinToString(" ") + } + } + + class TSVParams : CSVParams { + + constructor(params: List) : super(params) + + constructor(vararg params: String) : super(*params) + + override fun toString(): String { + return params.joinToString("\t") + } + } + + class PIPESParams : CSVParams { + + constructor(params: List) : super(params) + + constructor(vararg params: String) : super(*params) + + override fun toString(): String { + return params.joinToString("|") + } + } + + class SPACEParams : SSVParams() +} diff --git a/samples/client/echo_api/kotlin-model-prefix-type-mappings/src/main/kotlin/org/openapitools/client/infrastructure/LocalDateAdapter.kt b/samples/client/echo_api/kotlin-model-prefix-type-mappings/src/main/kotlin/org/openapitools/client/infrastructure/LocalDateAdapter.kt new file mode 100644 index 0000000000..30ef669718 --- /dev/null +++ b/samples/client/echo_api/kotlin-model-prefix-type-mappings/src/main/kotlin/org/openapitools/client/infrastructure/LocalDateAdapter.kt @@ -0,0 +1,35 @@ +package org.openapitools.client.infrastructure + +import com.google.gson.TypeAdapter +import com.google.gson.stream.JsonReader +import com.google.gson.stream.JsonWriter +import com.google.gson.stream.JsonToken.NULL +import java.io.IOException +import java.time.LocalDate +import java.time.format.DateTimeFormatter + +class LocalDateAdapter(private val formatter: DateTimeFormatter = DateTimeFormatter.ISO_LOCAL_DATE) : TypeAdapter() { + @Throws(IOException::class) + override fun write(out: JsonWriter?, value: LocalDate?) { + if (value == null) { + out?.nullValue() + } else { + out?.value(formatter.format(value)) + } + } + + @Throws(IOException::class) + override fun read(out: JsonReader?): LocalDate? { + out ?: return null + + when (out.peek()) { + NULL -> { + out.nextNull() + return null + } + else -> { + return LocalDate.parse(out.nextString(), formatter) + } + } + } +} diff --git a/samples/client/echo_api/kotlin-model-prefix-type-mappings/src/main/kotlin/org/openapitools/client/infrastructure/LocalDateTimeAdapter.kt b/samples/client/echo_api/kotlin-model-prefix-type-mappings/src/main/kotlin/org/openapitools/client/infrastructure/LocalDateTimeAdapter.kt new file mode 100644 index 0000000000..3ad781c66c --- /dev/null +++ b/samples/client/echo_api/kotlin-model-prefix-type-mappings/src/main/kotlin/org/openapitools/client/infrastructure/LocalDateTimeAdapter.kt @@ -0,0 +1,35 @@ +package org.openapitools.client.infrastructure + +import com.google.gson.TypeAdapter +import com.google.gson.stream.JsonReader +import com.google.gson.stream.JsonWriter +import com.google.gson.stream.JsonToken.NULL +import java.io.IOException +import java.time.LocalDateTime +import java.time.format.DateTimeFormatter + +class LocalDateTimeAdapter(private val formatter: DateTimeFormatter = DateTimeFormatter.ISO_LOCAL_DATE_TIME) : TypeAdapter() { + @Throws(IOException::class) + override fun write(out: JsonWriter?, value: LocalDateTime?) { + if (value == null) { + out?.nullValue() + } else { + out?.value(formatter.format(value)) + } + } + + @Throws(IOException::class) + override fun read(out: JsonReader?): LocalDateTime? { + out ?: return null + + when (out.peek()) { + NULL -> { + out.nextNull() + return null + } + else -> { + return LocalDateTime.parse(out.nextString(), formatter) + } + } + } +} diff --git a/samples/client/echo_api/kotlin-model-prefix-type-mappings/src/main/kotlin/org/openapitools/client/infrastructure/OffsetDateTimeAdapter.kt b/samples/client/echo_api/kotlin-model-prefix-type-mappings/src/main/kotlin/org/openapitools/client/infrastructure/OffsetDateTimeAdapter.kt new file mode 100644 index 0000000000..e615135c9c --- /dev/null +++ b/samples/client/echo_api/kotlin-model-prefix-type-mappings/src/main/kotlin/org/openapitools/client/infrastructure/OffsetDateTimeAdapter.kt @@ -0,0 +1,35 @@ +package org.openapitools.client.infrastructure + +import com.google.gson.TypeAdapter +import com.google.gson.stream.JsonReader +import com.google.gson.stream.JsonWriter +import com.google.gson.stream.JsonToken.NULL +import java.io.IOException +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter + +class OffsetDateTimeAdapter(private val formatter: DateTimeFormatter = DateTimeFormatter.ISO_OFFSET_DATE_TIME) : TypeAdapter() { + @Throws(IOException::class) + override fun write(out: JsonWriter?, value: OffsetDateTime?) { + if (value == null) { + out?.nullValue() + } else { + out?.value(formatter.format(value)) + } + } + + @Throws(IOException::class) + override fun read(out: JsonReader?): OffsetDateTime? { + out ?: return null + + when (out.peek()) { + NULL -> { + out.nextNull() + return null + } + else -> { + return OffsetDateTime.parse(out.nextString(), formatter) + } + } + } +} diff --git a/samples/client/echo_api/kotlin-model-prefix-type-mappings/src/main/kotlin/org/openapitools/client/infrastructure/ResponseExt.kt b/samples/client/echo_api/kotlin-model-prefix-type-mappings/src/main/kotlin/org/openapitools/client/infrastructure/ResponseExt.kt new file mode 100644 index 0000000000..f9dfac6bed --- /dev/null +++ b/samples/client/echo_api/kotlin-model-prefix-type-mappings/src/main/kotlin/org/openapitools/client/infrastructure/ResponseExt.kt @@ -0,0 +1,15 @@ +package org.openapitools.client.infrastructure + +import com.google.gson.GsonBuilder +import com.google.gson.JsonParseException +import retrofit2.Response + +@Throws(JsonParseException::class) +inline fun Response<*>.getErrorResponse(serializerBuilder: GsonBuilder = Serializer.gsonBuilder): T? { + val serializer = serializerBuilder.create() + val reader = errorBody()?.charStream() + if (reader != null) { + return serializer.fromJson(reader, T::class.java) + } + return null +} diff --git a/samples/client/echo_api/kotlin-model-prefix-type-mappings/src/main/kotlin/org/openapitools/client/infrastructure/Serializer.kt b/samples/client/echo_api/kotlin-model-prefix-type-mappings/src/main/kotlin/org/openapitools/client/infrastructure/Serializer.kt new file mode 100644 index 0000000000..6e16e4f658 --- /dev/null +++ b/samples/client/echo_api/kotlin-model-prefix-type-mappings/src/main/kotlin/org/openapitools/client/infrastructure/Serializer.kt @@ -0,0 +1,22 @@ +package org.openapitools.client.infrastructure + +import com.google.gson.Gson +import com.google.gson.GsonBuilder +import java.time.LocalDate +import java.time.LocalDateTime +import java.time.OffsetDateTime +import java.util.UUID + +object Serializer { + @JvmStatic + val gsonBuilder: GsonBuilder = GsonBuilder() + .registerTypeAdapter(OffsetDateTime::class.java, OffsetDateTimeAdapter()) + .registerTypeAdapter(LocalDateTime::class.java, LocalDateTimeAdapter()) + .registerTypeAdapter(LocalDate::class.java, LocalDateAdapter()) + .registerTypeAdapter(ByteArray::class.java, ByteArrayAdapter()) + + @JvmStatic + val gson: Gson by lazy { + gsonBuilder.create() + } +} diff --git a/samples/client/echo_api/kotlin-model-prefix-type-mappings/src/main/kotlin/org/openapitools/client/models/ApiBird.kt b/samples/client/echo_api/kotlin-model-prefix-type-mappings/src/main/kotlin/org/openapitools/client/models/ApiBird.kt new file mode 100644 index 0000000000..12de10f20a --- /dev/null +++ b/samples/client/echo_api/kotlin-model-prefix-type-mappings/src/main/kotlin/org/openapitools/client/models/ApiBird.kt @@ -0,0 +1,38 @@ +/** + * + * Please note: + * This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * Do not edit this file manually. + * + */ + +@file:Suppress( + "ArrayInDataClass", + "EnumEntryName", + "RemoveRedundantQualifierName", + "UnusedImport" +) + +package org.openapitools.client.models + + +import com.google.gson.annotations.SerializedName + +/** + * + * + * @param propertySize + * @param color + */ + + +data class ApiBird ( + + @SerializedName("size") + val propertySize: kotlin.String? = null, + + @SerializedName("color") + val color: kotlin.String? = null + +) + diff --git a/samples/client/echo_api/kotlin-model-prefix-type-mappings/src/main/kotlin/org/openapitools/client/models/ApiCategory.kt b/samples/client/echo_api/kotlin-model-prefix-type-mappings/src/main/kotlin/org/openapitools/client/models/ApiCategory.kt new file mode 100644 index 0000000000..509a736a1c --- /dev/null +++ b/samples/client/echo_api/kotlin-model-prefix-type-mappings/src/main/kotlin/org/openapitools/client/models/ApiCategory.kt @@ -0,0 +1,38 @@ +/** + * + * Please note: + * This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * Do not edit this file manually. + * + */ + +@file:Suppress( + "ArrayInDataClass", + "EnumEntryName", + "RemoveRedundantQualifierName", + "UnusedImport" +) + +package org.openapitools.client.models + + +import com.google.gson.annotations.SerializedName + +/** + * + * + * @param id + * @param name + */ + + +data class ApiCategory ( + + @SerializedName("id") + val id: kotlin.Long? = null, + + @SerializedName("name") + val name: kotlin.String? = null + +) + diff --git a/samples/client/echo_api/kotlin-model-prefix-type-mappings/src/main/kotlin/org/openapitools/client/models/ApiDefaultValue.kt b/samples/client/echo_api/kotlin-model-prefix-type-mappings/src/main/kotlin/org/openapitools/client/models/ApiDefaultValue.kt new file mode 100644 index 0000000000..55d1338383 --- /dev/null +++ b/samples/client/echo_api/kotlin-model-prefix-type-mappings/src/main/kotlin/org/openapitools/client/models/ApiDefaultValue.kt @@ -0,0 +1,75 @@ +/** + * + * Please note: + * This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * Do not edit this file manually. + * + */ + +@file:Suppress( + "ArrayInDataClass", + "EnumEntryName", + "RemoveRedundantQualifierName", + "UnusedImport" +) + +package org.openapitools.client.models + +import org.openapitools.client.models.ApiStringEnumRef + +import com.google.gson.annotations.SerializedName + +/** + * to test the default value of properties + * + * @param arrayStringEnumRefDefault + * @param arrayStringEnumDefault + * @param arrayStringDefault + * @param arrayIntegerDefault + * @param arrayString + * @param arrayStringNullable + * @param arrayStringExtensionNullable + * @param stringNullable + */ + + +data class ApiDefaultValue ( + + @SerializedName("array_string_enum_ref_default") + val arrayStringEnumRefDefault: kotlin.collections.List? = null, + + @SerializedName("array_string_enum_default") + val arrayStringEnumDefault: kotlin.collections.List? = null, + + @SerializedName("array_string_default") + val arrayStringDefault: kotlin.collections.List? = arrayListOf("failure","skipped"), + + @SerializedName("array_integer_default") + val arrayIntegerDefault: kotlin.collections.List? = arrayListOf(1,3), + + @SerializedName("array_string") + val arrayString: kotlin.collections.List? = null, + + @SerializedName("array_string_nullable") + val arrayStringNullable: kotlin.collections.List? = null, + + @SerializedName("array_string_extension_nullable") + val arrayStringExtensionNullable: kotlin.collections.List? = null, + + @SerializedName("string_nullable") + val stringNullable: kotlin.String? = null + +) { + + /** + * + * + * Values: SUCCESS,FAILURE,UNCLASSIFIED + */ + enum class ArrayStringEnumDefault(val value: kotlin.String) { + @SerializedName(value = "success") SUCCESS("success"), + @SerializedName(value = "failure") FAILURE("failure"), + @SerializedName(value = "unclassified") UNCLASSIFIED("unclassified"); + } +} + diff --git a/samples/client/echo_api/kotlin-model-prefix-type-mappings/src/main/kotlin/org/openapitools/client/models/ApiNumberPropertiesOnly.kt b/samples/client/echo_api/kotlin-model-prefix-type-mappings/src/main/kotlin/org/openapitools/client/models/ApiNumberPropertiesOnly.kt new file mode 100644 index 0000000000..3f411d197c --- /dev/null +++ b/samples/client/echo_api/kotlin-model-prefix-type-mappings/src/main/kotlin/org/openapitools/client/models/ApiNumberPropertiesOnly.kt @@ -0,0 +1,42 @@ +/** + * + * Please note: + * This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * Do not edit this file manually. + * + */ + +@file:Suppress( + "ArrayInDataClass", + "EnumEntryName", + "RemoveRedundantQualifierName", + "UnusedImport" +) + +package org.openapitools.client.models + + +import com.google.gson.annotations.SerializedName + +/** + * + * + * @param number + * @param float + * @param double + */ + + +data class ApiNumberPropertiesOnly ( + + @SerializedName("number") + val number: java.math.BigDecimal? = null, + + @SerializedName("float") + val float: kotlin.Float? = null, + + @SerializedName("double") + val double: kotlin.Double? = null + +) + diff --git a/samples/client/echo_api/kotlin-model-prefix-type-mappings/src/main/kotlin/org/openapitools/client/models/ApiPet.kt b/samples/client/echo_api/kotlin-model-prefix-type-mappings/src/main/kotlin/org/openapitools/client/models/ApiPet.kt new file mode 100644 index 0000000000..ac4940b5c7 --- /dev/null +++ b/samples/client/echo_api/kotlin-model-prefix-type-mappings/src/main/kotlin/org/openapitools/client/models/ApiPet.kt @@ -0,0 +1,69 @@ +/** + * + * Please note: + * This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * Do not edit this file manually. + * + */ + +@file:Suppress( + "ArrayInDataClass", + "EnumEntryName", + "RemoveRedundantQualifierName", + "UnusedImport" +) + +package org.openapitools.client.models + +import org.openapitools.client.models.ApiCategory +import org.openapitools.client.models.ApiTag + +import com.google.gson.annotations.SerializedName + +/** + * + * + * @param name + * @param photoUrls + * @param id + * @param category + * @param tags + * @param status pet status in the store + */ + + +data class ApiPet ( + + @SerializedName("name") + val name: kotlin.String, + + @SerializedName("photoUrls") + val photoUrls: kotlin.collections.List, + + @SerializedName("id") + val id: kotlin.Long? = null, + + @SerializedName("category") + val category: ApiCategory? = null, + + @SerializedName("tags") + val tags: kotlin.collections.List? = null, + + /* pet status in the store */ + @SerializedName("status") + val status: ApiPet.Status? = null + +) { + + /** + * pet status in the store + * + * Values: AVAILABLE,PENDING,SOLD + */ + enum class Status(val value: kotlin.String) { + @SerializedName(value = "available") AVAILABLE("available"), + @SerializedName(value = "pending") PENDING("pending"), + @SerializedName(value = "sold") SOLD("sold"); + } +} + diff --git a/samples/client/echo_api/kotlin-model-prefix-type-mappings/src/main/kotlin/org/openapitools/client/models/ApiQuery.kt b/samples/client/echo_api/kotlin-model-prefix-type-mappings/src/main/kotlin/org/openapitools/client/models/ApiQuery.kt new file mode 100644 index 0000000000..545b6556ee --- /dev/null +++ b/samples/client/echo_api/kotlin-model-prefix-type-mappings/src/main/kotlin/org/openapitools/client/models/ApiQuery.kt @@ -0,0 +1,51 @@ +/** + * + * Please note: + * This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * Do not edit this file manually. + * + */ + +@file:Suppress( + "ArrayInDataClass", + "EnumEntryName", + "RemoveRedundantQualifierName", + "UnusedImport" +) + +package org.openapitools.client.models + + +import com.google.gson.annotations.SerializedName + +/** + * + * + * @param id Query + * @param outcomes + */ + + +data class ApiQuery ( + + /* Query */ + @SerializedName("id") + val id: kotlin.Long? = null, + + @SerializedName("outcomes") + val outcomes: kotlin.collections.List? = null + +) { + + /** + * + * + * Values: SUCCESS,FAILURE,SKIPPED + */ + enum class Outcomes(val value: kotlin.String) { + @SerializedName(value = "SUCCESS") SUCCESS("SUCCESS"), + @SerializedName(value = "FAILURE") FAILURE("FAILURE"), + @SerializedName(value = "SKIPPED") SKIPPED("SKIPPED"); + } +} + diff --git a/samples/client/echo_api/kotlin-model-prefix-type-mappings/src/main/kotlin/org/openapitools/client/models/ApiStringEnumRef.kt b/samples/client/echo_api/kotlin-model-prefix-type-mappings/src/main/kotlin/org/openapitools/client/models/ApiStringEnumRef.kt new file mode 100644 index 0000000000..d9971985a7 --- /dev/null +++ b/samples/client/echo_api/kotlin-model-prefix-type-mappings/src/main/kotlin/org/openapitools/client/models/ApiStringEnumRef.kt @@ -0,0 +1,64 @@ +/** + * + * Please note: + * This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * Do not edit this file manually. + * + */ + +@file:Suppress( + "ArrayInDataClass", + "EnumEntryName", + "RemoveRedundantQualifierName", + "UnusedImport" +) + +package org.openapitools.client.models + + +import com.google.gson.annotations.SerializedName + +/** + * + * + * Values: SUCCESS,FAILURE,UNCLASSIFIED + */ + +enum class ApiStringEnumRef(val value: kotlin.String) { + + @SerializedName(value = "success") + SUCCESS("success"), + + @SerializedName(value = "failure") + FAILURE("failure"), + + @SerializedName(value = "unclassified") + UNCLASSIFIED("unclassified"); + + /** + * Override [toString()] to avoid using the enum variable name as the value, and instead use + * the actual value defined in the API spec file. + * + * This solves a problem when the variable name and its value are different, and ensures that + * the client sends the correct enum values to the server always. + */ + override fun toString(): kotlin.String = value + + companion object { + /** + * Converts the provided [data] to a [String] on success, null otherwise. + */ + fun encode(data: kotlin.Any?): kotlin.String? = if (data is ApiStringEnumRef) "$data" else null + + /** + * Returns a valid [ApiStringEnumRef] for [data], null otherwise. + */ + fun decode(data: kotlin.Any?): ApiStringEnumRef? = data?.let { + val normalizedData = "$it".lowercase() + values().firstOrNull { value -> + it == value || normalizedData == "$value".lowercase() + } + } + } +} + diff --git a/samples/client/echo_api/kotlin-model-prefix-type-mappings/src/main/kotlin/org/openapitools/client/models/ApiTag.kt b/samples/client/echo_api/kotlin-model-prefix-type-mappings/src/main/kotlin/org/openapitools/client/models/ApiTag.kt new file mode 100644 index 0000000000..b3a3a685a2 --- /dev/null +++ b/samples/client/echo_api/kotlin-model-prefix-type-mappings/src/main/kotlin/org/openapitools/client/models/ApiTag.kt @@ -0,0 +1,38 @@ +/** + * + * Please note: + * This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * Do not edit this file manually. + * + */ + +@file:Suppress( + "ArrayInDataClass", + "EnumEntryName", + "RemoveRedundantQualifierName", + "UnusedImport" +) + +package org.openapitools.client.models + + +import com.google.gson.annotations.SerializedName + +/** + * + * + * @param id + * @param name + */ + + +data class ApiTag ( + + @SerializedName("id") + val id: kotlin.Long? = null, + + @SerializedName("name") + val name: kotlin.String? = null + +) + diff --git a/samples/client/echo_api/kotlin-model-prefix-type-mappings/src/main/kotlin/org/openapitools/client/models/ApiTestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter.kt b/samples/client/echo_api/kotlin-model-prefix-type-mappings/src/main/kotlin/org/openapitools/client/models/ApiTestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter.kt new file mode 100644 index 0000000000..7c98444fb0 --- /dev/null +++ b/samples/client/echo_api/kotlin-model-prefix-type-mappings/src/main/kotlin/org/openapitools/client/models/ApiTestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter.kt @@ -0,0 +1,34 @@ +/** + * + * Please note: + * This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * Do not edit this file manually. + * + */ + +@file:Suppress( + "ArrayInDataClass", + "EnumEntryName", + "RemoveRedundantQualifierName", + "UnusedImport" +) + +package org.openapitools.client.models + + +import com.google.gson.annotations.SerializedName + +/** + * + * + * @param propertyValues + */ + + +data class ApiTestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter ( + + @SerializedName("values") + val propertyValues: kotlin.collections.List? = null + +) + diff --git a/samples/client/echo_api/kotlin-model-prefix-type-mappings/src/test/kotlin/org/openapitools/client/apis/AuthApiTest.kt b/samples/client/echo_api/kotlin-model-prefix-type-mappings/src/test/kotlin/org/openapitools/client/apis/AuthApiTest.kt new file mode 100644 index 0000000000..8e270b251e --- /dev/null +++ b/samples/client/echo_api/kotlin-model-prefix-type-mappings/src/test/kotlin/org/openapitools/client/apis/AuthApiTest.kt @@ -0,0 +1,43 @@ +/** + * + * Please note: + * This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * Do not edit this file manually. + * + */ + +@file:Suppress( + "ArrayInDataClass", + "EnumEntryName", + "RemoveRedundantQualifierName", + "UnusedImport" +) + +package org.openapitools.client.apis + +import io.kotlintest.shouldBe +import io.kotlintest.specs.ShouldSpec + +import org.openapitools.client.apis.AuthApi + +class AuthApiTest : ShouldSpec() { + init { + // uncomment below to create an instance of AuthApi + //val apiInstance = AuthApi() + + // to test testAuthHttpBasic + should("test testAuthHttpBasic") { + // uncomment below to test testAuthHttpBasic + //val result : kotlin.String = apiInstance.testAuthHttpBasic() + //result shouldBe ("TODO") + } + + // to test testAuthHttpBearer + should("test testAuthHttpBearer") { + // uncomment below to test testAuthHttpBearer + //val result : kotlin.String = apiInstance.testAuthHttpBearer() + //result shouldBe ("TODO") + } + + } +} diff --git a/samples/client/echo_api/kotlin-model-prefix-type-mappings/src/test/kotlin/org/openapitools/client/apis/BodyApiTest.kt b/samples/client/echo_api/kotlin-model-prefix-type-mappings/src/test/kotlin/org/openapitools/client/apis/BodyApiTest.kt new file mode 100644 index 0000000000..3467bcf297 --- /dev/null +++ b/samples/client/echo_api/kotlin-model-prefix-type-mappings/src/test/kotlin/org/openapitools/client/apis/BodyApiTest.kt @@ -0,0 +1,94 @@ +/** + * + * Please note: + * This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * Do not edit this file manually. + * + */ + +@file:Suppress( + "ArrayInDataClass", + "EnumEntryName", + "RemoveRedundantQualifierName", + "UnusedImport" +) + +package org.openapitools.client.apis + +import io.kotlintest.shouldBe +import io.kotlintest.specs.ShouldSpec + +import org.openapitools.client.apis.BodyApi +import org.openapitools.client.models.ApiPet +import org.openapitools.client.models.ApiTag + +class BodyApiTest : ShouldSpec() { + init { + // uncomment below to create an instance of BodyApi + //val apiInstance = BodyApi() + + // to test testBinaryGif + should("test testBinaryGif") { + // uncomment below to test testBinaryGif + //val result : RequestBody = apiInstance.testBinaryGif() + //result shouldBe ("TODO") + } + + // to test testBodyApplicationOctetstreamBinary + should("test testBodyApplicationOctetstreamBinary") { + // uncomment below to test testBodyApplicationOctetstreamBinary + //val body : RequestBody = BINARY_DATA_HERE // RequestBody | + //val result : kotlin.String = apiInstance.testBodyApplicationOctetstreamBinary(body) + //result shouldBe ("TODO") + } + + // to test testBodyMultipartFormdataArrayOfBinary + should("test testBodyMultipartFormdataArrayOfBinary") { + // uncomment below to test testBodyMultipartFormdataArrayOfBinary + //val files : kotlin.collections.List = /path/to/file.txt // kotlin.collections.List | + //val result : kotlin.String = apiInstance.testBodyMultipartFormdataArrayOfBinary(files) + //result shouldBe ("TODO") + } + + // to test testBodyMultipartFormdataSingleBinary + should("test testBodyMultipartFormdataSingleBinary") { + // uncomment below to test testBodyMultipartFormdataSingleBinary + //val myFile : RequestBody = BINARY_DATA_HERE // RequestBody | + //val result : kotlin.String = apiInstance.testBodyMultipartFormdataSingleBinary(myFile) + //result shouldBe ("TODO") + } + + // to test testEchoBodyFreeFormObjectResponseString + should("test testEchoBodyFreeFormObjectResponseString") { + // uncomment below to test testEchoBodyFreeFormObjectResponseString + //val body : kotlin.Any = Object // kotlin.Any | Free form object + //val result : kotlin.String = apiInstance.testEchoBodyFreeFormObjectResponseString(body) + //result shouldBe ("TODO") + } + + // to test testEchoBodyPet + should("test testEchoBodyPet") { + // uncomment below to test testEchoBodyPet + //val apiPet : ApiPet = // ApiPet | Pet object that needs to be added to the store + //val result : ApiPet = apiInstance.testEchoBodyPet(apiPet) + //result shouldBe ("TODO") + } + + // to test testEchoBodyPetResponseString + should("test testEchoBodyPetResponseString") { + // uncomment below to test testEchoBodyPetResponseString + //val apiPet : ApiPet = // ApiPet | Pet object that needs to be added to the store + //val result : kotlin.String = apiInstance.testEchoBodyPetResponseString(apiPet) + //result shouldBe ("TODO") + } + + // to test testEchoBodyTagResponseString + should("test testEchoBodyTagResponseString") { + // uncomment below to test testEchoBodyTagResponseString + //val apiTag : ApiTag = // ApiTag | Tag object + //val result : kotlin.String = apiInstance.testEchoBodyTagResponseString(apiTag) + //result shouldBe ("TODO") + } + + } +} diff --git a/samples/client/echo_api/kotlin-model-prefix-type-mappings/src/test/kotlin/org/openapitools/client/apis/FormApiTest.kt b/samples/client/echo_api/kotlin-model-prefix-type-mappings/src/test/kotlin/org/openapitools/client/apis/FormApiTest.kt new file mode 100644 index 0000000000..f2ff643d26 --- /dev/null +++ b/samples/client/echo_api/kotlin-model-prefix-type-mappings/src/test/kotlin/org/openapitools/client/apis/FormApiTest.kt @@ -0,0 +1,52 @@ +/** + * + * Please note: + * This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * Do not edit this file manually. + * + */ + +@file:Suppress( + "ArrayInDataClass", + "EnumEntryName", + "RemoveRedundantQualifierName", + "UnusedImport" +) + +package org.openapitools.client.apis + +import io.kotlintest.shouldBe +import io.kotlintest.specs.ShouldSpec + +import org.openapitools.client.apis.FormApi + +class FormApiTest : ShouldSpec() { + init { + // uncomment below to create an instance of FormApi + //val apiInstance = FormApi() + + // to test testFormIntegerBooleanString + should("test testFormIntegerBooleanString") { + // uncomment below to test testFormIntegerBooleanString + //val integerForm : kotlin.Int = 56 // kotlin.Int | + //val booleanForm : kotlin.Boolean = true // kotlin.Boolean | + //val stringForm : kotlin.String = stringForm_example // kotlin.String | + //val result : kotlin.String = apiInstance.testFormIntegerBooleanString(integerForm, booleanForm, stringForm) + //result shouldBe ("TODO") + } + + // to test testFormOneof + should("test testFormOneof") { + // uncomment below to test testFormOneof + //val form1 : kotlin.String = form1_example // kotlin.String | + //val form2 : kotlin.Int = 56 // kotlin.Int | + //val form3 : kotlin.String = form3_example // kotlin.String | + //val form4 : kotlin.Boolean = true // kotlin.Boolean | + //val id : kotlin.Long = 789 // kotlin.Long | + //val name : kotlin.String = name_example // kotlin.String | + //val result : kotlin.String = apiInstance.testFormOneof(form1, form2, form3, form4, id, name) + //result shouldBe ("TODO") + } + + } +} diff --git a/samples/client/echo_api/kotlin-model-prefix-type-mappings/src/test/kotlin/org/openapitools/client/apis/HeaderApiTest.kt b/samples/client/echo_api/kotlin-model-prefix-type-mappings/src/test/kotlin/org/openapitools/client/apis/HeaderApiTest.kt new file mode 100644 index 0000000000..ddae76adb1 --- /dev/null +++ b/samples/client/echo_api/kotlin-model-prefix-type-mappings/src/test/kotlin/org/openapitools/client/apis/HeaderApiTest.kt @@ -0,0 +1,42 @@ +/** + * + * Please note: + * This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * Do not edit this file manually. + * + */ + +@file:Suppress( + "ArrayInDataClass", + "EnumEntryName", + "RemoveRedundantQualifierName", + "UnusedImport" +) + +package org.openapitools.client.apis + +import io.kotlintest.shouldBe +import io.kotlintest.specs.ShouldSpec + +import org.openapitools.client.apis.HeaderApi +import org.openapitools.client.models.ApiStringEnumRef + +class HeaderApiTest : ShouldSpec() { + init { + // uncomment below to create an instance of HeaderApi + //val apiInstance = HeaderApi() + + // to test testHeaderIntegerBooleanStringEnums + should("test testHeaderIntegerBooleanStringEnums") { + // uncomment below to test testHeaderIntegerBooleanStringEnums + //val integerHeader : kotlin.Int = 56 // kotlin.Int | + //val booleanHeader : kotlin.Boolean = true // kotlin.Boolean | + //val stringHeader : kotlin.String = stringHeader_example // kotlin.String | + //val enumNonrefStringHeader : kotlin.String = enumNonrefStringHeader_example // kotlin.String | + //val enumRefStringHeader : ApiStringEnumRef = // ApiStringEnumRef | + //val result : kotlin.String = apiInstance.testHeaderIntegerBooleanStringEnums(integerHeader, booleanHeader, stringHeader, enumNonrefStringHeader, enumRefStringHeader) + //result shouldBe ("TODO") + } + + } +} diff --git a/samples/client/echo_api/kotlin-model-prefix-type-mappings/src/test/kotlin/org/openapitools/client/apis/PathApiTest.kt b/samples/client/echo_api/kotlin-model-prefix-type-mappings/src/test/kotlin/org/openapitools/client/apis/PathApiTest.kt new file mode 100644 index 0000000000..45e3535443 --- /dev/null +++ b/samples/client/echo_api/kotlin-model-prefix-type-mappings/src/test/kotlin/org/openapitools/client/apis/PathApiTest.kt @@ -0,0 +1,41 @@ +/** + * + * Please note: + * This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * Do not edit this file manually. + * + */ + +@file:Suppress( + "ArrayInDataClass", + "EnumEntryName", + "RemoveRedundantQualifierName", + "UnusedImport" +) + +package org.openapitools.client.apis + +import io.kotlintest.shouldBe +import io.kotlintest.specs.ShouldSpec + +import org.openapitools.client.apis.PathApi +import org.openapitools.client.models.ApiStringEnumRef + +class PathApiTest : ShouldSpec() { + init { + // uncomment below to create an instance of PathApi + //val apiInstance = PathApi() + + // to test testsPathStringPathStringIntegerPathIntegerEnumNonrefStringPathEnumRefStringPath + should("test testsPathStringPathStringIntegerPathIntegerEnumNonrefStringPathEnumRefStringPath") { + // uncomment below to test testsPathStringPathStringIntegerPathIntegerEnumNonrefStringPathEnumRefStringPath + //val pathString : kotlin.String = pathString_example // kotlin.String | + //val pathInteger : kotlin.Int = 56 // kotlin.Int | + //val enumNonrefStringPath : kotlin.String = enumNonrefStringPath_example // kotlin.String | + //val enumRefStringPath : ApiStringEnumRef = // ApiStringEnumRef | + //val result : kotlin.String = apiInstance.testsPathStringPathStringIntegerPathIntegerEnumNonrefStringPathEnumRefStringPath(pathString, pathInteger, enumNonrefStringPath, enumRefStringPath) + //result shouldBe ("TODO") + } + + } +} diff --git a/samples/client/echo_api/kotlin-model-prefix-type-mappings/src/test/kotlin/org/openapitools/client/apis/QueryApiTest.kt b/samples/client/echo_api/kotlin-model-prefix-type-mappings/src/test/kotlin/org/openapitools/client/apis/QueryApiTest.kt new file mode 100644 index 0000000000..8e036784b1 --- /dev/null +++ b/samples/client/echo_api/kotlin-model-prefix-type-mappings/src/test/kotlin/org/openapitools/client/apis/QueryApiTest.kt @@ -0,0 +1,85 @@ +/** + * + * Please note: + * This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * Do not edit this file manually. + * + */ + +@file:Suppress( + "ArrayInDataClass", + "EnumEntryName", + "RemoveRedundantQualifierName", + "UnusedImport" +) + +package org.openapitools.client.apis + +import io.kotlintest.shouldBe +import io.kotlintest.specs.ShouldSpec + +import org.openapitools.client.apis.QueryApi +import org.openapitools.client.models.ApiPet +import org.openapitools.client.models.ApiStringEnumRef +import org.openapitools.client.models.ApiTestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter + +class QueryApiTest : ShouldSpec() { + init { + // uncomment below to create an instance of QueryApi + //val apiInstance = QueryApi() + + // to test testEnumRefString + should("test testEnumRefString") { + // uncomment below to test testEnumRefString + //val enumNonrefStringQuery : kotlin.String = enumNonrefStringQuery_example // kotlin.String | + //val enumRefStringQuery : ApiStringEnumRef = // ApiStringEnumRef | + //val result : kotlin.String = apiInstance.testEnumRefString(enumNonrefStringQuery, enumRefStringQuery) + //result shouldBe ("TODO") + } + + // to test testQueryDatetimeDateString + should("test testQueryDatetimeDateString") { + // uncomment below to test testQueryDatetimeDateString + //val datetimeQuery : java.time.OffsetDateTime = 2013-10-20T19:20:30+01:00 // java.time.OffsetDateTime | + //val dateQuery : java.time.LocalDate = 2013-10-20 // java.time.LocalDate | + //val stringQuery : kotlin.String = stringQuery_example // kotlin.String | + //val result : kotlin.String = apiInstance.testQueryDatetimeDateString(datetimeQuery, dateQuery, stringQuery) + //result shouldBe ("TODO") + } + + // to test testQueryIntegerBooleanString + should("test testQueryIntegerBooleanString") { + // uncomment below to test testQueryIntegerBooleanString + //val integerQuery : kotlin.Int = 56 // kotlin.Int | + //val booleanQuery : kotlin.Boolean = true // kotlin.Boolean | + //val stringQuery : kotlin.String = stringQuery_example // kotlin.String | + //val result : kotlin.String = apiInstance.testQueryIntegerBooleanString(integerQuery, booleanQuery, stringQuery) + //result shouldBe ("TODO") + } + + // to test testQueryStyleDeepObjectExplodeTrueObject + should("test testQueryStyleDeepObjectExplodeTrueObject") { + // uncomment below to test testQueryStyleDeepObjectExplodeTrueObject + //val queryObject : ApiPet = // ApiPet | + //val result : kotlin.String = apiInstance.testQueryStyleDeepObjectExplodeTrueObject(queryObject) + //result shouldBe ("TODO") + } + + // to test testQueryStyleFormExplodeTrueArrayString + should("test testQueryStyleFormExplodeTrueArrayString") { + // uncomment below to test testQueryStyleFormExplodeTrueArrayString + //val queryObject : ApiTestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter = // ApiTestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter | + //val result : kotlin.String = apiInstance.testQueryStyleFormExplodeTrueArrayString(queryObject) + //result shouldBe ("TODO") + } + + // to test testQueryStyleFormExplodeTrueObject + should("test testQueryStyleFormExplodeTrueObject") { + // uncomment below to test testQueryStyleFormExplodeTrueObject + //val queryObject : ApiPet = // ApiPet | + //val result : kotlin.String = apiInstance.testQueryStyleFormExplodeTrueObject(queryObject) + //result shouldBe ("TODO") + } + + } +} diff --git a/samples/client/echo_api/kotlin-model-prefix-type-mappings/src/test/kotlin/org/openapitools/client/models/BirdTest.kt b/samples/client/echo_api/kotlin-model-prefix-type-mappings/src/test/kotlin/org/openapitools/client/models/BirdTest.kt new file mode 100644 index 0000000000..2b155a7f84 --- /dev/null +++ b/samples/client/echo_api/kotlin-model-prefix-type-mappings/src/test/kotlin/org/openapitools/client/models/BirdTest.kt @@ -0,0 +1,41 @@ +/** + * + * Please note: + * This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * Do not edit this file manually. + * + */ + +@file:Suppress( + "ArrayInDataClass", + "EnumEntryName", + "RemoveRedundantQualifierName", + "UnusedImport" +) + +package org.openapitools.client.models + +import io.kotlintest.shouldBe +import io.kotlintest.specs.ShouldSpec + +import org.openapitools.client.models.ApiBird + +class ApiBirdTest : ShouldSpec() { + init { + // uncomment below to create an instance of ApiBird + //val modelInstance = ApiBird() + + // to test the property `propertySize` + should("test propertySize") { + // uncomment below to test the property + //modelInstance.propertySize shouldBe ("TODO") + } + + // to test the property `color` + should("test color") { + // uncomment below to test the property + //modelInstance.color shouldBe ("TODO") + } + + } +} diff --git a/samples/client/echo_api/kotlin-model-prefix-type-mappings/src/test/kotlin/org/openapitools/client/models/CategoryTest.kt b/samples/client/echo_api/kotlin-model-prefix-type-mappings/src/test/kotlin/org/openapitools/client/models/CategoryTest.kt new file mode 100644 index 0000000000..32ca2d030e --- /dev/null +++ b/samples/client/echo_api/kotlin-model-prefix-type-mappings/src/test/kotlin/org/openapitools/client/models/CategoryTest.kt @@ -0,0 +1,41 @@ +/** + * + * Please note: + * This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * Do not edit this file manually. + * + */ + +@file:Suppress( + "ArrayInDataClass", + "EnumEntryName", + "RemoveRedundantQualifierName", + "UnusedImport" +) + +package org.openapitools.client.models + +import io.kotlintest.shouldBe +import io.kotlintest.specs.ShouldSpec + +import org.openapitools.client.models.ApiCategory + +class ApiCategoryTest : ShouldSpec() { + init { + // uncomment below to create an instance of ApiCategory + //val modelInstance = ApiCategory() + + // to test the property `id` + should("test id") { + // uncomment below to test the property + //modelInstance.id shouldBe ("TODO") + } + + // to test the property `name` + should("test name") { + // uncomment below to test the property + //modelInstance.name shouldBe ("TODO") + } + + } +} diff --git a/samples/client/echo_api/kotlin-model-prefix-type-mappings/src/test/kotlin/org/openapitools/client/models/DefaultValueTest.kt b/samples/client/echo_api/kotlin-model-prefix-type-mappings/src/test/kotlin/org/openapitools/client/models/DefaultValueTest.kt new file mode 100644 index 0000000000..31f50a4de4 --- /dev/null +++ b/samples/client/echo_api/kotlin-model-prefix-type-mappings/src/test/kotlin/org/openapitools/client/models/DefaultValueTest.kt @@ -0,0 +1,78 @@ +/** + * + * Please note: + * This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * Do not edit this file manually. + * + */ + +@file:Suppress( + "ArrayInDataClass", + "EnumEntryName", + "RemoveRedundantQualifierName", + "UnusedImport" +) + +package org.openapitools.client.models + +import io.kotlintest.shouldBe +import io.kotlintest.specs.ShouldSpec + +import org.openapitools.client.models.ApiDefaultValue +import org.openapitools.client.models.ApiStringEnumRef + +class ApiDefaultValueTest : ShouldSpec() { + init { + // uncomment below to create an instance of ApiDefaultValue + //val modelInstance = ApiDefaultValue() + + // to test the property `arrayStringEnumRefDefault` + should("test arrayStringEnumRefDefault") { + // uncomment below to test the property + //modelInstance.arrayStringEnumRefDefault shouldBe ("TODO") + } + + // to test the property `arrayStringEnumDefault` + should("test arrayStringEnumDefault") { + // uncomment below to test the property + //modelInstance.arrayStringEnumDefault shouldBe ("TODO") + } + + // to test the property `arrayStringDefault` + should("test arrayStringDefault") { + // uncomment below to test the property + //modelInstance.arrayStringDefault shouldBe ("TODO") + } + + // to test the property `arrayIntegerDefault` + should("test arrayIntegerDefault") { + // uncomment below to test the property + //modelInstance.arrayIntegerDefault shouldBe ("TODO") + } + + // to test the property `arrayString` + should("test arrayString") { + // uncomment below to test the property + //modelInstance.arrayString shouldBe ("TODO") + } + + // to test the property `arrayStringNullable` + should("test arrayStringNullable") { + // uncomment below to test the property + //modelInstance.arrayStringNullable shouldBe ("TODO") + } + + // to test the property `arrayStringExtensionNullable` + should("test arrayStringExtensionNullable") { + // uncomment below to test the property + //modelInstance.arrayStringExtensionNullable shouldBe ("TODO") + } + + // to test the property `stringNullable` + should("test stringNullable") { + // uncomment below to test the property + //modelInstance.stringNullable shouldBe ("TODO") + } + + } +} diff --git a/samples/client/echo_api/kotlin-model-prefix-type-mappings/src/test/kotlin/org/openapitools/client/models/NumberPropertiesOnlyTest.kt b/samples/client/echo_api/kotlin-model-prefix-type-mappings/src/test/kotlin/org/openapitools/client/models/NumberPropertiesOnlyTest.kt new file mode 100644 index 0000000000..1a2eb61469 --- /dev/null +++ b/samples/client/echo_api/kotlin-model-prefix-type-mappings/src/test/kotlin/org/openapitools/client/models/NumberPropertiesOnlyTest.kt @@ -0,0 +1,47 @@ +/** + * + * Please note: + * This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * Do not edit this file manually. + * + */ + +@file:Suppress( + "ArrayInDataClass", + "EnumEntryName", + "RemoveRedundantQualifierName", + "UnusedImport" +) + +package org.openapitools.client.models + +import io.kotlintest.shouldBe +import io.kotlintest.specs.ShouldSpec + +import org.openapitools.client.models.ApiNumberPropertiesOnly + +class ApiNumberPropertiesOnlyTest : ShouldSpec() { + init { + // uncomment below to create an instance of ApiNumberPropertiesOnly + //val modelInstance = ApiNumberPropertiesOnly() + + // to test the property `number` + should("test number") { + // uncomment below to test the property + //modelInstance.number shouldBe ("TODO") + } + + // to test the property `float` + should("test float") { + // uncomment below to test the property + //modelInstance.float shouldBe ("TODO") + } + + // to test the property `double` + should("test double") { + // uncomment below to test the property + //modelInstance.double shouldBe ("TODO") + } + + } +} diff --git a/samples/client/echo_api/kotlin-model-prefix-type-mappings/src/test/kotlin/org/openapitools/client/models/PetTest.kt b/samples/client/echo_api/kotlin-model-prefix-type-mappings/src/test/kotlin/org/openapitools/client/models/PetTest.kt new file mode 100644 index 0000000000..e551810928 --- /dev/null +++ b/samples/client/echo_api/kotlin-model-prefix-type-mappings/src/test/kotlin/org/openapitools/client/models/PetTest.kt @@ -0,0 +1,67 @@ +/** + * + * Please note: + * This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * Do not edit this file manually. + * + */ + +@file:Suppress( + "ArrayInDataClass", + "EnumEntryName", + "RemoveRedundantQualifierName", + "UnusedImport" +) + +package org.openapitools.client.models + +import io.kotlintest.shouldBe +import io.kotlintest.specs.ShouldSpec + +import org.openapitools.client.models.ApiPet +import org.openapitools.client.models.ApiCategory +import org.openapitools.client.models.ApiTag + +class ApiPetTest : ShouldSpec() { + init { + // uncomment below to create an instance of ApiPet + //val modelInstance = ApiPet() + + // to test the property `name` + should("test name") { + // uncomment below to test the property + //modelInstance.name shouldBe ("TODO") + } + + // to test the property `photoUrls` + should("test photoUrls") { + // uncomment below to test the property + //modelInstance.photoUrls shouldBe ("TODO") + } + + // to test the property `id` + should("test id") { + // uncomment below to test the property + //modelInstance.id shouldBe ("TODO") + } + + // to test the property `category` + should("test category") { + // uncomment below to test the property + //modelInstance.category shouldBe ("TODO") + } + + // to test the property `tags` + should("test tags") { + // uncomment below to test the property + //modelInstance.tags shouldBe ("TODO") + } + + // to test the property `status` - pet status in the store + should("test status") { + // uncomment below to test the property + //modelInstance.status shouldBe ("TODO") + } + + } +} diff --git a/samples/client/echo_api/kotlin-model-prefix-type-mappings/src/test/kotlin/org/openapitools/client/models/QueryTest.kt b/samples/client/echo_api/kotlin-model-prefix-type-mappings/src/test/kotlin/org/openapitools/client/models/QueryTest.kt new file mode 100644 index 0000000000..35801289fd --- /dev/null +++ b/samples/client/echo_api/kotlin-model-prefix-type-mappings/src/test/kotlin/org/openapitools/client/models/QueryTest.kt @@ -0,0 +1,41 @@ +/** + * + * Please note: + * This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * Do not edit this file manually. + * + */ + +@file:Suppress( + "ArrayInDataClass", + "EnumEntryName", + "RemoveRedundantQualifierName", + "UnusedImport" +) + +package org.openapitools.client.models + +import io.kotlintest.shouldBe +import io.kotlintest.specs.ShouldSpec + +import org.openapitools.client.models.ApiQuery + +class ApiQueryTest : ShouldSpec() { + init { + // uncomment below to create an instance of ApiQuery + //val modelInstance = ApiQuery() + + // to test the property `id` - Query + should("test id") { + // uncomment below to test the property + //modelInstance.id shouldBe ("TODO") + } + + // to test the property `outcomes` + should("test outcomes") { + // uncomment below to test the property + //modelInstance.outcomes shouldBe ("TODO") + } + + } +} diff --git a/samples/client/echo_api/kotlin-model-prefix-type-mappings/src/test/kotlin/org/openapitools/client/models/StringEnumRefTest.kt b/samples/client/echo_api/kotlin-model-prefix-type-mappings/src/test/kotlin/org/openapitools/client/models/StringEnumRefTest.kt new file mode 100644 index 0000000000..6b793e4726 --- /dev/null +++ b/samples/client/echo_api/kotlin-model-prefix-type-mappings/src/test/kotlin/org/openapitools/client/models/StringEnumRefTest.kt @@ -0,0 +1,29 @@ +/** + * + * Please note: + * This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * Do not edit this file manually. + * + */ + +@file:Suppress( + "ArrayInDataClass", + "EnumEntryName", + "RemoveRedundantQualifierName", + "UnusedImport" +) + +package org.openapitools.client.models + +import io.kotlintest.shouldBe +import io.kotlintest.specs.ShouldSpec + +import org.openapitools.client.models.ApiStringEnumRef + +class ApiStringEnumRefTest : ShouldSpec() { + init { + // uncomment below to create an instance of ApiStringEnumRef + //val modelInstance = ApiStringEnumRef() + + } +} diff --git a/samples/client/echo_api/kotlin-model-prefix-type-mappings/src/test/kotlin/org/openapitools/client/models/TagTest.kt b/samples/client/echo_api/kotlin-model-prefix-type-mappings/src/test/kotlin/org/openapitools/client/models/TagTest.kt new file mode 100644 index 0000000000..44fa5d60e0 --- /dev/null +++ b/samples/client/echo_api/kotlin-model-prefix-type-mappings/src/test/kotlin/org/openapitools/client/models/TagTest.kt @@ -0,0 +1,41 @@ +/** + * + * Please note: + * This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * Do not edit this file manually. + * + */ + +@file:Suppress( + "ArrayInDataClass", + "EnumEntryName", + "RemoveRedundantQualifierName", + "UnusedImport" +) + +package org.openapitools.client.models + +import io.kotlintest.shouldBe +import io.kotlintest.specs.ShouldSpec + +import org.openapitools.client.models.ApiTag + +class ApiTagTest : ShouldSpec() { + init { + // uncomment below to create an instance of ApiTag + //val modelInstance = ApiTag() + + // to test the property `id` + should("test id") { + // uncomment below to test the property + //modelInstance.id shouldBe ("TODO") + } + + // to test the property `name` + should("test name") { + // uncomment below to test the property + //modelInstance.name shouldBe ("TODO") + } + + } +} diff --git a/samples/client/echo_api/kotlin-model-prefix-type-mappings/src/test/kotlin/org/openapitools/client/models/TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameterTest.kt b/samples/client/echo_api/kotlin-model-prefix-type-mappings/src/test/kotlin/org/openapitools/client/models/TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameterTest.kt new file mode 100644 index 0000000000..633970ad00 --- /dev/null +++ b/samples/client/echo_api/kotlin-model-prefix-type-mappings/src/test/kotlin/org/openapitools/client/models/TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameterTest.kt @@ -0,0 +1,35 @@ +/** + * + * Please note: + * This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * Do not edit this file manually. + * + */ + +@file:Suppress( + "ArrayInDataClass", + "EnumEntryName", + "RemoveRedundantQualifierName", + "UnusedImport" +) + +package org.openapitools.client.models + +import io.kotlintest.shouldBe +import io.kotlintest.specs.ShouldSpec + +import org.openapitools.client.models.ApiTestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter + +class ApiTestQueryStyleFormExplodeTrueArrayStringQueryObjectParameterTest : ShouldSpec() { + init { + // uncomment below to create an instance of ApiTestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter + //val modelInstance = ApiTestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter() + + // to test the property `propertyValues` + should("test propertyValues") { + // uncomment below to test the property + //modelInstance.propertyValues shouldBe ("TODO") + } + + } +} diff --git a/samples/client/petstore/kotlin-model-prefix-type-mappings/.openapi-generator-ignore b/samples/client/petstore/kotlin-model-prefix-type-mappings/.openapi-generator-ignore new file mode 100644 index 0000000000..7484ee590a --- /dev/null +++ b/samples/client/petstore/kotlin-model-prefix-type-mappings/.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-model-prefix-type-mappings/.openapi-generator/FILES b/samples/client/petstore/kotlin-model-prefix-type-mappings/.openapi-generator/FILES new file mode 100644 index 0000000000..9326c4589e --- /dev/null +++ b/samples/client/petstore/kotlin-model-prefix-type-mappings/.openapi-generator/FILES @@ -0,0 +1,41 @@ +README.md +build.gradle +docs/Annotation.md +docs/ApiResponse.md +docs/Category.md +docs/FakeApi.md +docs/Order.md +docs/Pet.md +docs/PetApi.md +docs/StoreApi.md +docs/Tag.md +docs/User.md +docs/UserApi.md +gradle/wrapper/gradle-wrapper.jar +gradle/wrapper/gradle-wrapper.properties +gradlew +gradlew.bat +settings.gradle +src/main/kotlin/org/openapitools/client/apis/FakeApi.kt +src/main/kotlin/org/openapitools/client/apis/PetApi.kt +src/main/kotlin/org/openapitools/client/apis/StoreApi.kt +src/main/kotlin/org/openapitools/client/apis/UserApi.kt +src/main/kotlin/org/openapitools/client/auth/ApiKeyAuth.kt +src/main/kotlin/org/openapitools/client/auth/OAuth.kt +src/main/kotlin/org/openapitools/client/auth/OAuthFlow.kt +src/main/kotlin/org/openapitools/client/auth/OAuthOkHttpClient.kt +src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt +src/main/kotlin/org/openapitools/client/infrastructure/ByteArrayAdapter.kt +src/main/kotlin/org/openapitools/client/infrastructure/CollectionFormats.kt +src/main/kotlin/org/openapitools/client/infrastructure/LocalDateAdapter.kt +src/main/kotlin/org/openapitools/client/infrastructure/LocalDateTimeAdapter.kt +src/main/kotlin/org/openapitools/client/infrastructure/OffsetDateTimeAdapter.kt +src/main/kotlin/org/openapitools/client/infrastructure/ResponseExt.kt +src/main/kotlin/org/openapitools/client/infrastructure/Serializer.kt +src/main/kotlin/org/openapitools/client/models/ApiAnnotation.kt +src/main/kotlin/org/openapitools/client/models/ApiApiResponse.kt +src/main/kotlin/org/openapitools/client/models/ApiCategory.kt +src/main/kotlin/org/openapitools/client/models/ApiOrder.kt +src/main/kotlin/org/openapitools/client/models/ApiPet.kt +src/main/kotlin/org/openapitools/client/models/ApiTag.kt +src/main/kotlin/org/openapitools/client/models/ApiUser.kt diff --git a/samples/client/petstore/kotlin-model-prefix-type-mappings/.openapi-generator/VERSION b/samples/client/petstore/kotlin-model-prefix-type-mappings/.openapi-generator/VERSION new file mode 100644 index 0000000000..08bfd0643b --- /dev/null +++ b/samples/client/petstore/kotlin-model-prefix-type-mappings/.openapi-generator/VERSION @@ -0,0 +1 @@ +7.5.0-SNAPSHOT diff --git a/samples/client/petstore/kotlin-model-prefix-type-mappings/README.md b/samples/client/petstore/kotlin-model-prefix-type-mappings/README.md new file mode 100644 index 0000000000..39cb3bf921 --- /dev/null +++ b/samples/client/petstore/kotlin-model-prefix-type-mappings/README.md @@ -0,0 +1,104 @@ +# org.openapitools.client - Kotlin client library for 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. + +## Overview +This API client was generated by the [OpenAPI Generator](https://openapi-generator.tech) project. By using the [openapi-spec](https://github.com/OAI/OpenAPI-Specification) from a remote server, you can easily generate an API client. + +- API version: 1.0.0 +- Package version: +- Generator version: 7.5.0-SNAPSHOT +- Build package: org.openapitools.codegen.languages.KotlinClientCodegen + +## Requires + +* Kotlin 1.7.21 +* Gradle 7.5 + +## Build + +First, create the gradle wrapper script: + +``` +gradle wrapper +``` + +Then, run: + +``` +./gradlew check assemble +``` + +This runs all tests and packages the library. + +## Features/Implementation Notes + +* Supports JSON inputs/outputs, File inputs, and Form inputs. +* Supports collection formats for query parameters: csv, tsv, ssv, pipes. +* Some Kotlin and Java types are fully qualified to avoid conflicts with types defined in OpenAPI definitions. +* Implementation of ApiClient is intended to reduce method counts, specifically to benefit Android targets. + + +## Documentation for API Endpoints + +All URIs are relative to *http://petstore.swagger.io/v2* + +Class | Method | HTTP request | Description +------------ | ------------- | ------------- | ------------- +*FakeApi* | [**annotations**](docs/FakeApi.md#annotations) | **POST** fake/annotations | annotate +*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.ApiAnnotation](docs/ApiAnnotation.md) + - [org.openapitools.client.models.ApiApiResponse](docs/ApiApiResponse.md) + - [org.openapitools.client.models.ApiCategory](docs/ApiCategory.md) + - [org.openapitools.client.models.ApiOrder](docs/ApiOrder.md) + - [org.openapitools.client.models.ApiPet](docs/ApiPet.md) + - [org.openapitools.client.models.ApiTag](docs/ApiTag.md) + - [org.openapitools.client.models.ApiUser](docs/ApiUser.md) + + + +## Documentation for Authorization + + +Authentication schemes defined for the API: + +### 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 + + +### api_key + +- **Type**: API key +- **API key parameter name**: api_key +- **Location**: HTTP header + diff --git a/samples/client/petstore/kotlin-model-prefix-type-mappings/build.gradle b/samples/client/petstore/kotlin-model-prefix-type-mappings/build.gradle new file mode 100644 index 0000000000..dcd26b4cfc --- /dev/null +++ b/samples/client/petstore/kotlin-model-prefix-type-mappings/build.gradle @@ -0,0 +1,66 @@ +group 'org.openapitools' +version '1.0.0' + +wrapper { + gradleVersion = '7.5' + distributionUrl = "https://services.gradle.org/distributions/gradle-$gradleVersion-all.zip" +} + +buildscript { + ext.kotlin_version = '1.8.10' + ext.retrofitVersion = '2.9.0' + ext.spotless_version = "6.13.0" + + repositories { + maven { url "https://repo1.maven.org/maven2" } + } + dependencies { + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" + classpath "com.diffplug.spotless:spotless-plugin-gradle:$spotless_version" + } +} + +apply plugin: 'kotlin' +apply plugin: 'maven-publish' +apply plugin: 'com.diffplug.spotless' + +repositories { + maven { url "https://repo1.maven.org/maven2" } +} + +// Use spotless plugin to automatically format code, remove unused import, etc +// To apply changes directly to the file, run `gradlew spotlessApply` +// Ref: https://github.com/diffplug/spotless/tree/main/plugin-gradle +spotless { + // comment out below to run spotless as part of the `check` task + enforceCheck false + + format 'misc', { + // define the files (e.g. '*.gradle', '*.md') to apply `misc` to + target '.gitignore' + + // define the steps to apply to those files + trimTrailingWhitespace() + indentWithSpaces() // Takes an integer argument if you don't like 4 + endWithNewline() + } + kotlin { + ktfmt() + } +} + +test { + useJUnitPlatform() +} + +dependencies { + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" + implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4" + implementation "com.google.code.gson:gson:2.9.0" + implementation "org.apache.oltu.oauth2:org.apache.oltu.oauth2.client:1.0.2" + implementation "com.squareup.okhttp3:logging-interceptor:4.10.0" + implementation "com.squareup.retrofit2:retrofit:$retrofitVersion" + implementation "com.squareup.retrofit2:converter-gson:$retrofitVersion" + implementation "com.squareup.retrofit2:converter-scalars:$retrofitVersion" + testImplementation "io.kotlintest:kotlintest-runner-junit5:3.4.2" +} diff --git a/samples/client/petstore/kotlin-model-prefix-type-mappings/docs/Annotation.md b/samples/client/petstore/kotlin-model-prefix-type-mappings/docs/Annotation.md new file mode 100644 index 0000000000..7bf1a65e97 --- /dev/null +++ b/samples/client/petstore/kotlin-model-prefix-type-mappings/docs/Annotation.md @@ -0,0 +1,10 @@ + +# ApiAnnotation + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | [**java.util.UUID**](java.util.UUID.md) | | [optional] + + + diff --git a/samples/client/petstore/kotlin-model-prefix-type-mappings/docs/ApiResponse.md b/samples/client/petstore/kotlin-model-prefix-type-mappings/docs/ApiResponse.md new file mode 100644 index 0000000000..eea339dd9d --- /dev/null +++ b/samples/client/petstore/kotlin-model-prefix-type-mappings/docs/ApiResponse.md @@ -0,0 +1,12 @@ + +# ApiApiResponse + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**code** | **kotlin.Int** | | [optional] +**type** | **kotlin.String** | | [optional] +**message** | **kotlin.String** | | [optional] + + + diff --git a/samples/client/petstore/kotlin-model-prefix-type-mappings/docs/Category.md b/samples/client/petstore/kotlin-model-prefix-type-mappings/docs/Category.md new file mode 100644 index 0000000000..4445602c2d --- /dev/null +++ b/samples/client/petstore/kotlin-model-prefix-type-mappings/docs/Category.md @@ -0,0 +1,11 @@ + +# ApiCategory + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **kotlin.Long** | | [optional] +**name** | **kotlin.String** | | [optional] + + + diff --git a/samples/client/petstore/kotlin-model-prefix-type-mappings/docs/FakeApi.md b/samples/client/petstore/kotlin-model-prefix-type-mappings/docs/FakeApi.md new file mode 100644 index 0000000000..6df4082fb3 --- /dev/null +++ b/samples/client/petstore/kotlin-model-prefix-type-mappings/docs/FakeApi.md @@ -0,0 +1,47 @@ +# FakeApi + +All URIs are relative to *http://petstore.swagger.io/v2* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**annotations**](FakeApi.md#annotations) | **POST** fake/annotations | annotate + + + +annotate + +### Example +```kotlin +// Import classes: +//import org.openapitools.client.* +//import org.openapitools.client.infrastructure.* +//import org.openapitools.client.models.* + +val apiClient = ApiClient() +val webService = apiClient.createWebservice(FakeApi::class.java) +val apiAnnotation : ApiAnnotation = // ApiAnnotation | + +launch(Dispatchers.IO) { + webService.annotations(apiAnnotation) +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **apiAnnotation** | [**ApiAnnotation**](ApiAnnotation.md)| | + +### Return type + +null (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: Not defined + diff --git a/samples/client/petstore/kotlin-model-prefix-type-mappings/docs/Order.md b/samples/client/petstore/kotlin-model-prefix-type-mappings/docs/Order.md new file mode 100644 index 0000000000..22465419b2 --- /dev/null +++ b/samples/client/petstore/kotlin-model-prefix-type-mappings/docs/Order.md @@ -0,0 +1,22 @@ + +# ApiOrder + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **kotlin.Long** | | [optional] +**petId** | **kotlin.Long** | | [optional] +**quantity** | **kotlin.Int** | | [optional] +**shipDate** | [**java.time.OffsetDateTime**](java.time.OffsetDateTime.md) | | [optional] +**status** | [**inline**](#Status) | Order Status | [optional] +**complete** | **kotlin.Boolean** | | [optional] + + + +## Enum: status +Name | Value +---- | ----- +status | placed, approved, delivered + + + diff --git a/samples/client/petstore/kotlin-model-prefix-type-mappings/docs/Pet.md b/samples/client/petstore/kotlin-model-prefix-type-mappings/docs/Pet.md new file mode 100644 index 0000000000..f525df0ffd --- /dev/null +++ b/samples/client/petstore/kotlin-model-prefix-type-mappings/docs/Pet.md @@ -0,0 +1,22 @@ + +# ApiPet + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**name** | **kotlin.String** | | +**photoUrls** | **kotlin.collections.List<kotlin.String>** | | +**id** | **kotlin.Long** | | [optional] +**category** | [**ApiCategory**](ApiCategory.md) | | [optional] +**tags** | [**kotlin.collections.List<ApiTag>**](ApiTag.md) | | [optional] +**status** | [**inline**](#Status) | pet status in the store | [optional] + + + +## Enum: status +Name | Value +---- | ----- +status | available, pending, sold + + + diff --git a/samples/client/petstore/kotlin-model-prefix-type-mappings/docs/PetApi.md b/samples/client/petstore/kotlin-model-prefix-type-mappings/docs/PetApi.md new file mode 100644 index 0000000000..2fb1fdbaf3 --- /dev/null +++ b/samples/client/petstore/kotlin-model-prefix-type-mappings/docs/PetApi.md @@ -0,0 +1,346 @@ +# 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 + + + +Add a new pet to the store + + + +### Example +```kotlin +// Import classes: +//import org.openapitools.client.* +//import org.openapitools.client.infrastructure.* +//import org.openapitools.client.models.* + +val apiClient = ApiClient() +val webService = apiClient.createWebservice(PetApi::class.java) +val apiPet : ApiPet = // ApiPet | Pet object that needs to be added to the store + +launch(Dispatchers.IO) { + val result : ApiPet = webService.addPet(apiPet) +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **apiPet** | [**ApiPet**](ApiPet.md)| Pet object that needs to be added to the store | + +### Return type + +[**ApiPet**](ApiPet.md) + +### Authorization + + + +### HTTP request headers + + - **Content-Type**: application/json, application/xml + - **Accept**: application/xml, application/json + + +Deletes a pet + + + +### Example +```kotlin +// Import classes: +//import org.openapitools.client.* +//import org.openapitools.client.infrastructure.* +//import org.openapitools.client.models.* + +val apiClient = ApiClient() +val webService = apiClient.createWebservice(PetApi::class.java) +val petId : kotlin.Long = 789 // kotlin.Long | Pet id to delete +val apiKey : kotlin.String = apiKey_example // kotlin.String | + +launch(Dispatchers.IO) { + webService.deletePet(petId, apiKey) +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **petId** | **kotlin.Long**| Pet id to delete | + **apiKey** | **kotlin.String**| | [optional] + +### Return type + +null (empty response body) + +### Authorization + + + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: Not defined + + +Finds Pets by status + +Multiple status values can be provided with comma separated strings + +### Example +```kotlin +// Import classes: +//import org.openapitools.client.* +//import org.openapitools.client.infrastructure.* +//import org.openapitools.client.models.* + +val apiClient = ApiClient() +val webService = apiClient.createWebservice(PetApi::class.java) +val status : kotlin.collections.List = // kotlin.collections.List | Status values that need to be considered for filter + +launch(Dispatchers.IO) { + val result : kotlin.collections.List = webService.findPetsByStatus(status) +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **status** | [**kotlin.collections.List<kotlin.String>**](kotlin.String.md)| Status values that need to be considered for filter | [enum: available, pending, sold] + +### Return type + +[**kotlin.collections.List<ApiPet>**](ApiPet.md) + +### Authorization + + + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + + +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.* +//import org.openapitools.client.infrastructure.* +//import org.openapitools.client.models.* + +val apiClient = ApiClient() +val webService = apiClient.createWebservice(PetApi::class.java) +val tags : kotlin.collections.List = // kotlin.collections.List | Tags to filter by + +launch(Dispatchers.IO) { + val result : kotlin.collections.List = webService.findPetsByTags(tags) +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **tags** | [**kotlin.collections.List<kotlin.String>**](kotlin.String.md)| Tags to filter by | + +### Return type + +[**kotlin.collections.List<ApiPet>**](ApiPet.md) + +### Authorization + + + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + + +Find pet by ID + +Returns a single pet + +### Example +```kotlin +// Import classes: +//import org.openapitools.client.* +//import org.openapitools.client.infrastructure.* +//import org.openapitools.client.models.* + +val apiClient = ApiClient() +val webService = apiClient.createWebservice(PetApi::class.java) +val petId : kotlin.Long = 789 // kotlin.Long | ID of pet to return + +launch(Dispatchers.IO) { + val result : ApiPet = webService.getPetById(petId) +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **petId** | **kotlin.Long**| ID of pet to return | + +### Return type + +[**ApiPet**](ApiPet.md) + +### Authorization + + + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + + +Update an existing pet + + + +### Example +```kotlin +// Import classes: +//import org.openapitools.client.* +//import org.openapitools.client.infrastructure.* +//import org.openapitools.client.models.* + +val apiClient = ApiClient() +val webService = apiClient.createWebservice(PetApi::class.java) +val apiPet : ApiPet = // ApiPet | Pet object that needs to be added to the store + +launch(Dispatchers.IO) { + val result : ApiPet = webService.updatePet(apiPet) +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **apiPet** | [**ApiPet**](ApiPet.md)| Pet object that needs to be added to the store | + +### Return type + +[**ApiPet**](ApiPet.md) + +### Authorization + + + +### HTTP request headers + + - **Content-Type**: application/json, application/xml + - **Accept**: application/xml, application/json + + +Updates a pet in the store with form data + + + +### Example +```kotlin +// Import classes: +//import org.openapitools.client.* +//import org.openapitools.client.infrastructure.* +//import org.openapitools.client.models.* + +val apiClient = ApiClient() +val webService = apiClient.createWebservice(PetApi::class.java) +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 + +launch(Dispatchers.IO) { + webService.updatePetWithForm(petId, name, status) +} +``` + +### 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 + + + +### HTTP request headers + + - **Content-Type**: application/x-www-form-urlencoded + - **Accept**: Not defined + + +uploads an image + + + +### Example +```kotlin +// Import classes: +//import org.openapitools.client.* +//import org.openapitools.client.infrastructure.* +//import org.openapitools.client.models.* + +val apiClient = ApiClient() +val webService = apiClient.createWebservice(PetApi::class.java) +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 : RequestBody = BINARY_DATA_HERE // RequestBody | file to upload + +launch(Dispatchers.IO) { + val result : ApiApiResponse = webService.uploadFile(petId, additionalMetadata, file) +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **petId** | **kotlin.Long**| ID of pet to update | + **additionalMetadata** | **kotlin.String**| Additional data to pass to server | [optional] + **file** | **RequestBody**| file to upload | [optional] + +### Return type + +[**ApiApiResponse**](ApiApiResponse.md) + +### Authorization + + + +### HTTP request headers + + - **Content-Type**: multipart/form-data + - **Accept**: application/json + diff --git a/samples/client/petstore/kotlin-model-prefix-type-mappings/docs/StoreApi.md b/samples/client/petstore/kotlin-model-prefix-type-mappings/docs/StoreApi.md new file mode 100644 index 0000000000..8bedce7d2c --- /dev/null +++ b/samples/client/petstore/kotlin-model-prefix-type-mappings/docs/StoreApi.md @@ -0,0 +1,168 @@ +# 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 + + + +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.* +//import org.openapitools.client.infrastructure.* +//import org.openapitools.client.models.* + +val apiClient = ApiClient() +val webService = apiClient.createWebservice(StoreApi::class.java) +val orderId : kotlin.String = orderId_example // kotlin.String | ID of the order that needs to be deleted + +launch(Dispatchers.IO) { + webService.deleteOrder(orderId) +} +``` + +### 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 + + +Returns pet inventories by status + +Returns a map of status codes to quantities + +### Example +```kotlin +// Import classes: +//import org.openapitools.client.* +//import org.openapitools.client.infrastructure.* +//import org.openapitools.client.models.* + +val apiClient = ApiClient() +val webService = apiClient.createWebservice(StoreApi::class.java) + +launch(Dispatchers.IO) { + val result : kotlin.collections.Map = webService.getInventory() +} +``` + +### Parameters +This endpoint does not need any parameter. + +### Return type + +**kotlin.collections.Map<kotlin.String, kotlin.Int>** + +### Authorization + + + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + + +Find purchase order by ID + +For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions + +### Example +```kotlin +// Import classes: +//import org.openapitools.client.* +//import org.openapitools.client.infrastructure.* +//import org.openapitools.client.models.* + +val apiClient = ApiClient() +val webService = apiClient.createWebservice(StoreApi::class.java) +val orderId : kotlin.Long = 789 // kotlin.Long | ID of pet that needs to be fetched + +launch(Dispatchers.IO) { + val result : ApiOrder = webService.getOrderById(orderId) +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **orderId** | **kotlin.Long**| ID of pet that needs to be fetched | + +### Return type + +[**ApiOrder**](ApiOrder.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + + +Place an order for a pet + + + +### Example +```kotlin +// Import classes: +//import org.openapitools.client.* +//import org.openapitools.client.infrastructure.* +//import org.openapitools.client.models.* + +val apiClient = ApiClient() +val webService = apiClient.createWebservice(StoreApi::class.java) +val apiOrder : ApiOrder = // ApiOrder | order placed for purchasing the pet + +launch(Dispatchers.IO) { + val result : ApiOrder = webService.placeOrder(apiOrder) +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **apiOrder** | [**ApiOrder**](ApiOrder.md)| order placed for purchasing the pet | + +### Return type + +[**ApiOrder**](ApiOrder.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: application/xml, application/json + diff --git a/samples/client/petstore/kotlin-model-prefix-type-mappings/docs/Tag.md b/samples/client/petstore/kotlin-model-prefix-type-mappings/docs/Tag.md new file mode 100644 index 0000000000..91a171469a --- /dev/null +++ b/samples/client/petstore/kotlin-model-prefix-type-mappings/docs/Tag.md @@ -0,0 +1,11 @@ + +# ApiTag + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **kotlin.Long** | | [optional] +**name** | **kotlin.String** | | [optional] + + + diff --git a/samples/client/petstore/kotlin-model-prefix-type-mappings/docs/User.md b/samples/client/petstore/kotlin-model-prefix-type-mappings/docs/User.md new file mode 100644 index 0000000000..ccf8c9966e --- /dev/null +++ b/samples/client/petstore/kotlin-model-prefix-type-mappings/docs/User.md @@ -0,0 +1,17 @@ + +# ApiUser + +## 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-model-prefix-type-mappings/docs/UserApi.md b/samples/client/petstore/kotlin-model-prefix-type-mappings/docs/UserApi.md new file mode 100644 index 0000000000..920211e7c0 --- /dev/null +++ b/samples/client/petstore/kotlin-model-prefix-type-mappings/docs/UserApi.md @@ -0,0 +1,336 @@ +# 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 + + + +Create user + +This can only be done by the logged in user. + +### Example +```kotlin +// Import classes: +//import org.openapitools.client.* +//import org.openapitools.client.infrastructure.* +//import org.openapitools.client.models.* + +val apiClient = ApiClient() +val webService = apiClient.createWebservice(UserApi::class.java) +val apiUser : ApiUser = // ApiUser | Created user object + +launch(Dispatchers.IO) { + webService.createUser(apiUser) +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **apiUser** | [**ApiUser**](ApiUser.md)| Created user object | + +### Return type + +null (empty response body) + +### Authorization + + + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: Not defined + + +Creates list of users with given input array + + + +### Example +```kotlin +// Import classes: +//import org.openapitools.client.* +//import org.openapitools.client.infrastructure.* +//import org.openapitools.client.models.* + +val apiClient = ApiClient() +val webService = apiClient.createWebservice(UserApi::class.java) +val apiUser : kotlin.collections.List = // kotlin.collections.List | List of user object + +launch(Dispatchers.IO) { + webService.createUsersWithArrayInput(apiUser) +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **apiUser** | [**kotlin.collections.List<ApiUser>**](ApiUser.md)| List of user object | + +### Return type + +null (empty response body) + +### Authorization + + + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: Not defined + + +Creates list of users with given input array + + + +### Example +```kotlin +// Import classes: +//import org.openapitools.client.* +//import org.openapitools.client.infrastructure.* +//import org.openapitools.client.models.* + +val apiClient = ApiClient() +val webService = apiClient.createWebservice(UserApi::class.java) +val apiUser : kotlin.collections.List = // kotlin.collections.List | List of user object + +launch(Dispatchers.IO) { + webService.createUsersWithListInput(apiUser) +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **apiUser** | [**kotlin.collections.List<ApiUser>**](ApiUser.md)| List of user object | + +### Return type + +null (empty response body) + +### Authorization + + + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: Not defined + + +Delete user + +This can only be done by the logged in user. + +### Example +```kotlin +// Import classes: +//import org.openapitools.client.* +//import org.openapitools.client.infrastructure.* +//import org.openapitools.client.models.* + +val apiClient = ApiClient() +val webService = apiClient.createWebservice(UserApi::class.java) +val username : kotlin.String = username_example // kotlin.String | The name that needs to be deleted + +launch(Dispatchers.IO) { + webService.deleteUser(username) +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **username** | **kotlin.String**| The name that needs to be deleted | + +### Return type + +null (empty response body) + +### Authorization + + + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: Not defined + + +Get user by user name + + + +### Example +```kotlin +// Import classes: +//import org.openapitools.client.* +//import org.openapitools.client.infrastructure.* +//import org.openapitools.client.models.* + +val apiClient = ApiClient() +val webService = apiClient.createWebservice(UserApi::class.java) +val username : kotlin.String = username_example // kotlin.String | The name that needs to be fetched. Use user1 for testing. + +launch(Dispatchers.IO) { + val result : ApiUser = webService.getUserByName(username) +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **username** | **kotlin.String**| The name that needs to be fetched. Use user1 for testing. | + +### Return type + +[**ApiUser**](ApiUser.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + + +Logs user into the system + + + +### Example +```kotlin +// Import classes: +//import org.openapitools.client.* +//import org.openapitools.client.infrastructure.* +//import org.openapitools.client.models.* + +val apiClient = ApiClient() +val webService = apiClient.createWebservice(UserApi::class.java) +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 + +launch(Dispatchers.IO) { + val result : kotlin.String = webService.loginUser(username, password) +} +``` + +### 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 + + +Logs out current logged in user session + + + +### Example +```kotlin +// Import classes: +//import org.openapitools.client.* +//import org.openapitools.client.infrastructure.* +//import org.openapitools.client.models.* + +val apiClient = ApiClient() +val webService = apiClient.createWebservice(UserApi::class.java) + +launch(Dispatchers.IO) { + webService.logoutUser() +} +``` + +### Parameters +This endpoint does not need any parameter. + +### Return type + +null (empty response body) + +### Authorization + + + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: Not defined + + +Updated user + +This can only be done by the logged in user. + +### Example +```kotlin +// Import classes: +//import org.openapitools.client.* +//import org.openapitools.client.infrastructure.* +//import org.openapitools.client.models.* + +val apiClient = ApiClient() +val webService = apiClient.createWebservice(UserApi::class.java) +val username : kotlin.String = username_example // kotlin.String | name that need to be deleted +val apiUser : ApiUser = // ApiUser | Updated user object + +launch(Dispatchers.IO) { + webService.updateUser(username, apiUser) +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **username** | **kotlin.String**| name that need to be deleted | + **apiUser** | [**ApiUser**](ApiUser.md)| Updated user object | + +### Return type + +null (empty response body) + +### Authorization + + + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: Not defined + diff --git a/samples/client/petstore/kotlin-model-prefix-type-mappings/gradle/wrapper/gradle-wrapper.jar b/samples/client/petstore/kotlin-model-prefix-type-mappings/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000000..c1962a79e2 Binary files /dev/null and b/samples/client/petstore/kotlin-model-prefix-type-mappings/gradle/wrapper/gradle-wrapper.jar differ diff --git a/samples/client/petstore/kotlin-model-prefix-type-mappings/gradle/wrapper/gradle-wrapper.properties b/samples/client/petstore/kotlin-model-prefix-type-mappings/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000000..8707e8b506 --- /dev/null +++ b/samples/client/petstore/kotlin-model-prefix-type-mappings/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-all.zip +networkTimeout=10000 +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/samples/client/petstore/kotlin-model-prefix-type-mappings/gradlew b/samples/client/petstore/kotlin-model-prefix-type-mappings/gradlew new file mode 100644 index 0000000000..aeb74cbb43 --- /dev/null +++ b/samples/client/petstore/kotlin-model-prefix-type-mappings/gradlew @@ -0,0 +1,245 @@ +#!/bin/sh + +# +# Copyright © 2015-2021 the original authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +############################################################################## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# +############################################################################## + +# Attempt to set APP_HOME + +# Resolve links: $0 may be a link +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac +done + +# This is normally unused +# shellcheck disable=SC2034 +APP_BASE_NAME=${0##*/} +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD=maximum + +warn () { + echo "$*" +} >&2 + +die () { + echo + echo "$*" + echo + exit 1 +} >&2 + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD=$JAVA_HOME/jre/sh/java + else + JAVACMD=$JAVA_HOME/bin/java + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD=java + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC3045 + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC3045 + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac +fi + +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + + # Now convert the arguments - kludge to limit ourselves to /bin/sh + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) + fi + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg + done +fi + + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Collect all arguments for the java command; +# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of +# shell script including quotes and variable substitutions, so put them in +# double quotes to make sure that they get re-expanded; and +# * put everything else in single quotes, so that it's not re-expanded. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' + +exec "$JAVACMD" "$@" diff --git a/samples/client/petstore/kotlin-model-prefix-type-mappings/gradlew.bat b/samples/client/petstore/kotlin-model-prefix-type-mappings/gradlew.bat new file mode 100644 index 0000000000..93e3f59f13 --- /dev/null +++ b/samples/client/petstore/kotlin-model-prefix-type-mappings/gradlew.bat @@ -0,0 +1,92 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%"=="" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if %ERRORLEVEL% equ 0 goto execute + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if %ERRORLEVEL% equ 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! +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/samples/client/petstore/kotlin-model-prefix-type-mappings/settings.gradle b/samples/client/petstore/kotlin-model-prefix-type-mappings/settings.gradle new file mode 100644 index 0000000000..4b38a2a52a --- /dev/null +++ b/samples/client/petstore/kotlin-model-prefix-type-mappings/settings.gradle @@ -0,0 +1,2 @@ + +rootProject.name = 'kotlin-client-prefix-mapping' diff --git a/samples/client/petstore/kotlin-model-prefix-type-mappings/src/main/kotlin/org/openapitools/client/apis/FakeApi.kt b/samples/client/petstore/kotlin-model-prefix-type-mappings/src/main/kotlin/org/openapitools/client/apis/FakeApi.kt new file mode 100644 index 0000000000..d860d65499 --- /dev/null +++ b/samples/client/petstore/kotlin-model-prefix-type-mappings/src/main/kotlin/org/openapitools/client/apis/FakeApi.kt @@ -0,0 +1,24 @@ +package org.openapitools.client.apis + +import org.openapitools.client.infrastructure.CollectionFormats.* +import retrofit2.http.* +import retrofit2.Response +import okhttp3.RequestBody +import com.google.gson.annotations.SerializedName + +import org.openapitools.client.models.ApiAnnotation + +interface FakeApi { + /** + * annotate + * + * Responses: + * - 200: OK + * + * @param apiAnnotation + * @return [Unit] + */ + @POST("fake/annotations") + suspend fun annotations(@Body apiAnnotation: ApiAnnotation): Response + +} diff --git a/samples/client/petstore/kotlin-model-prefix-type-mappings/src/main/kotlin/org/openapitools/client/apis/PetApi.kt b/samples/client/petstore/kotlin-model-prefix-type-mappings/src/main/kotlin/org/openapitools/client/apis/PetApi.kt new file mode 100644 index 0000000000..25057b5ce5 --- /dev/null +++ b/samples/client/petstore/kotlin-model-prefix-type-mappings/src/main/kotlin/org/openapitools/client/apis/PetApi.kt @@ -0,0 +1,137 @@ +package org.openapitools.client.apis + +import org.openapitools.client.infrastructure.CollectionFormats.* +import retrofit2.http.* +import retrofit2.Response +import okhttp3.RequestBody +import com.google.gson.annotations.SerializedName + +import org.openapitools.client.models.ApiApiResponse +import org.openapitools.client.models.ApiPet + +import okhttp3.MultipartBody + +interface PetApi { + /** + * Add a new pet to the store + * + * Responses: + * - 200: successful operation + * - 405: Invalid input + * + * @param apiPet Pet object that needs to be added to the store + * @return [ApiPet] + */ + @POST("pet") + suspend fun addPet(@Body apiPet: ApiPet): Response + + /** + * Deletes a pet + * + * Responses: + * - 400: Invalid pet value + * + * @param petId Pet id to delete + * @param apiKey (optional) + * @return [Unit] + */ + @DELETE("pet/{petId}") + suspend fun deletePet(@Path("petId") petId: kotlin.Long, @Header("api_key") apiKey: kotlin.String? = null): Response + + + /** + * enum for parameter status + */ + enum class StatusFindPetsByStatus(val value: kotlin.String) { + @SerializedName(value = "available") AVAILABLE("available"), + @SerializedName(value = "pending") PENDING("pending"), + @SerializedName(value = "sold") SOLD("sold") + } + + /** + * Finds Pets by status + * Multiple status values can be provided with comma separated strings + * Responses: + * - 200: successful operation + * - 400: Invalid status value + * + * @param status Status values that need to be considered for filter + * @return [kotlin.collections.List] + */ + @GET("pet/findByStatus") + suspend fun findPetsByStatus(@Query("status") status: CSVParams): Response> + + /** + * Finds Pets by tags + * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + * Responses: + * - 200: successful operation + * - 400: Invalid tag value + * + * @param tags Tags to filter by + * @return [kotlin.collections.List] + */ + @Deprecated("This api was deprecated") + @GET("pet/findByTags") + suspend fun findPetsByTags(@Query("tags") tags: CSVParams): Response> + + /** + * Find pet by ID + * Returns a single pet + * Responses: + * - 200: successful operation + * - 400: Invalid ID supplied + * - 404: Pet not found + * + * @param petId ID of pet to return + * @return [ApiPet] + */ + @GET("pet/{petId}") + suspend fun getPetById(@Path("petId") petId: kotlin.Long): Response + + /** + * Update an existing pet + * + * Responses: + * - 200: successful operation + * - 400: Invalid ID supplied + * - 404: Pet not found + * - 405: Validation exception + * + * @param apiPet Pet object that needs to be added to the store + * @return [ApiPet] + */ + @PUT("pet") + suspend fun updatePet(@Body apiPet: ApiPet): Response + + /** + * Updates a pet in the store with form data + * + * Responses: + * - 405: Invalid input + * + * @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 [Unit] + */ + @FormUrlEncoded + @POST("pet/{petId}") + suspend fun updatePetWithForm(@Path("petId") petId: kotlin.Long, @Field("name") name: kotlin.String? = null, @Field("status") status: kotlin.String? = null): Response + + /** + * uploads an image + * + * Responses: + * - 200: successful operation + * + * @param petId ID of pet to update + * @param additionalMetadata Additional data to pass to server (optional) + * @param file file to upload (optional) + * @return [ApiApiResponse] + */ + @Multipart + @POST("pet/{petId}/uploadImage") + suspend fun uploadFile(@Path("petId") petId: kotlin.Long, @Part("additionalMetadata") additionalMetadata: kotlin.String? = null, @Part file: MultipartBody.Part? = null): Response + +} diff --git a/samples/client/petstore/kotlin-model-prefix-type-mappings/src/main/kotlin/org/openapitools/client/apis/StoreApi.kt b/samples/client/petstore/kotlin-model-prefix-type-mappings/src/main/kotlin/org/openapitools/client/apis/StoreApi.kt new file mode 100644 index 0000000000..6c51720b13 --- /dev/null +++ b/samples/client/petstore/kotlin-model-prefix-type-mappings/src/main/kotlin/org/openapitools/client/apis/StoreApi.kt @@ -0,0 +1,63 @@ +package org.openapitools.client.apis + +import org.openapitools.client.infrastructure.CollectionFormats.* +import retrofit2.http.* +import retrofit2.Response +import okhttp3.RequestBody +import com.google.gson.annotations.SerializedName + +import org.openapitools.client.models.ApiOrder + +interface StoreApi { + /** + * Delete purchase order by ID + * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + * Responses: + * - 400: Invalid ID supplied + * - 404: Order not found + * + * @param orderId ID of the order that needs to be deleted + * @return [Unit] + */ + @DELETE("store/order/{orderId}") + suspend fun deleteOrder(@Path("orderId") orderId: kotlin.String): Response + + /** + * Returns pet inventories by status + * Returns a map of status codes to quantities + * Responses: + * - 200: successful operation + * + * @return [kotlin.collections.Map] + */ + @GET("store/inventory") + suspend fun getInventory(): Response> + + /** + * Find purchase order by ID + * For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions + * Responses: + * - 200: successful operation + * - 400: Invalid ID supplied + * - 404: Order not found + * + * @param orderId ID of pet that needs to be fetched + * @return [ApiOrder] + */ + @GET("store/order/{orderId}") + suspend fun getOrderById(@Path("orderId") orderId: kotlin.Long): Response + + /** + * Place an order for a pet + * + * Responses: + * - 200: successful operation + * - 400: Invalid Order + * + * @param apiOrder order placed for purchasing the pet + * @return [ApiOrder] + */ + @POST("store/order") + suspend fun placeOrder(@Body apiOrder: ApiOrder): Response + +} diff --git a/samples/client/petstore/kotlin-model-prefix-type-mappings/src/main/kotlin/org/openapitools/client/apis/UserApi.kt b/samples/client/petstore/kotlin-model-prefix-type-mappings/src/main/kotlin/org/openapitools/client/apis/UserApi.kt new file mode 100644 index 0000000000..a69b6ed3e1 --- /dev/null +++ b/samples/client/petstore/kotlin-model-prefix-type-mappings/src/main/kotlin/org/openapitools/client/apis/UserApi.kt @@ -0,0 +1,114 @@ +package org.openapitools.client.apis + +import org.openapitools.client.infrastructure.CollectionFormats.* +import retrofit2.http.* +import retrofit2.Response +import okhttp3.RequestBody +import com.google.gson.annotations.SerializedName + +import org.openapitools.client.models.ApiUser + +interface UserApi { + /** + * Create user + * This can only be done by the logged in user. + * Responses: + * - 0: successful operation + * + * @param apiUser Created user object + * @return [Unit] + */ + @POST("user") + suspend fun createUser(@Body apiUser: ApiUser): Response + + /** + * Creates list of users with given input array + * + * Responses: + * - 0: successful operation + * + * @param apiUser List of user object + * @return [Unit] + */ + @POST("user/createWithArray") + suspend fun createUsersWithArrayInput(@Body apiUser: kotlin.collections.List): Response + + /** + * Creates list of users with given input array + * + * Responses: + * - 0: successful operation + * + * @param apiUser List of user object + * @return [Unit] + */ + @POST("user/createWithList") + suspend fun createUsersWithListInput(@Body apiUser: kotlin.collections.List): Response + + /** + * Delete user + * This can only be done by the logged in user. + * Responses: + * - 400: Invalid username supplied + * - 404: User not found + * + * @param username The name that needs to be deleted + * @return [Unit] + */ + @DELETE("user/{username}") + suspend fun deleteUser(@Path("username") username: kotlin.String): Response + + /** + * Get user by user name + * + * Responses: + * - 200: successful operation + * - 400: Invalid username supplied + * - 404: User not found + * + * @param username The name that needs to be fetched. Use user1 for testing. + * @return [ApiUser] + */ + @GET("user/{username}") + suspend fun getUserByName(@Path("username") username: kotlin.String): Response + + /** + * Logs user into the system + * + * Responses: + * - 200: successful operation + * - 400: Invalid username/password supplied + * + * @param username The user name for login + * @param password The password for login in clear text + * @return [kotlin.String] + */ + @GET("user/login") + suspend fun loginUser(@Query("username") username: kotlin.String, @Query("password") password: kotlin.String): Response + + /** + * Logs out current logged in user session + * + * Responses: + * - 0: successful operation + * + * @return [Unit] + */ + @GET("user/logout") + suspend fun logoutUser(): Response + + /** + * Updated user + * This can only be done by the logged in user. + * Responses: + * - 400: Invalid user supplied + * - 404: User not found + * + * @param username name that need to be deleted + * @param apiUser Updated user object + * @return [Unit] + */ + @PUT("user/{username}") + suspend fun updateUser(@Path("username") username: kotlin.String, @Body apiUser: ApiUser): Response + +} diff --git a/samples/client/petstore/kotlin-model-prefix-type-mappings/src/main/kotlin/org/openapitools/client/auth/ApiKeyAuth.kt b/samples/client/petstore/kotlin-model-prefix-type-mappings/src/main/kotlin/org/openapitools/client/auth/ApiKeyAuth.kt new file mode 100644 index 0000000000..ddb369be5f --- /dev/null +++ b/samples/client/petstore/kotlin-model-prefix-type-mappings/src/main/kotlin/org/openapitools/client/auth/ApiKeyAuth.kt @@ -0,0 +1,50 @@ +package org.openapitools.client.auth + +import java.io.IOException +import java.net.URI +import java.net.URISyntaxException + +import okhttp3.Interceptor +import okhttp3.Response + +class ApiKeyAuth( + private val location: String = "", + private val paramName: String = "", + private var apiKey: String = "" +) : Interceptor { + + @Throws(IOException::class) + override fun intercept(chain: Interceptor.Chain): Response { + var request = chain.request() + + if ("query" == location) { + var newQuery = request.url.toUri().query + val paramValue = "$paramName=$apiKey" + if (newQuery == null) { + newQuery = paramValue + } else { + newQuery += "&$paramValue" + } + + val newUri: URI + try { + val oldUri = request.url.toUri() + newUri = URI(oldUri.scheme, oldUri.authority, + oldUri.path, newQuery, oldUri.fragment) + } catch (e: URISyntaxException) { + throw IOException(e) + } + + request = request.newBuilder().url(newUri.toURL()).build() + } else if ("header" == location) { + request = request.newBuilder() + .addHeader(paramName, apiKey) + .build() + } else if ("cookie" == location) { + request = request.newBuilder() + .addHeader("Cookie", "$paramName=$apiKey") + .build() + } + return chain.proceed(request) + } +} diff --git a/samples/client/petstore/kotlin-model-prefix-type-mappings/src/main/kotlin/org/openapitools/client/auth/OAuth.kt b/samples/client/petstore/kotlin-model-prefix-type-mappings/src/main/kotlin/org/openapitools/client/auth/OAuth.kt new file mode 100644 index 0000000000..69582551f3 --- /dev/null +++ b/samples/client/petstore/kotlin-model-prefix-type-mappings/src/main/kotlin/org/openapitools/client/auth/OAuth.kt @@ -0,0 +1,151 @@ +package org.openapitools.client.auth + +import java.net.HttpURLConnection.HTTP_UNAUTHORIZED +import java.net.HttpURLConnection.HTTP_FORBIDDEN + +import java.io.IOException + +import org.apache.oltu.oauth2.client.OAuthClient +import org.apache.oltu.oauth2.client.request.OAuthBearerClientRequest +import org.apache.oltu.oauth2.client.request.OAuthClientRequest +import org.apache.oltu.oauth2.client.request.OAuthClientRequest.AuthenticationRequestBuilder +import org.apache.oltu.oauth2.client.request.OAuthClientRequest.TokenRequestBuilder +import org.apache.oltu.oauth2.common.exception.OAuthProblemException +import org.apache.oltu.oauth2.common.exception.OAuthSystemException +import org.apache.oltu.oauth2.common.message.types.GrantType +import org.apache.oltu.oauth2.common.token.BasicOAuthToken + +import okhttp3.Interceptor +import okhttp3.OkHttpClient +import okhttp3.Response + +class OAuth( + client: OkHttpClient, + var tokenRequestBuilder: TokenRequestBuilder +) : Interceptor { + + interface AccessTokenListener { + fun notify(token: BasicOAuthToken) + } + + private var oauthClient: OAuthClient = OAuthClient(OAuthOkHttpClient(client)) + + @Volatile + private var accessToken: String? = null + var authenticationRequestBuilder: AuthenticationRequestBuilder? = null + private var accessTokenListener: AccessTokenListener? = null + + constructor( + requestBuilder: TokenRequestBuilder + ) : this( + OkHttpClient(), + requestBuilder + ) + + constructor( + flow: OAuthFlow, + authorizationUrl: String, + tokenUrl: String, + scopes: String + ) : this( + OAuthClientRequest.tokenLocation(tokenUrl).setScope(scopes) + ) { + setFlow(flow) + authenticationRequestBuilder = OAuthClientRequest.authorizationLocation(authorizationUrl) + } + + fun setFlow(flow: OAuthFlow) { + when (flow) { + OAuthFlow.accessCode, OAuthFlow.implicit -> + tokenRequestBuilder.setGrantType(GrantType.AUTHORIZATION_CODE) + OAuthFlow.password -> + tokenRequestBuilder.setGrantType(GrantType.PASSWORD) + OAuthFlow.application -> + tokenRequestBuilder.setGrantType(GrantType.CLIENT_CREDENTIALS) + } + } + + @Throws(IOException::class) + override fun intercept(chain: Interceptor.Chain): Response { + return retryingIntercept(chain, true) + } + + @Throws(IOException::class) + private fun retryingIntercept(chain: Interceptor.Chain, updateTokenAndRetryOnAuthorizationFailure: Boolean): Response { + var request = chain.request() + + // If the request already have an authorization (eg. Basic auth), do nothing + if (request.header("Authorization") != null) { + return chain.proceed(request) + } + + // If first time, get the token + val oAuthRequest: OAuthClientRequest + if (accessToken == null) { + updateAccessToken(null) + } + + if (accessToken != null) { + // Build the request + val rb = request.newBuilder() + + val requestAccessToken = accessToken + try { + oAuthRequest = OAuthBearerClientRequest(request.url.toString()) + .setAccessToken(requestAccessToken) + .buildHeaderMessage() + } catch (e: OAuthSystemException) { + throw IOException(e) + } + + oAuthRequest.headers.entries.forEach { header -> + rb.addHeader(header.key, header.value) + } + rb.url(oAuthRequest.locationUri) + + //Execute the request + val response = chain.proceed(rb.build()) + + // 401/403 most likely indicates that access token has expired. Unless it happens two times in a row. + if ((response.code == HTTP_UNAUTHORIZED || response.code == HTTP_FORBIDDEN) && updateTokenAndRetryOnAuthorizationFailure) { + try { + if (updateAccessToken(requestAccessToken)) { + response.body?.close() + return retryingIntercept(chain, false) + } + } catch (e: Exception) { + response.body?.close() + throw e + } + } + return response + } else { + return chain.proceed(chain.request()) + } + } + + /** + * Returns true if the access token has been updated + */ + @Throws(IOException::class) + @Synchronized + fun updateAccessToken(requestAccessToken: String?): Boolean { + if (accessToken == null || accessToken.equals(requestAccessToken)) { + return try { + val accessTokenResponse = oauthClient.accessToken(this.tokenRequestBuilder.buildBodyMessage()) + if (accessTokenResponse != null && accessTokenResponse.accessToken != null) { + accessToken = accessTokenResponse.accessToken + accessTokenListener?.notify(accessTokenResponse.oAuthToken as BasicOAuthToken) + !accessToken.equals(requestAccessToken) + } else { + false + } + } catch (e: OAuthSystemException) { + throw IOException(e) + } catch (e: OAuthProblemException) { + throw IOException(e) + } + } + return true + } +} diff --git a/samples/client/petstore/kotlin-model-prefix-type-mappings/src/main/kotlin/org/openapitools/client/auth/OAuthFlow.kt b/samples/client/petstore/kotlin-model-prefix-type-mappings/src/main/kotlin/org/openapitools/client/auth/OAuthFlow.kt new file mode 100644 index 0000000000..bcada9b7a6 --- /dev/null +++ b/samples/client/petstore/kotlin-model-prefix-type-mappings/src/main/kotlin/org/openapitools/client/auth/OAuthFlow.kt @@ -0,0 +1,5 @@ +package org.openapitools.client.auth + +enum class OAuthFlow { + accessCode, implicit, password, application +} diff --git a/samples/client/petstore/kotlin-model-prefix-type-mappings/src/main/kotlin/org/openapitools/client/auth/OAuthOkHttpClient.kt b/samples/client/petstore/kotlin-model-prefix-type-mappings/src/main/kotlin/org/openapitools/client/auth/OAuthOkHttpClient.kt new file mode 100644 index 0000000000..6680059d05 --- /dev/null +++ b/samples/client/petstore/kotlin-model-prefix-type-mappings/src/main/kotlin/org/openapitools/client/auth/OAuthOkHttpClient.kt @@ -0,0 +1,61 @@ +package org.openapitools.client.auth + +import java.io.IOException + +import org.apache.oltu.oauth2.client.HttpClient +import org.apache.oltu.oauth2.client.request.OAuthClientRequest +import org.apache.oltu.oauth2.client.response.OAuthClientResponse +import org.apache.oltu.oauth2.client.response.OAuthClientResponseFactory +import org.apache.oltu.oauth2.common.exception.OAuthProblemException +import org.apache.oltu.oauth2.common.exception.OAuthSystemException + +import okhttp3.OkHttpClient +import okhttp3.Request +import okhttp3.MediaType.Companion.toMediaTypeOrNull +import okhttp3.RequestBody +import okhttp3.RequestBody.Companion.toRequestBody + + +class OAuthOkHttpClient( + private var client: OkHttpClient = OkHttpClient() +) : HttpClient { + + @Throws(OAuthSystemException::class, OAuthProblemException::class) + override fun execute( + request: OAuthClientRequest, + headers: Map?, + requestMethod: String, + responseClass: Class?): T { + + var mediaType = "application/json".toMediaTypeOrNull() + val requestBuilder = Request.Builder().url(request.locationUri) + + headers?.forEach { entry -> + if (entry.key.equals("Content-Type", true)) { + mediaType = entry.value.toMediaTypeOrNull() + } else { + requestBuilder.addHeader(entry.key, entry.value) + } + } + + val body: RequestBody? = if (request.body != null) request.body.toRequestBody(mediaType) else null + requestBuilder.method(requestMethod, body) + + try { + val response = client.newCall(requestBuilder.build()).execute() + return OAuthClientResponseFactory.createCustomResponse( + response.body?.string(), + response.body?.contentType()?.toString(), + response.code, + response.headers.toMultimap(), + responseClass) + } catch (e: IOException) { + throw OAuthSystemException(e) + } + } + + override fun shutdown() { + // Nothing to do here + } + +} diff --git a/samples/client/petstore/kotlin-model-prefix-type-mappings/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt b/samples/client/petstore/kotlin-model-prefix-type-mappings/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt new file mode 100644 index 0000000000..891cb7c59d --- /dev/null +++ b/samples/client/petstore/kotlin-model-prefix-type-mappings/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt @@ -0,0 +1,223 @@ +package org.openapitools.client.infrastructure + +import org.apache.oltu.oauth2.client.request.OAuthClientRequest.AuthenticationRequestBuilder +import org.apache.oltu.oauth2.client.request.OAuthClientRequest.TokenRequestBuilder +import org.openapitools.client.auth.OAuth +import org.openapitools.client.auth.OAuth.AccessTokenListener +import org.openapitools.client.auth.OAuthFlow +import org.openapitools.client.auth.ApiKeyAuth + +import okhttp3.Call +import okhttp3.Interceptor +import okhttp3.OkHttpClient +import retrofit2.Retrofit +import okhttp3.logging.HttpLoggingInterceptor +import retrofit2.Converter +import retrofit2.CallAdapter +import retrofit2.converter.scalars.ScalarsConverterFactory +import com.google.gson.Gson +import com.google.gson.GsonBuilder +import retrofit2.converter.gson.GsonConverterFactory + + +class ApiClient( + private var baseUrl: String = defaultBasePath, + private val okHttpClientBuilder: OkHttpClient.Builder? = null, + private val serializerBuilder: GsonBuilder = Serializer.gsonBuilder, + private val callFactory : Call.Factory? = null, + private val callAdapterFactories: List = listOf( + ), + private val converterFactories: List = listOf( + ScalarsConverterFactory.create(), + GsonConverterFactory.create(serializerBuilder.create()), + ) +) { + private val apiAuthorizations = mutableMapOf() + var logger: ((String) -> Unit)? = null + + private val retrofitBuilder: Retrofit.Builder by lazy { + Retrofit.Builder() + .baseUrl(baseUrl) + .apply { + callAdapterFactories.forEach { + addCallAdapterFactory(it) + } + } + .apply { + converterFactories.forEach { + addConverterFactory(it) + } + } + } + + private val clientBuilder: OkHttpClient.Builder by lazy { + okHttpClientBuilder ?: defaultClientBuilder + } + + private val defaultClientBuilder: OkHttpClient.Builder by lazy { + OkHttpClient() + .newBuilder() + .addInterceptor(HttpLoggingInterceptor { message -> logger?.invoke(message) } + .apply { level = HttpLoggingInterceptor.Level.BODY } + ) + } + + init { + normalizeBaseUrl() + } + + constructor( + baseUrl: String = defaultBasePath, + okHttpClientBuilder: OkHttpClient.Builder? = null, + serializerBuilder: GsonBuilder = Serializer.gsonBuilder, + authNames: Array + ) : this(baseUrl, okHttpClientBuilder, serializerBuilder) { + authNames.forEach { authName -> + val auth: Interceptor? = when (authName) { + "petstore_auth" -> OAuth(OAuthFlow.implicit, "http://petstore.swagger.io/api/oauth/dialog", "", "write:pets, read:pets") + + "api_key" -> ApiKeyAuth("header", "api_key") + + else -> throw RuntimeException("auth name $authName not found in available auth names") + } + if (auth != null) { + addAuthorization(authName, auth) + } + } + } + + constructor( + baseUrl: String = defaultBasePath, + okHttpClientBuilder: OkHttpClient.Builder? = null, + serializerBuilder: GsonBuilder = Serializer.gsonBuilder, + authName: String, + clientId: String, + secret: String, + username: String, + password: String + ) : this(baseUrl, okHttpClientBuilder, serializerBuilder, arrayOf(authName)) { + getTokenEndPoint() + ?.setClientId(clientId) + ?.setClientSecret(secret) + ?.setUsername(username) + ?.setPassword(password) + } + + /** + * Helper method to configure the token endpoint of the first oauth found in the apiAuthorizations (there should be only one) + * @return Token request builder + */ + fun getTokenEndPoint(): TokenRequestBuilder? { + var result: TokenRequestBuilder? = null + apiAuthorizations.values.runOnFirst { + result = tokenRequestBuilder + } + return result + } + + /** + * Helper method to configure authorization endpoint of the first oauth found in the apiAuthorizations (there should be only one) + * @return Authentication request builder + */ + fun getAuthorizationEndPoint(): AuthenticationRequestBuilder? { + var result: AuthenticationRequestBuilder? = null + apiAuthorizations.values.runOnFirst { + result = authenticationRequestBuilder + } + return result + } + + /** + * Helper method to pre-set the oauth access token of the first oauth found in the apiAuthorizations (there should be only one) + * @param accessToken Access token + * @return ApiClient + */ + fun setAccessToken(accessToken: String): ApiClient { + apiAuthorizations.values.runOnFirst { + setAccessToken(accessToken) + } + return this + } + + /** + * Helper method to configure the oauth accessCode/implicit flow parameters + * @param clientId Client ID + * @param clientSecret Client secret + * @param redirectURI Redirect URI + * @return ApiClient + */ + fun configureAuthorizationFlow(clientId: String, clientSecret: String, redirectURI: String): ApiClient { + apiAuthorizations.values.runOnFirst { + tokenRequestBuilder + .setClientId(clientId) + .setClientSecret(clientSecret) + .setRedirectURI(redirectURI) + authenticationRequestBuilder + ?.setClientId(clientId) + ?.setRedirectURI(redirectURI) + } + return this + } + + /** + * Configures a listener which is notified when a new access token is received. + * @param accessTokenListener Access token listener + * @return ApiClient + */ + fun registerAccessTokenListener(accessTokenListener: AccessTokenListener): ApiClient { + apiAuthorizations.values.runOnFirst { + registerAccessTokenListener(accessTokenListener) + } + return this + } + + /** + * Adds an authorization to be used by the client + * @param authName Authentication name + * @param authorization Authorization interceptor + * @return ApiClient + */ + fun addAuthorization(authName: String, authorization: Interceptor): ApiClient { + if (apiAuthorizations.containsKey(authName)) { + throw RuntimeException("auth name $authName already in api authorizations") + } + apiAuthorizations[authName] = authorization + clientBuilder.addInterceptor(authorization) + return this + } + + fun setLogger(logger: (String) -> Unit): ApiClient { + this.logger = logger + return this + } + + fun createService(serviceClass: Class): S { + val usedCallFactory = this.callFactory ?: clientBuilder.build() + return retrofitBuilder.callFactory(usedCallFactory).build().create(serviceClass) + } + + private fun normalizeBaseUrl() { + if (!baseUrl.endsWith("/")) { + baseUrl += "/" + } + } + + private inline fun Iterable.runOnFirst(callback: U.() -> Unit) { + for (element in this) { + if (element is U) { + callback.invoke(element) + break + } + } + } + + companion object { + @JvmStatic + protected val baseUrlKey = "org.openapitools.client.baseUrl" + + @JvmStatic + val defaultBasePath: String by lazy { + System.getProperties().getProperty(baseUrlKey, "http://petstore.swagger.io/v2") + } + } +} diff --git a/samples/client/petstore/kotlin-model-prefix-type-mappings/src/main/kotlin/org/openapitools/client/infrastructure/ByteArrayAdapter.kt b/samples/client/petstore/kotlin-model-prefix-type-mappings/src/main/kotlin/org/openapitools/client/infrastructure/ByteArrayAdapter.kt new file mode 100644 index 0000000000..6120b08192 --- /dev/null +++ b/samples/client/petstore/kotlin-model-prefix-type-mappings/src/main/kotlin/org/openapitools/client/infrastructure/ByteArrayAdapter.kt @@ -0,0 +1,33 @@ +package org.openapitools.client.infrastructure + +import com.google.gson.TypeAdapter +import com.google.gson.stream.JsonReader +import com.google.gson.stream.JsonWriter +import com.google.gson.stream.JsonToken.NULL +import java.io.IOException + +class ByteArrayAdapter : TypeAdapter() { + @Throws(IOException::class) + override fun write(out: JsonWriter?, value: ByteArray?) { + if (value == null) { + out?.nullValue() + } else { + out?.value(String(value)) + } + } + + @Throws(IOException::class) + override fun read(out: JsonReader?): ByteArray? { + out ?: return null + + when (out.peek()) { + NULL -> { + out.nextNull() + return null + } + else -> { + return out.nextString().toByteArray() + } + } + } +} diff --git a/samples/client/petstore/kotlin-model-prefix-type-mappings/src/main/kotlin/org/openapitools/client/infrastructure/CollectionFormats.kt b/samples/client/petstore/kotlin-model-prefix-type-mappings/src/main/kotlin/org/openapitools/client/infrastructure/CollectionFormats.kt new file mode 100644 index 0000000000..7f404da69e --- /dev/null +++ b/samples/client/petstore/kotlin-model-prefix-type-mappings/src/main/kotlin/org/openapitools/client/infrastructure/CollectionFormats.kt @@ -0,0 +1,56 @@ +package org.openapitools.client.infrastructure + +class CollectionFormats { + + open class CSVParams { + + var params: List + + constructor(params: List) { + this.params = params + } + + constructor(vararg params: String) { + this.params = listOf(*params) + } + + override fun toString(): String { + return params.joinToString(",") + } + } + + open class SSVParams : CSVParams { + + constructor(params: List) : super(params) + + constructor(vararg params: String) : super(*params) + + override fun toString(): String { + return params.joinToString(" ") + } + } + + class TSVParams : CSVParams { + + constructor(params: List) : super(params) + + constructor(vararg params: String) : super(*params) + + override fun toString(): String { + return params.joinToString("\t") + } + } + + class PIPESParams : CSVParams { + + constructor(params: List) : super(params) + + constructor(vararg params: String) : super(*params) + + override fun toString(): String { + return params.joinToString("|") + } + } + + class SPACEParams : SSVParams() +} diff --git a/samples/client/petstore/kotlin-model-prefix-type-mappings/src/main/kotlin/org/openapitools/client/infrastructure/LocalDateAdapter.kt b/samples/client/petstore/kotlin-model-prefix-type-mappings/src/main/kotlin/org/openapitools/client/infrastructure/LocalDateAdapter.kt new file mode 100644 index 0000000000..30ef669718 --- /dev/null +++ b/samples/client/petstore/kotlin-model-prefix-type-mappings/src/main/kotlin/org/openapitools/client/infrastructure/LocalDateAdapter.kt @@ -0,0 +1,35 @@ +package org.openapitools.client.infrastructure + +import com.google.gson.TypeAdapter +import com.google.gson.stream.JsonReader +import com.google.gson.stream.JsonWriter +import com.google.gson.stream.JsonToken.NULL +import java.io.IOException +import java.time.LocalDate +import java.time.format.DateTimeFormatter + +class LocalDateAdapter(private val formatter: DateTimeFormatter = DateTimeFormatter.ISO_LOCAL_DATE) : TypeAdapter() { + @Throws(IOException::class) + override fun write(out: JsonWriter?, value: LocalDate?) { + if (value == null) { + out?.nullValue() + } else { + out?.value(formatter.format(value)) + } + } + + @Throws(IOException::class) + override fun read(out: JsonReader?): LocalDate? { + out ?: return null + + when (out.peek()) { + NULL -> { + out.nextNull() + return null + } + else -> { + return LocalDate.parse(out.nextString(), formatter) + } + } + } +} diff --git a/samples/client/petstore/kotlin-model-prefix-type-mappings/src/main/kotlin/org/openapitools/client/infrastructure/LocalDateTimeAdapter.kt b/samples/client/petstore/kotlin-model-prefix-type-mappings/src/main/kotlin/org/openapitools/client/infrastructure/LocalDateTimeAdapter.kt new file mode 100644 index 0000000000..3ad781c66c --- /dev/null +++ b/samples/client/petstore/kotlin-model-prefix-type-mappings/src/main/kotlin/org/openapitools/client/infrastructure/LocalDateTimeAdapter.kt @@ -0,0 +1,35 @@ +package org.openapitools.client.infrastructure + +import com.google.gson.TypeAdapter +import com.google.gson.stream.JsonReader +import com.google.gson.stream.JsonWriter +import com.google.gson.stream.JsonToken.NULL +import java.io.IOException +import java.time.LocalDateTime +import java.time.format.DateTimeFormatter + +class LocalDateTimeAdapter(private val formatter: DateTimeFormatter = DateTimeFormatter.ISO_LOCAL_DATE_TIME) : TypeAdapter() { + @Throws(IOException::class) + override fun write(out: JsonWriter?, value: LocalDateTime?) { + if (value == null) { + out?.nullValue() + } else { + out?.value(formatter.format(value)) + } + } + + @Throws(IOException::class) + override fun read(out: JsonReader?): LocalDateTime? { + out ?: return null + + when (out.peek()) { + NULL -> { + out.nextNull() + return null + } + else -> { + return LocalDateTime.parse(out.nextString(), formatter) + } + } + } +} diff --git a/samples/client/petstore/kotlin-model-prefix-type-mappings/src/main/kotlin/org/openapitools/client/infrastructure/OffsetDateTimeAdapter.kt b/samples/client/petstore/kotlin-model-prefix-type-mappings/src/main/kotlin/org/openapitools/client/infrastructure/OffsetDateTimeAdapter.kt new file mode 100644 index 0000000000..e615135c9c --- /dev/null +++ b/samples/client/petstore/kotlin-model-prefix-type-mappings/src/main/kotlin/org/openapitools/client/infrastructure/OffsetDateTimeAdapter.kt @@ -0,0 +1,35 @@ +package org.openapitools.client.infrastructure + +import com.google.gson.TypeAdapter +import com.google.gson.stream.JsonReader +import com.google.gson.stream.JsonWriter +import com.google.gson.stream.JsonToken.NULL +import java.io.IOException +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter + +class OffsetDateTimeAdapter(private val formatter: DateTimeFormatter = DateTimeFormatter.ISO_OFFSET_DATE_TIME) : TypeAdapter() { + @Throws(IOException::class) + override fun write(out: JsonWriter?, value: OffsetDateTime?) { + if (value == null) { + out?.nullValue() + } else { + out?.value(formatter.format(value)) + } + } + + @Throws(IOException::class) + override fun read(out: JsonReader?): OffsetDateTime? { + out ?: return null + + when (out.peek()) { + NULL -> { + out.nextNull() + return null + } + else -> { + return OffsetDateTime.parse(out.nextString(), formatter) + } + } + } +} diff --git a/samples/client/petstore/kotlin-model-prefix-type-mappings/src/main/kotlin/org/openapitools/client/infrastructure/ResponseExt.kt b/samples/client/petstore/kotlin-model-prefix-type-mappings/src/main/kotlin/org/openapitools/client/infrastructure/ResponseExt.kt new file mode 100644 index 0000000000..f9dfac6bed --- /dev/null +++ b/samples/client/petstore/kotlin-model-prefix-type-mappings/src/main/kotlin/org/openapitools/client/infrastructure/ResponseExt.kt @@ -0,0 +1,15 @@ +package org.openapitools.client.infrastructure + +import com.google.gson.GsonBuilder +import com.google.gson.JsonParseException +import retrofit2.Response + +@Throws(JsonParseException::class) +inline fun Response<*>.getErrorResponse(serializerBuilder: GsonBuilder = Serializer.gsonBuilder): T? { + val serializer = serializerBuilder.create() + val reader = errorBody()?.charStream() + if (reader != null) { + return serializer.fromJson(reader, T::class.java) + } + return null +} diff --git a/samples/client/petstore/kotlin-model-prefix-type-mappings/src/main/kotlin/org/openapitools/client/infrastructure/Serializer.kt b/samples/client/petstore/kotlin-model-prefix-type-mappings/src/main/kotlin/org/openapitools/client/infrastructure/Serializer.kt new file mode 100644 index 0000000000..6e16e4f658 --- /dev/null +++ b/samples/client/petstore/kotlin-model-prefix-type-mappings/src/main/kotlin/org/openapitools/client/infrastructure/Serializer.kt @@ -0,0 +1,22 @@ +package org.openapitools.client.infrastructure + +import com.google.gson.Gson +import com.google.gson.GsonBuilder +import java.time.LocalDate +import java.time.LocalDateTime +import java.time.OffsetDateTime +import java.util.UUID + +object Serializer { + @JvmStatic + val gsonBuilder: GsonBuilder = GsonBuilder() + .registerTypeAdapter(OffsetDateTime::class.java, OffsetDateTimeAdapter()) + .registerTypeAdapter(LocalDateTime::class.java, LocalDateTimeAdapter()) + .registerTypeAdapter(LocalDate::class.java, LocalDateAdapter()) + .registerTypeAdapter(ByteArray::class.java, ByteArrayAdapter()) + + @JvmStatic + val gson: Gson by lazy { + gsonBuilder.create() + } +} diff --git a/samples/client/petstore/kotlin-model-prefix-type-mappings/src/main/kotlin/org/openapitools/client/models/ApiAnnotation.kt b/samples/client/petstore/kotlin-model-prefix-type-mappings/src/main/kotlin/org/openapitools/client/models/ApiAnnotation.kt new file mode 100644 index 0000000000..98cc1ba5b3 --- /dev/null +++ b/samples/client/petstore/kotlin-model-prefix-type-mappings/src/main/kotlin/org/openapitools/client/models/ApiAnnotation.kt @@ -0,0 +1,34 @@ +/** + * + * Please note: + * This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * Do not edit this file manually. + * + */ + +@file:Suppress( + "ArrayInDataClass", + "EnumEntryName", + "RemoveRedundantQualifierName", + "UnusedImport" +) + +package org.openapitools.client.models + + +import com.google.gson.annotations.SerializedName + +/** + * + * + * @param id + */ + + +data class ApiAnnotation ( + + @SerializedName("id") + val id: java.util.UUID? = null + +) + diff --git a/samples/client/petstore/kotlin-model-prefix-type-mappings/src/main/kotlin/org/openapitools/client/models/ApiApiResponse.kt b/samples/client/petstore/kotlin-model-prefix-type-mappings/src/main/kotlin/org/openapitools/client/models/ApiApiResponse.kt new file mode 100644 index 0000000000..03ccc83950 --- /dev/null +++ b/samples/client/petstore/kotlin-model-prefix-type-mappings/src/main/kotlin/org/openapitools/client/models/ApiApiResponse.kt @@ -0,0 +1,42 @@ +/** + * + * Please note: + * This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * Do not edit this file manually. + * + */ + +@file:Suppress( + "ArrayInDataClass", + "EnumEntryName", + "RemoveRedundantQualifierName", + "UnusedImport" +) + +package org.openapitools.client.models + + +import com.google.gson.annotations.SerializedName + +/** + * Describes the result of uploading an image resource + * + * @param code + * @param type + * @param message + */ + + +data class ApiApiResponse ( + + @SerializedName("code") + val code: kotlin.Int? = null, + + @SerializedName("type") + val type: kotlin.String? = null, + + @SerializedName("message") + val message: kotlin.String? = null + +) + diff --git a/samples/client/petstore/kotlin-model-prefix-type-mappings/src/main/kotlin/org/openapitools/client/models/ApiCategory.kt b/samples/client/petstore/kotlin-model-prefix-type-mappings/src/main/kotlin/org/openapitools/client/models/ApiCategory.kt new file mode 100644 index 0000000000..5820e268f1 --- /dev/null +++ b/samples/client/petstore/kotlin-model-prefix-type-mappings/src/main/kotlin/org/openapitools/client/models/ApiCategory.kt @@ -0,0 +1,38 @@ +/** + * + * Please note: + * This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * Do not edit this file manually. + * + */ + +@file:Suppress( + "ArrayInDataClass", + "EnumEntryName", + "RemoveRedundantQualifierName", + "UnusedImport" +) + +package org.openapitools.client.models + + +import com.google.gson.annotations.SerializedName + +/** + * A category for a pet + * + * @param id + * @param name + */ + + +data class ApiCategory ( + + @SerializedName("id") + val id: kotlin.Long? = null, + + @SerializedName("name") + val name: kotlin.String? = null + +) + diff --git a/samples/client/petstore/kotlin-model-prefix-type-mappings/src/main/kotlin/org/openapitools/client/models/ApiOrder.kt b/samples/client/petstore/kotlin-model-prefix-type-mappings/src/main/kotlin/org/openapitools/client/models/ApiOrder.kt new file mode 100644 index 0000000000..f2044587ba --- /dev/null +++ b/samples/client/petstore/kotlin-model-prefix-type-mappings/src/main/kotlin/org/openapitools/client/models/ApiOrder.kt @@ -0,0 +1,67 @@ +/** + * + * Please note: + * This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * Do not edit this file manually. + * + */ + +@file:Suppress( + "ArrayInDataClass", + "EnumEntryName", + "RemoveRedundantQualifierName", + "UnusedImport" +) + +package org.openapitools.client.models + + +import com.google.gson.annotations.SerializedName + +/** + * An order for a pets from the pet store + * + * @param id + * @param petId + * @param quantity + * @param shipDate + * @param status Order Status + * @param complete + */ + + +data class ApiOrder ( + + @SerializedName("id") + val id: kotlin.Long? = null, + + @SerializedName("petId") + val petId: kotlin.Long? = null, + + @SerializedName("quantity") + val quantity: kotlin.Int? = null, + + @SerializedName("shipDate") + val shipDate: java.time.OffsetDateTime? = null, + + /* Order Status */ + @SerializedName("status") + val status: ApiOrder.Status? = null, + + @SerializedName("complete") + val complete: kotlin.Boolean? = false + +) { + + /** + * Order Status + * + * Values: PLACED,APPROVED,DELIVERED + */ + enum class Status(val value: kotlin.String) { + @SerializedName(value = "placed") PLACED("placed"), + @SerializedName(value = "approved") APPROVED("approved"), + @SerializedName(value = "delivered") DELIVERED("delivered"); + } +} + diff --git a/samples/client/petstore/kotlin-model-prefix-type-mappings/src/main/kotlin/org/openapitools/client/models/ApiPet.kt b/samples/client/petstore/kotlin-model-prefix-type-mappings/src/main/kotlin/org/openapitools/client/models/ApiPet.kt new file mode 100644 index 0000000000..23db537327 --- /dev/null +++ b/samples/client/petstore/kotlin-model-prefix-type-mappings/src/main/kotlin/org/openapitools/client/models/ApiPet.kt @@ -0,0 +1,70 @@ +/** + * + * Please note: + * This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * Do not edit this file manually. + * + */ + +@file:Suppress( + "ArrayInDataClass", + "EnumEntryName", + "RemoveRedundantQualifierName", + "UnusedImport" +) + +package org.openapitools.client.models + +import org.openapitools.client.models.ApiCategory +import org.openapitools.client.models.ApiTag + +import com.google.gson.annotations.SerializedName + +/** + * A pet for sale in the pet store + * + * @param name + * @param photoUrls + * @param id + * @param category + * @param tags + * @param status pet status in the store + */ + + +data class ApiPet ( + + @SerializedName("name") + val name: kotlin.String, + + @SerializedName("photoUrls") + val photoUrls: kotlin.collections.List, + + @SerializedName("id") + val id: kotlin.Long? = null, + + @SerializedName("category") + val category: ApiCategory? = null, + + @SerializedName("tags") + val tags: kotlin.collections.List? = null, + + /* pet status in the store */ + @SerializedName("status") + @Deprecated(message = "This property is deprecated.") + val status: ApiPet.Status? = null + +) { + + /** + * pet status in the store + * + * Values: AVAILABLE,PENDING,SOLD + */ + enum class Status(val value: kotlin.String) { + @SerializedName(value = "available") AVAILABLE("available"), + @SerializedName(value = "pending") PENDING("pending"), + @SerializedName(value = "sold") SOLD("sold"); + } +} + diff --git a/samples/client/petstore/kotlin-model-prefix-type-mappings/src/main/kotlin/org/openapitools/client/models/ApiTag.kt b/samples/client/petstore/kotlin-model-prefix-type-mappings/src/main/kotlin/org/openapitools/client/models/ApiTag.kt new file mode 100644 index 0000000000..e943518f8f --- /dev/null +++ b/samples/client/petstore/kotlin-model-prefix-type-mappings/src/main/kotlin/org/openapitools/client/models/ApiTag.kt @@ -0,0 +1,38 @@ +/** + * + * Please note: + * This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * Do not edit this file manually. + * + */ + +@file:Suppress( + "ArrayInDataClass", + "EnumEntryName", + "RemoveRedundantQualifierName", + "UnusedImport" +) + +package org.openapitools.client.models + + +import com.google.gson.annotations.SerializedName + +/** + * A tag for a pet + * + * @param id + * @param name + */ + + +data class ApiTag ( + + @SerializedName("id") + val id: kotlin.Long? = null, + + @SerializedName("name") + val name: kotlin.String? = null + +) + diff --git a/samples/client/petstore/kotlin-model-prefix-type-mappings/src/main/kotlin/org/openapitools/client/models/ApiUser.kt b/samples/client/petstore/kotlin-model-prefix-type-mappings/src/main/kotlin/org/openapitools/client/models/ApiUser.kt new file mode 100644 index 0000000000..d236965b76 --- /dev/null +++ b/samples/client/petstore/kotlin-model-prefix-type-mappings/src/main/kotlin/org/openapitools/client/models/ApiUser.kt @@ -0,0 +1,63 @@ +/** + * + * Please note: + * This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * Do not edit this file manually. + * + */ + +@file:Suppress( + "ArrayInDataClass", + "EnumEntryName", + "RemoveRedundantQualifierName", + "UnusedImport" +) + +package org.openapitools.client.models + + +import com.google.gson.annotations.SerializedName + +/** + * 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 + */ + + +data class ApiUser ( + + @SerializedName("id") + val id: kotlin.Long? = null, + + @SerializedName("username") + val username: kotlin.String? = null, + + @SerializedName("firstName") + val firstName: kotlin.String? = null, + + @SerializedName("lastName") + val lastName: kotlin.String? = null, + + @SerializedName("email") + val email: kotlin.String? = null, + + @SerializedName("password") + val password: kotlin.String? = null, + + @SerializedName("phone") + val phone: kotlin.String? = null, + + /* User Status */ + @SerializedName("userStatus") + val userStatus: kotlin.Int? = null + +) + diff --git a/samples/client/petstore/kotlin-model-prefix-type-mappings/src/test/kotlin/org/openapitools/client/apis/FakeApiTest.kt b/samples/client/petstore/kotlin-model-prefix-type-mappings/src/test/kotlin/org/openapitools/client/apis/FakeApiTest.kt new file mode 100644 index 0000000000..4b0f58e03b --- /dev/null +++ b/samples/client/petstore/kotlin-model-prefix-type-mappings/src/test/kotlin/org/openapitools/client/apis/FakeApiTest.kt @@ -0,0 +1,37 @@ +/** + * + * Please note: + * This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * Do not edit this file manually. + * + */ + +@file:Suppress( + "ArrayInDataClass", + "EnumEntryName", + "RemoveRedundantQualifierName", + "UnusedImport" +) + +package org.openapitools.client.apis + +import io.kotlintest.shouldBe +import io.kotlintest.specs.ShouldSpec + +import org.openapitools.client.apis.FakeApi +import org.openapitools.client.models.ApiAnnotation + +class FakeApiTest : ShouldSpec() { + init { + // uncomment below to create an instance of FakeApi + //val apiInstance = FakeApi() + + // to test annotations + should("test annotations") { + // uncomment below to test annotations + //val apiAnnotation : ApiAnnotation = // ApiAnnotation | + //apiInstance.annotations(apiAnnotation) + } + + } +} diff --git a/samples/client/petstore/kotlin-model-prefix-type-mappings/src/test/kotlin/org/openapitools/client/apis/PetApiTest.kt b/samples/client/petstore/kotlin-model-prefix-type-mappings/src/test/kotlin/org/openapitools/client/apis/PetApiTest.kt new file mode 100644 index 0000000000..776fbdc7dc --- /dev/null +++ b/samples/client/petstore/kotlin-model-prefix-type-mappings/src/test/kotlin/org/openapitools/client/apis/PetApiTest.kt @@ -0,0 +1,98 @@ +/** + * + * Please note: + * This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * Do not edit this file manually. + * + */ + +@file:Suppress( + "ArrayInDataClass", + "EnumEntryName", + "RemoveRedundantQualifierName", + "UnusedImport" +) + +package org.openapitools.client.apis + +import io.kotlintest.shouldBe +import io.kotlintest.specs.ShouldSpec + +import org.openapitools.client.apis.PetApi +import org.openapitools.client.models.ApiApiResponse +import org.openapitools.client.models.ApiPet + +class PetApiTest : ShouldSpec() { + init { + // uncomment below to create an instance of PetApi + //val apiInstance = PetApi() + + // to test addPet + should("test addPet") { + // uncomment below to test addPet + //val apiPet : ApiPet = // ApiPet | Pet object that needs to be added to the store + //val result : ApiPet = apiInstance.addPet(apiPet) + //result shouldBe ("TODO") + } + + // to test deletePet + should("test deletePet") { + // uncomment below to test deletePet + //val petId : kotlin.Long = 789 // kotlin.Long | Pet id to delete + //val apiKey : kotlin.String = apiKey_example // kotlin.String | + //apiInstance.deletePet(petId, apiKey) + } + + // to test findPetsByStatus + should("test findPetsByStatus") { + // uncomment below to test findPetsByStatus + //val status : kotlin.collections.List = // kotlin.collections.List | Status values that need to be considered for filter + //val result : kotlin.collections.List = apiInstance.findPetsByStatus(status) + //result shouldBe ("TODO") + } + + // to test findPetsByTags + should("test findPetsByTags") { + // uncomment below to test findPetsByTags + //val tags : kotlin.collections.List = // kotlin.collections.List | Tags to filter by + //val result : kotlin.collections.List = apiInstance.findPetsByTags(tags) + //result shouldBe ("TODO") + } + + // to test getPetById + should("test getPetById") { + // uncomment below to test getPetById + //val petId : kotlin.Long = 789 // kotlin.Long | ID of pet to return + //val result : ApiPet = apiInstance.getPetById(petId) + //result shouldBe ("TODO") + } + + // to test updatePet + should("test updatePet") { + // uncomment below to test updatePet + //val apiPet : ApiPet = // ApiPet | Pet object that needs to be added to the store + //val result : ApiPet = apiInstance.updatePet(apiPet) + //result shouldBe ("TODO") + } + + // to test updatePetWithForm + should("test updatePetWithForm") { + // uncomment below to test updatePetWithForm + //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 + //apiInstance.updatePetWithForm(petId, name, status) + } + + // to test uploadFile + should("test uploadFile") { + // uncomment below to test uploadFile + //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 : RequestBody = BINARY_DATA_HERE // RequestBody | file to upload + //val result : ApiApiResponse = apiInstance.uploadFile(petId, additionalMetadata, file) + //result shouldBe ("TODO") + } + + } +} diff --git a/samples/client/petstore/kotlin-model-prefix-type-mappings/src/test/kotlin/org/openapitools/client/apis/StoreApiTest.kt b/samples/client/petstore/kotlin-model-prefix-type-mappings/src/test/kotlin/org/openapitools/client/apis/StoreApiTest.kt new file mode 100644 index 0000000000..b4463c8698 --- /dev/null +++ b/samples/client/petstore/kotlin-model-prefix-type-mappings/src/test/kotlin/org/openapitools/client/apis/StoreApiTest.kt @@ -0,0 +1,60 @@ +/** + * + * Please note: + * This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * Do not edit this file manually. + * + */ + +@file:Suppress( + "ArrayInDataClass", + "EnumEntryName", + "RemoveRedundantQualifierName", + "UnusedImport" +) + +package org.openapitools.client.apis + +import io.kotlintest.shouldBe +import io.kotlintest.specs.ShouldSpec + +import org.openapitools.client.apis.StoreApi +import org.openapitools.client.models.ApiOrder + +class StoreApiTest : ShouldSpec() { + init { + // uncomment below to create an instance of StoreApi + //val apiInstance = StoreApi() + + // to test deleteOrder + should("test deleteOrder") { + // uncomment below to test deleteOrder + //val orderId : kotlin.String = orderId_example // kotlin.String | ID of the order that needs to be deleted + //apiInstance.deleteOrder(orderId) + } + + // to test getInventory + should("test getInventory") { + // uncomment below to test getInventory + //val result : kotlin.collections.Map = apiInstance.getInventory() + //result shouldBe ("TODO") + } + + // to test getOrderById + should("test getOrderById") { + // uncomment below to test getOrderById + //val orderId : kotlin.Long = 789 // kotlin.Long | ID of pet that needs to be fetched + //val result : ApiOrder = apiInstance.getOrderById(orderId) + //result shouldBe ("TODO") + } + + // to test placeOrder + should("test placeOrder") { + // uncomment below to test placeOrder + //val apiOrder : ApiOrder = // ApiOrder | order placed for purchasing the pet + //val result : ApiOrder = apiInstance.placeOrder(apiOrder) + //result shouldBe ("TODO") + } + + } +} diff --git a/samples/client/petstore/kotlin-model-prefix-type-mappings/src/test/kotlin/org/openapitools/client/apis/UserApiTest.kt b/samples/client/petstore/kotlin-model-prefix-type-mappings/src/test/kotlin/org/openapitools/client/apis/UserApiTest.kt new file mode 100644 index 0000000000..336dbdcde0 --- /dev/null +++ b/samples/client/petstore/kotlin-model-prefix-type-mappings/src/test/kotlin/org/openapitools/client/apis/UserApiTest.kt @@ -0,0 +1,89 @@ +/** + * + * Please note: + * This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * Do not edit this file manually. + * + */ + +@file:Suppress( + "ArrayInDataClass", + "EnumEntryName", + "RemoveRedundantQualifierName", + "UnusedImport" +) + +package org.openapitools.client.apis + +import io.kotlintest.shouldBe +import io.kotlintest.specs.ShouldSpec + +import org.openapitools.client.apis.UserApi +import org.openapitools.client.models.ApiUser + +class UserApiTest : ShouldSpec() { + init { + // uncomment below to create an instance of UserApi + //val apiInstance = UserApi() + + // to test createUser + should("test createUser") { + // uncomment below to test createUser + //val apiUser : ApiUser = // ApiUser | Created user object + //apiInstance.createUser(apiUser) + } + + // to test createUsersWithArrayInput + should("test createUsersWithArrayInput") { + // uncomment below to test createUsersWithArrayInput + //val apiUser : kotlin.collections.List = // kotlin.collections.List | List of user object + //apiInstance.createUsersWithArrayInput(apiUser) + } + + // to test createUsersWithListInput + should("test createUsersWithListInput") { + // uncomment below to test createUsersWithListInput + //val apiUser : kotlin.collections.List = // kotlin.collections.List | List of user object + //apiInstance.createUsersWithListInput(apiUser) + } + + // to test deleteUser + should("test deleteUser") { + // uncomment below to test deleteUser + //val username : kotlin.String = username_example // kotlin.String | The name that needs to be deleted + //apiInstance.deleteUser(username) + } + + // to test getUserByName + should("test getUserByName") { + // uncomment below to test getUserByName + //val username : kotlin.String = username_example // kotlin.String | The name that needs to be fetched. Use user1 for testing. + //val result : ApiUser = apiInstance.getUserByName(username) + //result shouldBe ("TODO") + } + + // to test loginUser + should("test loginUser") { + // uncomment below to test loginUser + //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 + //val result : kotlin.String = apiInstance.loginUser(username, password) + //result shouldBe ("TODO") + } + + // to test logoutUser + should("test logoutUser") { + // uncomment below to test logoutUser + //apiInstance.logoutUser() + } + + // to test updateUser + should("test updateUser") { + // uncomment below to test updateUser + //val username : kotlin.String = username_example // kotlin.String | name that need to be deleted + //val apiUser : ApiUser = // ApiUser | Updated user object + //apiInstance.updateUser(username, apiUser) + } + + } +} diff --git a/samples/client/petstore/kotlin-model-prefix-type-mappings/src/test/kotlin/org/openapitools/client/models/AnnotationTest.kt b/samples/client/petstore/kotlin-model-prefix-type-mappings/src/test/kotlin/org/openapitools/client/models/AnnotationTest.kt new file mode 100644 index 0000000000..edd01dcf06 --- /dev/null +++ b/samples/client/petstore/kotlin-model-prefix-type-mappings/src/test/kotlin/org/openapitools/client/models/AnnotationTest.kt @@ -0,0 +1,35 @@ +/** + * + * Please note: + * This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * Do not edit this file manually. + * + */ + +@file:Suppress( + "ArrayInDataClass", + "EnumEntryName", + "RemoveRedundantQualifierName", + "UnusedImport" +) + +package org.openapitools.client.models + +import io.kotlintest.shouldBe +import io.kotlintest.specs.ShouldSpec + +import org.openapitools.client.models.ApiAnnotation + +class ApiAnnotationTest : ShouldSpec() { + init { + // uncomment below to create an instance of ApiAnnotation + //val modelInstance = ApiAnnotation() + + // to test the property `id` + should("test id") { + // uncomment below to test the property + //modelInstance.id shouldBe ("TODO") + } + + } +} diff --git a/samples/client/petstore/kotlin-model-prefix-type-mappings/src/test/kotlin/org/openapitools/client/models/ApiResponseTest.kt b/samples/client/petstore/kotlin-model-prefix-type-mappings/src/test/kotlin/org/openapitools/client/models/ApiResponseTest.kt new file mode 100644 index 0000000000..9289972196 --- /dev/null +++ b/samples/client/petstore/kotlin-model-prefix-type-mappings/src/test/kotlin/org/openapitools/client/models/ApiResponseTest.kt @@ -0,0 +1,47 @@ +/** + * + * Please note: + * This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * Do not edit this file manually. + * + */ + +@file:Suppress( + "ArrayInDataClass", + "EnumEntryName", + "RemoveRedundantQualifierName", + "UnusedImport" +) + +package org.openapitools.client.models + +import io.kotlintest.shouldBe +import io.kotlintest.specs.ShouldSpec + +import org.openapitools.client.models.ApiApiResponse + +class ApiApiResponseTest : ShouldSpec() { + init { + // uncomment below to create an instance of ApiApiResponse + //val modelInstance = ApiApiResponse() + + // to test the property `code` + should("test code") { + // uncomment below to test the property + //modelInstance.code shouldBe ("TODO") + } + + // to test the property `type` + should("test type") { + // uncomment below to test the property + //modelInstance.type shouldBe ("TODO") + } + + // to test the property `message` + should("test message") { + // uncomment below to test the property + //modelInstance.message shouldBe ("TODO") + } + + } +} diff --git a/samples/client/petstore/kotlin-model-prefix-type-mappings/src/test/kotlin/org/openapitools/client/models/CategoryTest.kt b/samples/client/petstore/kotlin-model-prefix-type-mappings/src/test/kotlin/org/openapitools/client/models/CategoryTest.kt new file mode 100644 index 0000000000..32ca2d030e --- /dev/null +++ b/samples/client/petstore/kotlin-model-prefix-type-mappings/src/test/kotlin/org/openapitools/client/models/CategoryTest.kt @@ -0,0 +1,41 @@ +/** + * + * Please note: + * This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * Do not edit this file manually. + * + */ + +@file:Suppress( + "ArrayInDataClass", + "EnumEntryName", + "RemoveRedundantQualifierName", + "UnusedImport" +) + +package org.openapitools.client.models + +import io.kotlintest.shouldBe +import io.kotlintest.specs.ShouldSpec + +import org.openapitools.client.models.ApiCategory + +class ApiCategoryTest : ShouldSpec() { + init { + // uncomment below to create an instance of ApiCategory + //val modelInstance = ApiCategory() + + // to test the property `id` + should("test id") { + // uncomment below to test the property + //modelInstance.id shouldBe ("TODO") + } + + // to test the property `name` + should("test name") { + // uncomment below to test the property + //modelInstance.name shouldBe ("TODO") + } + + } +} diff --git a/samples/client/petstore/kotlin-model-prefix-type-mappings/src/test/kotlin/org/openapitools/client/models/OrderTest.kt b/samples/client/petstore/kotlin-model-prefix-type-mappings/src/test/kotlin/org/openapitools/client/models/OrderTest.kt new file mode 100644 index 0000000000..4b91f4532f --- /dev/null +++ b/samples/client/petstore/kotlin-model-prefix-type-mappings/src/test/kotlin/org/openapitools/client/models/OrderTest.kt @@ -0,0 +1,65 @@ +/** + * + * Please note: + * This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * Do not edit this file manually. + * + */ + +@file:Suppress( + "ArrayInDataClass", + "EnumEntryName", + "RemoveRedundantQualifierName", + "UnusedImport" +) + +package org.openapitools.client.models + +import io.kotlintest.shouldBe +import io.kotlintest.specs.ShouldSpec + +import org.openapitools.client.models.ApiOrder + +class ApiOrderTest : ShouldSpec() { + init { + // uncomment below to create an instance of ApiOrder + //val modelInstance = ApiOrder() + + // to test the property `id` + should("test id") { + // uncomment below to test the property + //modelInstance.id shouldBe ("TODO") + } + + // to test the property `petId` + should("test petId") { + // uncomment below to test the property + //modelInstance.petId shouldBe ("TODO") + } + + // to test the property `quantity` + should("test quantity") { + // uncomment below to test the property + //modelInstance.quantity shouldBe ("TODO") + } + + // to test the property `shipDate` + should("test shipDate") { + // uncomment below to test the property + //modelInstance.shipDate shouldBe ("TODO") + } + + // to test the property `status` - Order Status + should("test status") { + // uncomment below to test the property + //modelInstance.status shouldBe ("TODO") + } + + // to test the property `complete` + should("test complete") { + // uncomment below to test the property + //modelInstance.complete shouldBe ("TODO") + } + + } +} diff --git a/samples/client/petstore/kotlin-model-prefix-type-mappings/src/test/kotlin/org/openapitools/client/models/PetTest.kt b/samples/client/petstore/kotlin-model-prefix-type-mappings/src/test/kotlin/org/openapitools/client/models/PetTest.kt new file mode 100644 index 0000000000..e551810928 --- /dev/null +++ b/samples/client/petstore/kotlin-model-prefix-type-mappings/src/test/kotlin/org/openapitools/client/models/PetTest.kt @@ -0,0 +1,67 @@ +/** + * + * Please note: + * This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * Do not edit this file manually. + * + */ + +@file:Suppress( + "ArrayInDataClass", + "EnumEntryName", + "RemoveRedundantQualifierName", + "UnusedImport" +) + +package org.openapitools.client.models + +import io.kotlintest.shouldBe +import io.kotlintest.specs.ShouldSpec + +import org.openapitools.client.models.ApiPet +import org.openapitools.client.models.ApiCategory +import org.openapitools.client.models.ApiTag + +class ApiPetTest : ShouldSpec() { + init { + // uncomment below to create an instance of ApiPet + //val modelInstance = ApiPet() + + // to test the property `name` + should("test name") { + // uncomment below to test the property + //modelInstance.name shouldBe ("TODO") + } + + // to test the property `photoUrls` + should("test photoUrls") { + // uncomment below to test the property + //modelInstance.photoUrls shouldBe ("TODO") + } + + // to test the property `id` + should("test id") { + // uncomment below to test the property + //modelInstance.id shouldBe ("TODO") + } + + // to test the property `category` + should("test category") { + // uncomment below to test the property + //modelInstance.category shouldBe ("TODO") + } + + // to test the property `tags` + should("test tags") { + // uncomment below to test the property + //modelInstance.tags shouldBe ("TODO") + } + + // to test the property `status` - pet status in the store + should("test status") { + // uncomment below to test the property + //modelInstance.status shouldBe ("TODO") + } + + } +} diff --git a/samples/client/petstore/kotlin-model-prefix-type-mappings/src/test/kotlin/org/openapitools/client/models/TagTest.kt b/samples/client/petstore/kotlin-model-prefix-type-mappings/src/test/kotlin/org/openapitools/client/models/TagTest.kt new file mode 100644 index 0000000000..44fa5d60e0 --- /dev/null +++ b/samples/client/petstore/kotlin-model-prefix-type-mappings/src/test/kotlin/org/openapitools/client/models/TagTest.kt @@ -0,0 +1,41 @@ +/** + * + * Please note: + * This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * Do not edit this file manually. + * + */ + +@file:Suppress( + "ArrayInDataClass", + "EnumEntryName", + "RemoveRedundantQualifierName", + "UnusedImport" +) + +package org.openapitools.client.models + +import io.kotlintest.shouldBe +import io.kotlintest.specs.ShouldSpec + +import org.openapitools.client.models.ApiTag + +class ApiTagTest : ShouldSpec() { + init { + // uncomment below to create an instance of ApiTag + //val modelInstance = ApiTag() + + // to test the property `id` + should("test id") { + // uncomment below to test the property + //modelInstance.id shouldBe ("TODO") + } + + // to test the property `name` + should("test name") { + // uncomment below to test the property + //modelInstance.name shouldBe ("TODO") + } + + } +} diff --git a/samples/client/petstore/kotlin-model-prefix-type-mappings/src/test/kotlin/org/openapitools/client/models/UserTest.kt b/samples/client/petstore/kotlin-model-prefix-type-mappings/src/test/kotlin/org/openapitools/client/models/UserTest.kt new file mode 100644 index 0000000000..843c31fa0e --- /dev/null +++ b/samples/client/petstore/kotlin-model-prefix-type-mappings/src/test/kotlin/org/openapitools/client/models/UserTest.kt @@ -0,0 +1,77 @@ +/** + * + * Please note: + * This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * Do not edit this file manually. + * + */ + +@file:Suppress( + "ArrayInDataClass", + "EnumEntryName", + "RemoveRedundantQualifierName", + "UnusedImport" +) + +package org.openapitools.client.models + +import io.kotlintest.shouldBe +import io.kotlintest.specs.ShouldSpec + +import org.openapitools.client.models.ApiUser + +class ApiUserTest : ShouldSpec() { + init { + // uncomment below to create an instance of ApiUser + //val modelInstance = ApiUser() + + // to test the property `id` + should("test id") { + // uncomment below to test the property + //modelInstance.id shouldBe ("TODO") + } + + // to test the property `username` + should("test username") { + // uncomment below to test the property + //modelInstance.username shouldBe ("TODO") + } + + // to test the property `firstName` + should("test firstName") { + // uncomment below to test the property + //modelInstance.firstName shouldBe ("TODO") + } + + // to test the property `lastName` + should("test lastName") { + // uncomment below to test the property + //modelInstance.lastName shouldBe ("TODO") + } + + // to test the property `email` + should("test email") { + // uncomment below to test the property + //modelInstance.email shouldBe ("TODO") + } + + // to test the property `password` + should("test password") { + // uncomment below to test the property + //modelInstance.password shouldBe ("TODO") + } + + // to test the property `phone` + should("test phone") { + // uncomment below to test the property + //modelInstance.phone shouldBe ("TODO") + } + + // to test the property `userStatus` - User Status + should("test userStatus") { + // uncomment below to test the property + //modelInstance.userStatus shouldBe ("TODO") + } + + } +}