From 4898ffa4e9a79d0c3ce609bb7667586b47ecfbdf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Armand=20M=C3=A9grot?= Date: Thu, 22 Aug 2019 15:32:07 +0200 Subject: [PATCH] [Kotlin-client] Authentication support (#3722) * Handle and document authorization for kotlin client * Regenerate clients and tests * Remove testing files --- .../resources/kotlin-client/api_doc.mustache | 24 ++- .../infrastructure/ApiClient.kt.mustache | 60 +++++++ samples/client/petstore/kotlin/docs/PetApi.md | 33 +++- .../client/petstore/kotlin/docs/StoreApi.md | 5 +- .../client/infrastructure/ApiClient.kt | 23 +++ .../kotlin/.openapi-generator/VERSION | 2 +- .../openapi3/client/petstore/kotlin/README.md | 3 + .../client/petstore/kotlin/docs/CatAllOf.md | 10 ++ .../client/petstore/kotlin/docs/DogAllOf.md | 10 ++ .../client/petstore/kotlin/docs/FakeApi.md | 73 ++++---- .../kotlin/docs/FakeClassnameTags123Api.md | 5 +- .../client/petstore/kotlin/docs/FormatTest.md | 2 +- .../petstore/kotlin/docs/InlineObject3.md | 2 +- .../client/petstore/kotlin/docs/List.md | 2 +- .../petstore/kotlin/docs/NullableClass.md | 21 +++ .../client/petstore/kotlin/docs/PetApi.md | 65 ++++--- .../petstore/kotlin/docs/SpecialModelName.md | 2 +- .../client/petstore/kotlin/docs/StoreApi.md | 9 +- .../client/petstore/kotlin/docs/UserApi.md | 14 +- .../client/apis/AnotherFakeApi.kt | 17 +- .../openapitools/client/apis/DefaultApi.kt | 17 +- .../org/openapitools/client/apis/FakeApi.kt | 113 ++++++------- .../client/apis/FakeClassnameTags123Api.kt | 17 +- .../org/openapitools/client/apis/PetApi.kt | 61 +++---- .../org/openapitools/client/apis/StoreApi.kt | 26 +-- .../org/openapitools/client/apis/UserApi.kt | 38 +++-- .../client/infrastructure/ApiClient.kt | 160 +++++++++++------- .../client/infrastructure/LocalDateAdapter.kt | 19 +++ .../infrastructure/LocalDateTimeAdapter.kt | 19 +++ .../client/infrastructure/RequestConfig.kt | 2 +- .../client/infrastructure/Serializer.kt | 12 +- .../client/infrastructure/UUIDAdapter.kt | 13 ++ .../models/AdditionalPropertiesClass.kt | 5 +- .../org/openapitools/client/models/Animal.kt | 5 +- .../openapitools/client/models/ApiResponse.kt | 6 +- .../client/models/ArrayOfArrayOfNumberOnly.kt | 4 +- .../client/models/ArrayOfNumberOnly.kt | 4 +- .../openapitools/client/models/ArrayTest.kt | 6 +- .../client/models/Capitalization.kt | 9 +- .../org/openapitools/client/models/Cat.kt | 7 +- .../openapitools/client/models/CatAllOf.kt | 26 +++ .../openapitools/client/models/Category.kt | 5 +- .../openapitools/client/models/ClassModel.kt | 4 +- .../org/openapitools/client/models/Client.kt | 4 +- .../org/openapitools/client/models/Dog.kt | 7 +- .../openapitools/client/models/DogAllOf.kt | 26 +++ .../openapitools/client/models/EnumArrays.kt | 16 +- .../openapitools/client/models/EnumClass.kt | 11 +- .../openapitools/client/models/EnumTest.kt | 40 +++-- .../client/models/FileSchemaTestClass.kt | 5 +- .../org/openapitools/client/models/Foo.kt | 4 +- .../openapitools/client/models/FormatTest.kt | 20 ++- .../client/models/HasOnlyReadOnly.kt | 5 +- .../client/models/HealthCheckResult.kt | 4 +- .../client/models/InlineObject.kt | 5 +- .../client/models/InlineObject1.kt | 5 +- .../client/models/InlineObject2.kt | 19 ++- .../client/models/InlineObject3.kt | 19 ++- .../client/models/InlineObject4.kt | 5 +- .../client/models/InlineObject5.kt | 5 +- .../client/models/InlineResponseDefault.kt | 4 +- .../org/openapitools/client/models/List.kt | 8 +- .../org/openapitools/client/models/MapTest.kt | 12 +- ...dPropertiesAndAdditionalPropertiesClass.kt | 6 +- .../client/models/Model200Response.kt | 5 +- .../org/openapitools/client/models/Name.kt | 7 +- .../client/models/NullableClass.kt | 59 +++++++ .../openapitools/client/models/NumberOnly.kt | 4 +- .../org/openapitools/client/models/Order.kt | 17 +- .../client/models/OuterComposite.kt | 6 +- .../openapitools/client/models/OuterEnum.kt | 11 +- .../client/models/OuterEnumDefaultValue.kt | 11 +- .../client/models/OuterEnumInteger.kt | 11 +- .../models/OuterEnumIntegerDefaultValue.kt | 11 +- .../org/openapitools/client/models/Pet.kt | 17 +- .../client/models/ReadOnlyFirst.kt | 5 +- .../org/openapitools/client/models/Return.kt | 4 +- .../client/models/SpecialModelname.kt | 8 +- .../org/openapitools/client/models/Tag.kt | 5 +- .../org/openapitools/client/models/User.kt | 11 +- 80 files changed, 1012 insertions(+), 370 deletions(-) create mode 100644 samples/openapi3/client/petstore/kotlin/docs/CatAllOf.md create mode 100644 samples/openapi3/client/petstore/kotlin/docs/DogAllOf.md create mode 100644 samples/openapi3/client/petstore/kotlin/docs/NullableClass.md create mode 100644 samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/infrastructure/LocalDateAdapter.kt create mode 100644 samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/infrastructure/LocalDateTimeAdapter.kt create mode 100644 samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/infrastructure/UUIDAdapter.kt create mode 100644 samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/CatAllOf.kt create mode 100644 samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/DogAllOf.kt create mode 100644 samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/NullableClass.kt diff --git a/modules/openapi-generator/src/main/resources/kotlin-client/api_doc.mustache b/modules/openapi-generator/src/main/resources/kotlin-client/api_doc.mustache index d288470ca88..09ccc14758c 100644 --- a/modules/openapi-generator/src/main/resources/kotlin-client/api_doc.mustache +++ b/modules/openapi-generator/src/main/resources/kotlin-client/api_doc.mustache @@ -54,7 +54,29 @@ Name | Type | Description | Notes ### Authorization -{{^authMethods}}No authorization required{{/authMethods}}{{#authMethods}}[{{name}}](../README.md#{{name}}){{^-last}}, {{/-last}}{{/authMethods}} +{{^authMethods}}No authorization required{{/authMethods}} +{{#authMethods}} +{{#isApiKey}} +Configure {{name}}: + ApiClient.apiKey["{{keyParamName}}"] = "" + ApiClient.apiKeyPrefix["{{keyParamName}}"] = "" +{{/isApiKey}} +{{#isBasic}} +{{^isBasicBearer}} +Configure {{name}}: + ApiClient.username = "" + ApiClient.password = "" +{{/isBasicBearer}} +{{#isBasicBearer}} +Configure {{name}}: + ApiClient.accessToken = "" +{{/isBasicBearer}} +{{/isBasic}} +{{#isOAuth}} +Configure {{name}}: + ApiClient.accessToken = "" +{{/isOAuth}} +{{/authMethods}} ### HTTP request headers diff --git a/modules/openapi-generator/src/main/resources/kotlin-client/infrastructure/ApiClient.kt.mustache b/modules/openapi-generator/src/main/resources/kotlin-client/infrastructure/ApiClient.kt.mustache index 61dda50372d..3bb9f079ac0 100644 --- a/modules/openapi-generator/src/main/resources/kotlin-client/infrastructure/ApiClient.kt.mustache +++ b/modules/openapi-generator/src/main/resources/kotlin-client/infrastructure/ApiClient.kt.mustache @@ -15,11 +15,18 @@ open class ApiClient(val baseUrl: String) { companion object { protected const val ContentType = "Content-Type" protected const val Accept = "Accept" + protected const val Authorization = "Authorization" protected const val JsonMediaType = "application/json" protected const val FormDataMediaType = "multipart/form-data" protected const val FormUrlEncMediaType = "application/x-www-form-urlencoded" protected const val XmlMediaType = "application/xml" + val apiKey: MutableMap = mutableMapOf() + val apiKeyPrefix: MutableMap = mutableMapOf() + var username: String? = null + var password: String? = null + var accessToken: String? = null + @JvmStatic val client: OkHttpClient by lazy { builder.build() @@ -65,8 +72,61 @@ open class ApiClient(val baseUrl: String) { } } + {{#hasAuthMethods}} + protected fun updateAuthParams(requestConfig: RequestConfig) { + {{#authMethods}} + {{#isApiKey}} + {{#isKeyInHeader}} + if (requestConfig.headers["{{keyParamName}}"].isNullOrEmpty()) { + {{/isKeyInHeader}} + {{#isKeyInQuery}} + if (requestConfig.query["{{keyParamName}}"].isNullOrEmpty()) { + {{/isKeyInQuery}} + if (apiKeyPrefix["{{keyParamName}}"] != null) { + {{#isKeyInHeader}} + requestConfig.headers["{{keyParamName}}"] = apiKeyPrefix["{{keyParamName}}"] + " " + apiKey["{{keyParamName}}"] + {{/isKeyInHeader}} + {{#isKeyInQuery}} + requestConfig.query["{{keyParamName}}"] = apiKeyPrefix["{{keyParamName}}"] + " " + apiKey["{{keyParamName}}"] + {{/isKeyInQuery}} + } else { + {{#isKeyInHeader}} + requestConfig.headers["{{keyParamName}}"] = apiKey["{{keyParamName}}"] + {{/isKeyInHeader}} + {{#isKeyInQuery}} + requestConfig.query["{{keyParamName}}"] = apiKey["{{keyParamName}}"] + {{/isKeyInQuery}} + } + } + {{/isApiKey}} + {{#isBasic}} + {{^isBasicBearer}} + if (requestConfig.headers[Authorization].isNullOrEmpty()) { + requestConfig.headers[Authorization] = Credentials.basic(username, password) + } + {{/isBasicBearer}} + {{#isBasicBearer}} + if (requestConfig.headers[Authorization].isNullOrEmpty()) { + requestConfig.headers[Authorization] = "Bearer " + accessToken + } + {{/isBasicBearer}} + {{/isBasic}} + {{#isOAuth}} + if (requestConfig.headers[Authorization].isNullOrEmpty()) { + requestConfig.headers[Authorization] = "Bearer " + accessToken + } + {{/isOAuth}} + {{/authMethods}} + } + {{/hasAuthMethods}} + protected inline fun request(requestConfig: RequestConfig, body : Any? = null): ApiInfrastructureResponse { val httpUrl = baseUrl.toHttpUrlOrNull() ?: throw IllegalStateException("baseUrl is invalid.") + {{#hasAuthMethods}} + + // take authMethod from operation + updateAuthParams(requestConfig) + {{/hasAuthMethods}} val url = httpUrl.newBuilder() .addPathSegments(requestConfig.path.trimStart('/')) diff --git a/samples/client/petstore/kotlin/docs/PetApi.md b/samples/client/petstore/kotlin/docs/PetApi.md index 9c09efacf7d..ea93e174527 100644 --- a/samples/client/petstore/kotlin/docs/PetApi.md +++ b/samples/client/petstore/kotlin/docs/PetApi.md @@ -51,7 +51,9 @@ null (empty response body) ### Authorization -[petstore_auth](../README.md#petstore_auth) + +Configure petstore_auth: + ApiClient.accessToken = "" ### HTTP request headers @@ -97,7 +99,9 @@ null (empty response body) ### Authorization -[petstore_auth](../README.md#petstore_auth) + +Configure petstore_auth: + ApiClient.accessToken = "" ### HTTP request headers @@ -144,7 +148,9 @@ Name | Type | Description | Notes ### Authorization -[petstore_auth](../README.md#petstore_auth) + +Configure petstore_auth: + ApiClient.accessToken = "" ### HTTP request headers @@ -191,7 +197,9 @@ Name | Type | Description | Notes ### Authorization -[petstore_auth](../README.md#petstore_auth) + +Configure petstore_auth: + ApiClient.accessToken = "" ### HTTP request headers @@ -238,7 +246,10 @@ Name | Type | Description | Notes ### Authorization -[api_key](../README.md#api_key) + +Configure api_key: + ApiClient.apiKey["api_key"] = "" + ApiClient.apiKeyPrefix["api_key"] = "" ### HTTP request headers @@ -282,7 +293,9 @@ null (empty response body) ### Authorization -[petstore_auth](../README.md#petstore_auth) + +Configure petstore_auth: + ApiClient.accessToken = "" ### HTTP request headers @@ -330,7 +343,9 @@ null (empty response body) ### Authorization -[petstore_auth](../README.md#petstore_auth) + +Configure petstore_auth: + ApiClient.accessToken = "" ### HTTP request headers @@ -379,7 +394,9 @@ Name | Type | Description | Notes ### Authorization -[petstore_auth](../README.md#petstore_auth) + +Configure petstore_auth: + ApiClient.accessToken = "" ### HTTP request headers diff --git a/samples/client/petstore/kotlin/docs/StoreApi.md b/samples/client/petstore/kotlin/docs/StoreApi.md index eed73ae300a..f4986041af8 100644 --- a/samples/client/petstore/kotlin/docs/StoreApi.md +++ b/samples/client/petstore/kotlin/docs/StoreApi.md @@ -92,7 +92,10 @@ This endpoint does not need any parameter. ### Authorization -[api_key](../README.md#api_key) + +Configure api_key: + ApiClient.apiKey["api_key"] = "" + ApiClient.apiKeyPrefix["api_key"] = "" ### HTTP request headers diff --git a/samples/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt b/samples/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt index 75a49d0fa43..e6ebe7982db 100644 --- a/samples/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt +++ b/samples/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt @@ -15,11 +15,18 @@ open class ApiClient(val baseUrl: String) { companion object { protected const val ContentType = "Content-Type" protected const val Accept = "Accept" + protected const val Authorization = "Authorization" protected const val JsonMediaType = "application/json" protected const val FormDataMediaType = "multipart/form-data" protected const val FormUrlEncMediaType = "application/x-www-form-urlencoded" protected const val XmlMediaType = "application/xml" + val apiKey: MutableMap = mutableMapOf() + val apiKeyPrefix: MutableMap = mutableMapOf() + var username: String? = null + var password: String? = null + var accessToken: String? = null + @JvmStatic val client: OkHttpClient by lazy { builder.build() @@ -65,9 +72,25 @@ open class ApiClient(val baseUrl: String) { } } + protected fun updateAuthParams(requestConfig: RequestConfig) { + if (requestConfig.headers["api_key"].isNullOrEmpty()) { + if (apiKeyPrefix["api_key"] != null) { + requestConfig.headers["api_key"] = apiKeyPrefix["api_key"] + " " + apiKey["api_key"] + } else { + requestConfig.headers["api_key"] = apiKey["api_key"] + } + } + if (requestConfig.headers[Authorization].isNullOrEmpty()) { + requestConfig.headers[Authorization] = "Bearer " + accessToken + } + } + protected inline fun request(requestConfig: RequestConfig, body : Any? = null): ApiInfrastructureResponse { val httpUrl = baseUrl.toHttpUrlOrNull() ?: throw IllegalStateException("baseUrl is invalid.") + // take authMethod from operation + updateAuthParams(requestConfig) + val url = httpUrl.newBuilder() .addPathSegments(requestConfig.path.trimStart('/')) .apply { diff --git a/samples/openapi3/client/petstore/kotlin/.openapi-generator/VERSION b/samples/openapi3/client/petstore/kotlin/.openapi-generator/VERSION index afa63656064..83a328a9227 100644 --- a/samples/openapi3/client/petstore/kotlin/.openapi-generator/VERSION +++ b/samples/openapi3/client/petstore/kotlin/.openapi-generator/VERSION @@ -1 +1 @@ -4.0.0-SNAPSHOT \ No newline at end of file +4.1.0-SNAPSHOT \ No newline at end of file diff --git a/samples/openapi3/client/petstore/kotlin/README.md b/samples/openapi3/client/petstore/kotlin/README.md index d4d33f303f1..cf1793ec2f6 100644 --- a/samples/openapi3/client/petstore/kotlin/README.md +++ b/samples/openapi3/client/petstore/kotlin/README.md @@ -85,10 +85,12 @@ Class | Method | HTTP request | Description - [org.openapitools.client.models.ArrayTest](docs/ArrayTest.md) - [org.openapitools.client.models.Capitalization](docs/Capitalization.md) - [org.openapitools.client.models.Cat](docs/Cat.md) + - [org.openapitools.client.models.CatAllOf](docs/CatAllOf.md) - [org.openapitools.client.models.Category](docs/Category.md) - [org.openapitools.client.models.ClassModel](docs/ClassModel.md) - [org.openapitools.client.models.Client](docs/Client.md) - [org.openapitools.client.models.Dog](docs/Dog.md) + - [org.openapitools.client.models.DogAllOf](docs/DogAllOf.md) - [org.openapitools.client.models.EnumArrays](docs/EnumArrays.md) - [org.openapitools.client.models.EnumClass](docs/EnumClass.md) - [org.openapitools.client.models.EnumTest](docs/EnumTest.md) @@ -109,6 +111,7 @@ Class | Method | HTTP request | Description - [org.openapitools.client.models.MixedPropertiesAndAdditionalPropertiesClass](docs/MixedPropertiesAndAdditionalPropertiesClass.md) - [org.openapitools.client.models.Model200Response](docs/Model200Response.md) - [org.openapitools.client.models.Name](docs/Name.md) + - [org.openapitools.client.models.NullableClass](docs/NullableClass.md) - [org.openapitools.client.models.NumberOnly](docs/NumberOnly.md) - [org.openapitools.client.models.Order](docs/Order.md) - [org.openapitools.client.models.OuterComposite](docs/OuterComposite.md) diff --git a/samples/openapi3/client/petstore/kotlin/docs/CatAllOf.md b/samples/openapi3/client/petstore/kotlin/docs/CatAllOf.md new file mode 100644 index 00000000000..fb8883197a1 --- /dev/null +++ b/samples/openapi3/client/petstore/kotlin/docs/CatAllOf.md @@ -0,0 +1,10 @@ + +# CatAllOf + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**declawed** | **kotlin.Boolean** | | [optional] + + + diff --git a/samples/openapi3/client/petstore/kotlin/docs/DogAllOf.md b/samples/openapi3/client/petstore/kotlin/docs/DogAllOf.md new file mode 100644 index 00000000000..6b14d5e9147 --- /dev/null +++ b/samples/openapi3/client/petstore/kotlin/docs/DogAllOf.md @@ -0,0 +1,10 @@ + +# DogAllOf + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**breed** | **kotlin.String** | | [optional] + + + diff --git a/samples/openapi3/client/petstore/kotlin/docs/FakeApi.md b/samples/openapi3/client/petstore/kotlin/docs/FakeApi.md index 52d0b1f0fb9..7ffab3ed071 100644 --- a/samples/openapi3/client/petstore/kotlin/docs/FakeApi.md +++ b/samples/openapi3/client/petstore/kotlin/docs/FakeApi.md @@ -324,7 +324,7 @@ try { Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **query** | **kotlin.String**| | [default to null] + **query** | **kotlin.String**| | **user** | [**User**](User.md)| | ### Return type @@ -412,7 +412,7 @@ val int64 : kotlin.Long = 789 // kotlin.Long | None val float : kotlin.Float = 3.4 // kotlin.Float | None val string : kotlin.String = string_example // kotlin.String | None val binary : java.io.File = BINARY_DATA_HERE // java.io.File | None -val date : java.time.LocalDateTime = 2013-10-20 // java.time.LocalDateTime | None +val date : java.time.LocalDate = 2013-10-20 // java.time.LocalDate | None val dateTime : java.time.LocalDateTime = 2013-10-20T19:20:30+01:00 // java.time.LocalDateTime | None val password : kotlin.String = password_example // kotlin.String | None val paramCallback : kotlin.String = paramCallback_example // kotlin.String | None @@ -431,20 +431,20 @@ try { Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **number** | **java.math.BigDecimal**| None | [default to null] - **double** | **kotlin.Double**| None | [default to null] - **patternWithoutDelimiter** | **kotlin.String**| None | [default to null] - **byte** | **kotlin.ByteArray**| None | [default to null] - **integer** | **kotlin.Int**| None | [optional] [default to null] - **int32** | **kotlin.Int**| None | [optional] [default to null] - **int64** | **kotlin.Long**| None | [optional] [default to null] - **float** | **kotlin.Float**| None | [optional] [default to null] - **string** | **kotlin.String**| None | [optional] [default to null] - **binary** | **java.io.File**| None | [optional] [default to null] - **date** | **java.time.LocalDateTime**| None | [optional] [default to null] - **dateTime** | **java.time.LocalDateTime**| None | [optional] [default to null] - **password** | **kotlin.String**| None | [optional] [default to null] - **paramCallback** | **kotlin.String**| None | [optional] [default to null] + **number** | **java.math.BigDecimal**| None | + **double** | **kotlin.Double**| None | + **patternWithoutDelimiter** | **kotlin.String**| None | + **byte** | **kotlin.ByteArray**| None | + **integer** | **kotlin.Int**| None | [optional] + **int32** | **kotlin.Int**| None | [optional] + **int64** | **kotlin.Long**| None | [optional] + **float** | **kotlin.Float**| None | [optional] + **string** | **kotlin.String**| None | [optional] + **binary** | **java.io.File**| None | [optional] + **date** | **java.time.LocalDate**| None | [optional] + **dateTime** | **java.time.LocalDateTime**| None | [optional] + **password** | **kotlin.String**| None | [optional] + **paramCallback** | **kotlin.String**| None | [optional] ### Return type @@ -452,7 +452,10 @@ null (empty response body) ### Authorization -[http_basic_test](../README.md#http_basic_test) + +Configure http_basic_test: + ApiClient.username = "" + ApiClient.password = "" ### HTTP request headers @@ -497,14 +500,14 @@ try { Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **enumHeaderStringArray** | [**kotlin.Array<kotlin.String>**](kotlin.String.md)| Header parameter enum test (string array) | [optional] [default to null] [enum: >, $] - **enumHeaderString** | **kotlin.String**| Header parameter enum test (string) | [optional] [default to -efg] [enum: _abc, -efg, (xyz)] - **enumQueryStringArray** | [**kotlin.Array<kotlin.String>**](kotlin.String.md)| Query parameter enum test (string array) | [optional] [default to null] [enum: >, $] - **enumQueryString** | **kotlin.String**| Query parameter enum test (string) | [optional] [default to -efg] [enum: _abc, -efg, (xyz)] - **enumQueryInteger** | **kotlin.Int**| Query parameter enum test (double) | [optional] [default to null] [enum: 1, -2] - **enumQueryDouble** | **kotlin.Double**| Query parameter enum test (double) | [optional] [default to null] [enum: 1.1, -1.2] - **enumFormStringArray** | [**kotlin.Array<kotlin.String>**](kotlin.String.md)| Form parameter enum test (string array) | [optional] [default to $] [enum: >, $] - **enumFormString** | **kotlin.String**| Form parameter enum test (string) | [optional] [default to -efg] [enum: _abc, -efg, (xyz)] + **enumHeaderStringArray** | [**kotlin.Array<kotlin.String>**](kotlin.String.md)| Header parameter enum test (string array) | [optional] [enum: >, $] + **enumHeaderString** | **kotlin.String**| Header parameter enum test (string) | [optional] [default to '-efg'] [enum: _abc, -efg, (xyz)] + **enumQueryStringArray** | [**kotlin.Array<kotlin.String>**](kotlin.String.md)| Query parameter enum test (string array) | [optional] [enum: >, $] + **enumQueryString** | **kotlin.String**| Query parameter enum test (string) | [optional] [default to '-efg'] [enum: _abc, -efg, (xyz)] + **enumQueryInteger** | **kotlin.Int**| Query parameter enum test (double) | [optional] [enum: 1, -2] + **enumQueryDouble** | **kotlin.Double**| Query parameter enum test (double) | [optional] [enum: 1.1, -1.2] + **enumFormStringArray** | [**kotlin.Array<kotlin.String>**](kotlin.String.md)| Form parameter enum test (string array) | [optional] [default to '$'] [enum: >, $] + **enumFormString** | **kotlin.String**| Form parameter enum test (string) | [optional] [default to '-efg'] [enum: _abc, -efg, (xyz)] ### Return type @@ -555,12 +558,12 @@ try { Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **requiredStringGroup** | **kotlin.Int**| Required String in group parameters | [default to null] - **requiredBooleanGroup** | **kotlin.Boolean**| Required Boolean in group parameters | [default to null] - **requiredInt64Group** | **kotlin.Long**| Required Integer in group parameters | [default to null] - **stringGroup** | **kotlin.Int**| String in group parameters | [optional] [default to null] - **booleanGroup** | **kotlin.Boolean**| Boolean in group parameters | [optional] [default to null] - **int64Group** | **kotlin.Long**| Integer in group parameters | [optional] [default to null] + **requiredStringGroup** | **kotlin.Int**| Required String in group parameters | + **requiredBooleanGroup** | **kotlin.Boolean**| Required Boolean in group parameters | + **requiredInt64Group** | **kotlin.Long**| Required Integer in group parameters | + **stringGroup** | **kotlin.Int**| String in group parameters | [optional] + **booleanGroup** | **kotlin.Boolean**| Boolean in group parameters | [optional] + **int64Group** | **kotlin.Long**| Integer in group parameters | [optional] ### Return type @@ -568,7 +571,9 @@ null (empty response body) ### Authorization -[bearer_test](../README.md#bearer_test) + +Configure bearer_test: + ApiClient.accessToken = "" ### HTTP request headers @@ -649,8 +654,8 @@ try { Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **param** | **kotlin.String**| field1 | [default to null] - **param2** | **kotlin.String**| field2 | [default to null] + **param** | **kotlin.String**| field1 | + **param2** | **kotlin.String**| field2 | ### Return type diff --git a/samples/openapi3/client/petstore/kotlin/docs/FakeClassnameTags123Api.md b/samples/openapi3/client/petstore/kotlin/docs/FakeClassnameTags123Api.md index 1569acbee64..962dfd4d2dc 100644 --- a/samples/openapi3/client/petstore/kotlin/docs/FakeClassnameTags123Api.md +++ b/samples/openapi3/client/petstore/kotlin/docs/FakeClassnameTags123Api.md @@ -47,7 +47,10 @@ Name | Type | Description | Notes ### Authorization -[api_key_query](../README.md#api_key_query) + +Configure api_key_query: + ApiClient.apiKey["api_key_query"] = "" + ApiClient.apiKeyPrefix["api_key_query"] = "" ### HTTP request headers diff --git a/samples/openapi3/client/petstore/kotlin/docs/FormatTest.md b/samples/openapi3/client/petstore/kotlin/docs/FormatTest.md index 337ef846e22..9a339982e00 100644 --- a/samples/openapi3/client/petstore/kotlin/docs/FormatTest.md +++ b/samples/openapi3/client/petstore/kotlin/docs/FormatTest.md @@ -13,7 +13,7 @@ Name | Type | Description | Notes **string** | **kotlin.String** | | [optional] **byte** | **kotlin.ByteArray** | | **binary** | [**java.io.File**](java.io.File.md) | | [optional] -**date** | [**java.time.LocalDateTime**](java.time.LocalDateTime.md) | | +**date** | [**java.time.LocalDate**](java.time.LocalDate.md) | | **dateTime** | [**java.time.LocalDateTime**](java.time.LocalDateTime.md) | | [optional] **uuid** | [**java.util.UUID**](java.util.UUID.md) | | [optional] **password** | **kotlin.String** | | diff --git a/samples/openapi3/client/petstore/kotlin/docs/InlineObject3.md b/samples/openapi3/client/petstore/kotlin/docs/InlineObject3.md index f9478db66a4..e709b0e1b89 100644 --- a/samples/openapi3/client/petstore/kotlin/docs/InlineObject3.md +++ b/samples/openapi3/client/petstore/kotlin/docs/InlineObject3.md @@ -14,7 +14,7 @@ Name | Type | Description | Notes **patternWithoutDelimiter** | **kotlin.String** | None | **byte** | **kotlin.ByteArray** | None | **binary** | [**java.io.File**](java.io.File.md) | None | [optional] -**date** | [**java.time.LocalDateTime**](java.time.LocalDateTime.md) | None | [optional] +**date** | [**java.time.LocalDate**](java.time.LocalDate.md) | None | [optional] **dateTime** | [**java.time.LocalDateTime**](java.time.LocalDateTime.md) | None | [optional] **password** | **kotlin.String** | None | [optional] **callback** | **kotlin.String** | None | [optional] diff --git a/samples/openapi3/client/petstore/kotlin/docs/List.md b/samples/openapi3/client/petstore/kotlin/docs/List.md index f426d541a40..13a09a4c414 100644 --- a/samples/openapi3/client/petstore/kotlin/docs/List.md +++ b/samples/openapi3/client/petstore/kotlin/docs/List.md @@ -4,7 +4,7 @@ ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**`123list`** | **kotlin.String** | | [optional] +**`123minusList`** | **kotlin.String** | | [optional] diff --git a/samples/openapi3/client/petstore/kotlin/docs/NullableClass.md b/samples/openapi3/client/petstore/kotlin/docs/NullableClass.md new file mode 100644 index 00000000000..6b15b13fc9b --- /dev/null +++ b/samples/openapi3/client/petstore/kotlin/docs/NullableClass.md @@ -0,0 +1,21 @@ + +# NullableClass + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**integerProp** | **kotlin.Int** | | [optional] +**numberProp** | [**java.math.BigDecimal**](java.math.BigDecimal.md) | | [optional] +**booleanProp** | **kotlin.Boolean** | | [optional] +**stringProp** | **kotlin.String** | | [optional] +**dateProp** | [**java.time.LocalDate**](java.time.LocalDate.md) | | [optional] +**datetimeProp** | [**java.time.LocalDateTime**](java.time.LocalDateTime.md) | | [optional] +**arrayNullableProp** | [**kotlin.Array<kotlin.Any>**](kotlin.Any.md) | | [optional] +**arrayAndItemsNullableProp** | [**kotlin.Array<kotlin.Any>**](kotlin.Any.md) | | [optional] +**arrayItemsNullable** | [**kotlin.Array<kotlin.Any>**](kotlin.Any.md) | | [optional] +**objectNullableProp** | [**kotlin.collections.Map<kotlin.String, kotlin.Any>**](kotlin.Any.md) | | [optional] +**objectAndItemsNullableProp** | [**kotlin.collections.Map<kotlin.String, kotlin.Any>**](kotlin.Any.md) | | [optional] +**objectItemsNullable** | [**kotlin.collections.Map<kotlin.String, kotlin.Any>**](kotlin.Any.md) | | [optional] + + + diff --git a/samples/openapi3/client/petstore/kotlin/docs/PetApi.md b/samples/openapi3/client/petstore/kotlin/docs/PetApi.md index da2cf27282c..576d2f04ca8 100644 --- a/samples/openapi3/client/petstore/kotlin/docs/PetApi.md +++ b/samples/openapi3/client/petstore/kotlin/docs/PetApi.md @@ -52,7 +52,9 @@ null (empty response body) ### Authorization -[petstore_auth](../README.md#petstore_auth) + +Configure petstore_auth: + ApiClient.accessToken = "" ### HTTP request headers @@ -89,8 +91,8 @@ try { Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **petId** | **kotlin.Long**| Pet id to delete | [default to null] - **apiKey** | **kotlin.String**| | [optional] [default to null] + **petId** | **kotlin.Long**| Pet id to delete | + **apiKey** | **kotlin.String**| | [optional] ### Return type @@ -98,7 +100,9 @@ null (empty response body) ### Authorization -[petstore_auth](../README.md#petstore_auth) + +Configure petstore_auth: + ApiClient.accessToken = "" ### HTTP request headers @@ -137,7 +141,7 @@ try { Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **status** | [**kotlin.Array<kotlin.String>**](kotlin.String.md)| Status values that need to be considered for filter | [default to null] [enum: available, pending, sold] + **status** | [**kotlin.Array<kotlin.String>**](kotlin.String.md)| Status values that need to be considered for filter | [enum: available, pending, sold] ### Return type @@ -145,7 +149,9 @@ Name | Type | Description | Notes ### Authorization -[petstore_auth](../README.md#petstore_auth) + +Configure petstore_auth: + ApiClient.accessToken = "" ### HTTP request headers @@ -184,7 +190,7 @@ try { Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **tags** | [**kotlin.Array<kotlin.String>**](kotlin.String.md)| Tags to filter by | [default to null] + **tags** | [**kotlin.Array<kotlin.String>**](kotlin.String.md)| Tags to filter by | ### Return type @@ -192,7 +198,9 @@ Name | Type | Description | Notes ### Authorization -[petstore_auth](../README.md#petstore_auth) + +Configure petstore_auth: + ApiClient.accessToken = "" ### HTTP request headers @@ -231,7 +239,7 @@ try { Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **petId** | **kotlin.Long**| ID of pet to return | [default to null] + **petId** | **kotlin.Long**| ID of pet to return | ### Return type @@ -239,7 +247,10 @@ Name | Type | Description | Notes ### Authorization -[api_key](../README.md#api_key) + +Configure api_key: + ApiClient.apiKey["api_key"] = "" + ApiClient.apiKeyPrefix["api_key"] = "" ### HTTP request headers @@ -283,7 +294,9 @@ null (empty response body) ### Authorization -[petstore_auth](../README.md#petstore_auth) + +Configure petstore_auth: + ApiClient.accessToken = "" ### HTTP request headers @@ -321,9 +334,9 @@ try { Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **petId** | **kotlin.Long**| ID of pet that needs to be updated | [default to null] - **name** | **kotlin.String**| Updated name of the pet | [optional] [default to null] - **status** | **kotlin.String**| Updated status of the pet | [optional] [default to null] + **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 @@ -331,7 +344,9 @@ null (empty response body) ### Authorization -[petstore_auth](../README.md#petstore_auth) + +Configure petstore_auth: + ApiClient.accessToken = "" ### HTTP request headers @@ -370,9 +385,9 @@ try { Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **petId** | **kotlin.Long**| ID of pet to update | [default to null] - **additionalMetadata** | **kotlin.String**| Additional data to pass to server | [optional] [default to null] - **file** | **java.io.File**| file to upload | [optional] [default to null] + **petId** | **kotlin.Long**| ID of pet to update | + **additionalMetadata** | **kotlin.String**| Additional data to pass to server | [optional] + **file** | **java.io.File**| file to upload | [optional] ### Return type @@ -380,7 +395,9 @@ Name | Type | Description | Notes ### Authorization -[petstore_auth](../README.md#petstore_auth) + +Configure petstore_auth: + ApiClient.accessToken = "" ### HTTP request headers @@ -419,9 +436,9 @@ try { Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **petId** | **kotlin.Long**| ID of pet to update | [default to null] - **requiredFile** | **java.io.File**| file to upload | [default to null] - **additionalMetadata** | **kotlin.String**| Additional data to pass to server | [optional] [default to null] + **petId** | **kotlin.Long**| ID of pet to update | + **requiredFile** | **java.io.File**| file to upload | + **additionalMetadata** | **kotlin.String**| Additional data to pass to server | [optional] ### Return type @@ -429,7 +446,9 @@ Name | Type | Description | Notes ### Authorization -[petstore_auth](../README.md#petstore_auth) + +Configure petstore_auth: + ApiClient.accessToken = "" ### HTTP request headers diff --git a/samples/openapi3/client/petstore/kotlin/docs/SpecialModelName.md b/samples/openapi3/client/petstore/kotlin/docs/SpecialModelName.md index 03cfa9b444b..282649449d9 100644 --- a/samples/openapi3/client/petstore/kotlin/docs/SpecialModelName.md +++ b/samples/openapi3/client/petstore/kotlin/docs/SpecialModelName.md @@ -4,7 +4,7 @@ ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**`$specialPropertyName`** | **kotlin.Long** | | [optional] +**dollarSpecialLeftSquareBracketPropertyPeriodNameRightSquareBracket** | **kotlin.Long** | | [optional] diff --git a/samples/openapi3/client/petstore/kotlin/docs/StoreApi.md b/samples/openapi3/client/petstore/kotlin/docs/StoreApi.md index 4735a7dc3dc..55bd8afdbc0 100644 --- a/samples/openapi3/client/petstore/kotlin/docs/StoreApi.md +++ b/samples/openapi3/client/petstore/kotlin/docs/StoreApi.md @@ -41,7 +41,7 @@ try { Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **orderId** | **kotlin.String**| ID of the order that needs to be deleted | [default to null] + **orderId** | **kotlin.String**| ID of the order that needs to be deleted | ### Return type @@ -92,7 +92,10 @@ This endpoint does not need any parameter. ### Authorization -[api_key](../README.md#api_key) + +Configure api_key: + ApiClient.apiKey["api_key"] = "" + ApiClient.apiKeyPrefix["api_key"] = "" ### HTTP request headers @@ -131,7 +134,7 @@ try { Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **orderId** | **kotlin.Long**| ID of pet that needs to be fetched | [default to null] + **orderId** | **kotlin.Long**| ID of pet that needs to be fetched | ### Return type diff --git a/samples/openapi3/client/petstore/kotlin/docs/UserApi.md b/samples/openapi3/client/petstore/kotlin/docs/UserApi.md index 9451997ed63..dbf78e81eb2 100644 --- a/samples/openapi3/client/petstore/kotlin/docs/UserApi.md +++ b/samples/openapi3/client/petstore/kotlin/docs/UserApi.md @@ -89,7 +89,7 @@ try { Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **user** | [**kotlin.Array<User>**](kotlin.Array.md)| List of user object | + **user** | [**kotlin.Array<User>**](User.md)| List of user object | ### Return type @@ -133,7 +133,7 @@ try { Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **user** | [**kotlin.Array<User>**](kotlin.Array.md)| List of user object | + **user** | [**kotlin.Array<User>**](User.md)| List of user object | ### Return type @@ -179,7 +179,7 @@ try { Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **username** | **kotlin.String**| The name that needs to be deleted | [default to null] + **username** | **kotlin.String**| The name that needs to be deleted | ### Return type @@ -224,7 +224,7 @@ try { Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **username** | **kotlin.String**| The name that needs to be fetched. Use user1 for testing. | [default to null] + **username** | **kotlin.String**| The name that needs to be fetched. Use user1 for testing. | ### Return type @@ -270,8 +270,8 @@ try { Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **username** | **kotlin.String**| The user name for login | [default to null] - **password** | **kotlin.String**| The password for login in clear text | [default to null] + **username** | **kotlin.String**| The user name for login | + **password** | **kotlin.String**| The password for login in clear text | ### Return type @@ -358,7 +358,7 @@ try { Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **username** | **kotlin.String**| name that need to be deleted | [default to null] + **username** | **kotlin.String**| name that need to be deleted | **user** | [**User**](User.md)| Updated user object | ### Return type diff --git a/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/apis/AnotherFakeApi.kt b/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/apis/AnotherFakeApi.kt index 0b2a7ce3c07..5079cdf61aa 100644 --- a/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/apis/AnotherFakeApi.kt +++ b/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/apis/AnotherFakeApi.kt @@ -2,7 +2,7 @@ * OpenAPI Petstore * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ * -* OpenAPI spec version: 1.0.0 +* The version of the OpenAPI document: 1.0.0 * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). @@ -13,7 +13,17 @@ package org.openapitools.client.apis import org.openapitools.client.models.Client -import org.openapitools.client.infrastructure.* +import org.openapitools.client.infrastructure.ApiClient +import org.openapitools.client.infrastructure.ClientException +import org.openapitools.client.infrastructure.ClientError +import org.openapitools.client.infrastructure.ServerException +import org.openapitools.client.infrastructure.ServerError +import org.openapitools.client.infrastructure.MultiValueMap +import org.openapitools.client.infrastructure.RequestConfig +import org.openapitools.client.infrastructure.RequestMethod +import org.openapitools.client.infrastructure.ResponseType +import org.openapitools.client.infrastructure.Success +import org.openapitools.client.infrastructure.toMultiValue class AnotherFakeApi(basePath: kotlin.String = "http://petstore.swagger.io:80/v2") : ApiClient(basePath) { @@ -27,7 +37,7 @@ class AnotherFakeApi(basePath: kotlin.String = "http://petstore.swagger.io:80/v2 fun call123testSpecialTags(client: Client) : Client { val localVariableBody: kotlin.Any? = client val localVariableQuery: MultiValueMap = mapOf() - val localVariableHeaders: kotlin.collections.Map = mapOf() + val localVariableHeaders: MutableMap = mutableMapOf() val localVariableConfig = RequestConfig( RequestMethod.PATCH, "/another-fake/dummy", @@ -45,7 +55,6 @@ class AnotherFakeApi(basePath: kotlin.String = "http://petstore.swagger.io:80/v2 ResponseType.Redirection -> TODO() ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") - else -> throw kotlin.IllegalStateException("Undefined ResponseType.") } } diff --git a/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/apis/DefaultApi.kt b/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/apis/DefaultApi.kt index 932f57beca8..73e12e59ab1 100644 --- a/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/apis/DefaultApi.kt +++ b/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/apis/DefaultApi.kt @@ -2,7 +2,7 @@ * OpenAPI Petstore * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ * -* OpenAPI spec version: 1.0.0 +* The version of the OpenAPI document: 1.0.0 * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). @@ -13,7 +13,17 @@ package org.openapitools.client.apis import org.openapitools.client.models.InlineResponseDefault -import org.openapitools.client.infrastructure.* +import org.openapitools.client.infrastructure.ApiClient +import org.openapitools.client.infrastructure.ClientException +import org.openapitools.client.infrastructure.ClientError +import org.openapitools.client.infrastructure.ServerException +import org.openapitools.client.infrastructure.ServerError +import org.openapitools.client.infrastructure.MultiValueMap +import org.openapitools.client.infrastructure.RequestConfig +import org.openapitools.client.infrastructure.RequestMethod +import org.openapitools.client.infrastructure.ResponseType +import org.openapitools.client.infrastructure.Success +import org.openapitools.client.infrastructure.toMultiValue class DefaultApi(basePath: kotlin.String = "http://petstore.swagger.io:80/v2") : ApiClient(basePath) { @@ -26,7 +36,7 @@ class DefaultApi(basePath: kotlin.String = "http://petstore.swagger.io:80/v2") : fun fooGet() : InlineResponseDefault { val localVariableBody: kotlin.Any? = null val localVariableQuery: MultiValueMap = mapOf() - val localVariableHeaders: kotlin.collections.Map = mapOf() + val localVariableHeaders: MutableMap = mutableMapOf() val localVariableConfig = RequestConfig( RequestMethod.GET, "/foo", @@ -44,7 +54,6 @@ class DefaultApi(basePath: kotlin.String = "http://petstore.swagger.io:80/v2") : ResponseType.Redirection -> TODO() ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") - else -> throw kotlin.IllegalStateException("Undefined ResponseType.") } } diff --git a/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/apis/FakeApi.kt b/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/apis/FakeApi.kt index 89785dfbbee..b493a0282e2 100644 --- a/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/apis/FakeApi.kt +++ b/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/apis/FakeApi.kt @@ -2,7 +2,7 @@ * OpenAPI Petstore * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ * -* OpenAPI spec version: 1.0.0 +* The version of the OpenAPI document: 1.0.0 * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). @@ -17,7 +17,17 @@ import org.openapitools.client.models.HealthCheckResult import org.openapitools.client.models.OuterComposite import org.openapitools.client.models.User -import org.openapitools.client.infrastructure.* +import org.openapitools.client.infrastructure.ApiClient +import org.openapitools.client.infrastructure.ClientException +import org.openapitools.client.infrastructure.ClientError +import org.openapitools.client.infrastructure.ServerException +import org.openapitools.client.infrastructure.ServerError +import org.openapitools.client.infrastructure.MultiValueMap +import org.openapitools.client.infrastructure.RequestConfig +import org.openapitools.client.infrastructure.RequestMethod +import org.openapitools.client.infrastructure.ResponseType +import org.openapitools.client.infrastructure.Success +import org.openapitools.client.infrastructure.toMultiValue class FakeApi(basePath: kotlin.String = "http://petstore.swagger.io:80/v2") : ApiClient(basePath) { @@ -30,7 +40,7 @@ class FakeApi(basePath: kotlin.String = "http://petstore.swagger.io:80/v2") : Ap fun fakeHealthGet() : HealthCheckResult { val localVariableBody: kotlin.Any? = null val localVariableQuery: MultiValueMap = mapOf() - val localVariableHeaders: kotlin.collections.Map = mapOf() + val localVariableHeaders: MutableMap = mutableMapOf() val localVariableConfig = RequestConfig( RequestMethod.GET, "/fake/health", @@ -48,7 +58,6 @@ class FakeApi(basePath: kotlin.String = "http://petstore.swagger.io:80/v2") : Ap ResponseType.Redirection -> TODO() ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") - else -> throw kotlin.IllegalStateException("Undefined ResponseType.") } } @@ -59,10 +68,10 @@ class FakeApi(basePath: kotlin.String = "http://petstore.swagger.io:80/v2") : Ap * @return kotlin.Boolean */ @Suppress("UNCHECKED_CAST") - fun fakeOuterBooleanSerialize(body: kotlin.Boolean) : kotlin.Boolean { + fun fakeOuterBooleanSerialize(body: kotlin.Boolean?) : kotlin.Boolean { val localVariableBody: kotlin.Any? = body val localVariableQuery: MultiValueMap = mapOf() - val localVariableHeaders: kotlin.collections.Map = mapOf() + val localVariableHeaders: MutableMap = mutableMapOf() val localVariableConfig = RequestConfig( RequestMethod.POST, "/fake/outer/boolean", @@ -80,7 +89,6 @@ class FakeApi(basePath: kotlin.String = "http://petstore.swagger.io:80/v2") : Ap ResponseType.Redirection -> TODO() ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") - else -> throw kotlin.IllegalStateException("Undefined ResponseType.") } } @@ -91,10 +99,10 @@ class FakeApi(basePath: kotlin.String = "http://petstore.swagger.io:80/v2") : Ap * @return OuterComposite */ @Suppress("UNCHECKED_CAST") - fun fakeOuterCompositeSerialize(outerComposite: OuterComposite) : OuterComposite { + fun fakeOuterCompositeSerialize(outerComposite: OuterComposite?) : OuterComposite { val localVariableBody: kotlin.Any? = outerComposite val localVariableQuery: MultiValueMap = mapOf() - val localVariableHeaders: kotlin.collections.Map = mapOf() + val localVariableHeaders: MutableMap = mutableMapOf() val localVariableConfig = RequestConfig( RequestMethod.POST, "/fake/outer/composite", @@ -112,7 +120,6 @@ class FakeApi(basePath: kotlin.String = "http://petstore.swagger.io:80/v2") : Ap ResponseType.Redirection -> TODO() ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") - else -> throw kotlin.IllegalStateException("Undefined ResponseType.") } } @@ -123,10 +130,10 @@ class FakeApi(basePath: kotlin.String = "http://petstore.swagger.io:80/v2") : Ap * @return java.math.BigDecimal */ @Suppress("UNCHECKED_CAST") - fun fakeOuterNumberSerialize(body: java.math.BigDecimal) : java.math.BigDecimal { + fun fakeOuterNumberSerialize(body: java.math.BigDecimal?) : java.math.BigDecimal { val localVariableBody: kotlin.Any? = body val localVariableQuery: MultiValueMap = mapOf() - val localVariableHeaders: kotlin.collections.Map = mapOf() + val localVariableHeaders: MutableMap = mutableMapOf() val localVariableConfig = RequestConfig( RequestMethod.POST, "/fake/outer/number", @@ -144,7 +151,6 @@ class FakeApi(basePath: kotlin.String = "http://petstore.swagger.io:80/v2") : Ap ResponseType.Redirection -> TODO() ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") - else -> throw kotlin.IllegalStateException("Undefined ResponseType.") } } @@ -155,10 +161,10 @@ class FakeApi(basePath: kotlin.String = "http://petstore.swagger.io:80/v2") : Ap * @return kotlin.String */ @Suppress("UNCHECKED_CAST") - fun fakeOuterStringSerialize(body: kotlin.String) : kotlin.String { + fun fakeOuterStringSerialize(body: kotlin.String?) : kotlin.String { val localVariableBody: kotlin.Any? = body val localVariableQuery: MultiValueMap = mapOf() - val localVariableHeaders: kotlin.collections.Map = mapOf() + val localVariableHeaders: MutableMap = mutableMapOf() val localVariableConfig = RequestConfig( RequestMethod.POST, "/fake/outer/string", @@ -176,7 +182,6 @@ class FakeApi(basePath: kotlin.String = "http://petstore.swagger.io:80/v2") : Ap ResponseType.Redirection -> TODO() ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") - else -> throw kotlin.IllegalStateException("Undefined ResponseType.") } } @@ -189,7 +194,7 @@ class FakeApi(basePath: kotlin.String = "http://petstore.swagger.io:80/v2") : Ap fun testBodyWithFileSchema(fileSchemaTestClass: FileSchemaTestClass) : Unit { val localVariableBody: kotlin.Any? = fileSchemaTestClass val localVariableQuery: MultiValueMap = mapOf() - val localVariableHeaders: kotlin.collections.Map = mapOf() + val localVariableHeaders: MutableMap = mutableMapOf() val localVariableConfig = RequestConfig( RequestMethod.PUT, "/fake/body-with-file-schema", @@ -207,7 +212,6 @@ class FakeApi(basePath: kotlin.String = "http://petstore.swagger.io:80/v2") : Ap ResponseType.Redirection -> TODO() ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") - else -> throw kotlin.IllegalStateException("Undefined ResponseType.") } } @@ -221,7 +225,7 @@ class FakeApi(basePath: kotlin.String = "http://petstore.swagger.io:80/v2") : Ap fun testBodyWithQueryParams(query: kotlin.String, user: User) : Unit { val localVariableBody: kotlin.Any? = user val localVariableQuery: MultiValueMap = mapOf("query" to listOf("$query")) - val localVariableHeaders: kotlin.collections.Map = mapOf() + val localVariableHeaders: MutableMap = mutableMapOf() val localVariableConfig = RequestConfig( RequestMethod.PUT, "/fake/body-with-query-params", @@ -239,7 +243,6 @@ class FakeApi(basePath: kotlin.String = "http://petstore.swagger.io:80/v2") : Ap ResponseType.Redirection -> TODO() ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") - else -> throw kotlin.IllegalStateException("Undefined ResponseType.") } } @@ -253,7 +256,7 @@ class FakeApi(basePath: kotlin.String = "http://petstore.swagger.io:80/v2") : Ap fun testClientModel(client: Client) : Client { val localVariableBody: kotlin.Any? = client val localVariableQuery: MultiValueMap = mapOf() - val localVariableHeaders: kotlin.collections.Map = mapOf() + val localVariableHeaders: MutableMap = mutableMapOf() val localVariableConfig = RequestConfig( RequestMethod.PATCH, "/fake", @@ -271,7 +274,6 @@ class FakeApi(basePath: kotlin.String = "http://petstore.swagger.io:80/v2") : Ap ResponseType.Redirection -> TODO() ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") - else -> throw kotlin.IllegalStateException("Undefined ResponseType.") } } @@ -282,22 +284,22 @@ class FakeApi(basePath: kotlin.String = "http://petstore.swagger.io:80/v2") : Ap * @param double None * @param patternWithoutDelimiter None * @param byte None - * @param integer None (optional, default to null) - * @param int32 None (optional, default to null) - * @param int64 None (optional, default to null) - * @param float None (optional, default to null) - * @param string None (optional, default to null) - * @param binary None (optional, default to null) - * @param date None (optional, default to null) - * @param dateTime None (optional, default to null) - * @param password None (optional, default to null) - * @param paramCallback None (optional, default to null) + * @param integer None (optional) + * @param int32 None (optional) + * @param int64 None (optional) + * @param float None (optional) + * @param string None (optional) + * @param binary None (optional) + * @param date None (optional) + * @param dateTime None (optional) + * @param password None (optional) + * @param paramCallback None (optional) * @return void */ - fun testEndpointParameters(number: java.math.BigDecimal, double: kotlin.Double, patternWithoutDelimiter: kotlin.String, byte: kotlin.ByteArray, integer: kotlin.Int, int32: kotlin.Int, int64: kotlin.Long, float: kotlin.Float, string: kotlin.String, binary: java.io.File, date: java.time.LocalDateTime, dateTime: java.time.LocalDateTime, password: kotlin.String, paramCallback: kotlin.String) : Unit { + fun testEndpointParameters(number: java.math.BigDecimal, double: kotlin.Double, patternWithoutDelimiter: kotlin.String, byte: kotlin.ByteArray, integer: kotlin.Int?, int32: kotlin.Int?, int64: kotlin.Long?, float: kotlin.Float?, string: kotlin.String?, binary: java.io.File?, date: java.time.LocalDate?, dateTime: java.time.LocalDateTime?, password: kotlin.String?, paramCallback: kotlin.String?) : Unit { val localVariableBody: kotlin.Any? = mapOf("integer" to "$integer", "int32" to "$int32", "int64" to "$int64", "number" to "$number", "float" to "$float", "double" to "$double", "string" to "$string", "pattern_without_delimiter" to "$patternWithoutDelimiter", "byte" to "$byte", "binary" to "$binary", "date" to "$date", "dateTime" to "$dateTime", "password" to "$password", "callback" to "$paramCallback") val localVariableQuery: MultiValueMap = mapOf() - val localVariableHeaders: kotlin.collections.Map = mapOf("Content-Type" to "multipart/form-data") + val localVariableHeaders: MutableMap = mutableMapOf("Content-Type" to "") val localVariableConfig = RequestConfig( RequestMethod.POST, "/fake", @@ -315,27 +317,26 @@ class FakeApi(basePath: kotlin.String = "http://petstore.swagger.io:80/v2") : Ap ResponseType.Redirection -> TODO() ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") - else -> throw kotlin.IllegalStateException("Undefined ResponseType.") } } /** * To test enum parameters * To test enum parameters - * @param enumHeaderStringArray Header parameter enum test (string array) (optional, default to null) - * @param enumHeaderString Header parameter enum test (string) (optional, default to -efg) - * @param enumQueryStringArray Query parameter enum test (string array) (optional, default to null) - * @param enumQueryString Query parameter enum test (string) (optional, default to -efg) - * @param enumQueryInteger Query parameter enum test (double) (optional, default to null) - * @param enumQueryDouble Query parameter enum test (double) (optional, default to null) - * @param enumFormStringArray Form parameter enum test (string array) (optional, default to $) - * @param enumFormString Form parameter enum test (string) (optional, default to -efg) + * @param enumHeaderStringArray Header parameter enum test (string array) (optional) + * @param enumHeaderString Header parameter enum test (string) (optional, default to '-efg') + * @param enumQueryStringArray Query parameter enum test (string array) (optional) + * @param enumQueryString Query parameter enum test (string) (optional, default to '-efg') + * @param enumQueryInteger Query parameter enum test (double) (optional) + * @param enumQueryDouble Query parameter enum test (double) (optional) + * @param enumFormStringArray Form parameter enum test (string array) (optional, default to '$') + * @param enumFormString Form parameter enum test (string) (optional, default to '-efg') * @return void */ - fun testEnumParameters(enumHeaderStringArray: kotlin.Array, enumHeaderString: kotlin.String, enumQueryStringArray: kotlin.Array, enumQueryString: kotlin.String, enumQueryInteger: kotlin.Int, enumQueryDouble: kotlin.Double, enumFormStringArray: kotlin.Array, enumFormString: kotlin.String) : Unit { + fun testEnumParameters(enumHeaderStringArray: kotlin.Array?, enumHeaderString: kotlin.String?, enumQueryStringArray: kotlin.Array?, enumQueryString: kotlin.String?, enumQueryInteger: kotlin.Int?, enumQueryDouble: kotlin.Double?, enumFormStringArray: kotlin.Array?, enumFormString: kotlin.String?) : Unit { val localVariableBody: kotlin.Any? = mapOf("enum_form_string_array" to "$enumFormStringArray", "enum_form_string" to "$enumFormString") - val localVariableQuery: MultiValueMap = mapOf("enum_query_string_array" to toMultiValue(enumQueryStringArray.toList(), "multi"), "enum_query_string" to listOf("$enumQueryString"), "enum_query_integer" to listOf("$enumQueryInteger"), "enum_query_double" to listOf("$enumQueryDouble")) - val localVariableHeaders: kotlin.collections.Map = mapOf("Content-Type" to "multipart/form-data", "enum_header_string_array" to enumHeaderStringArray.joinToString(separator = collectionDelimiter("csv")), "enum_header_string" to enumHeaderString.toString()) + val localVariableQuery: MultiValueMap = mapOf("enumQueryStringArray" to toMultiValue(enumQueryStringArray.toList(), "multi"), "enumQueryString" to listOf("$enumQueryString"), "enumQueryInteger" to listOf("$enumQueryInteger"), "enumQueryDouble" to listOf("$enumQueryDouble")) + val localVariableHeaders: MutableMap = mutableMapOf("Content-Type" to "", "enum_header_string_array" to enumHeaderStringArray.joinToString(separator = collectionDelimiter("csv")), "enum_header_string" to enumHeaderString.toString()) val localVariableConfig = RequestConfig( RequestMethod.GET, "/fake", @@ -353,7 +354,6 @@ class FakeApi(basePath: kotlin.String = "http://petstore.swagger.io:80/v2") : Ap ResponseType.Redirection -> TODO() ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") - else -> throw kotlin.IllegalStateException("Undefined ResponseType.") } } @@ -363,15 +363,15 @@ class FakeApi(basePath: kotlin.String = "http://petstore.swagger.io:80/v2") : Ap * @param requiredStringGroup Required String in group parameters * @param requiredBooleanGroup Required Boolean in group parameters * @param requiredInt64Group Required Integer in group parameters - * @param stringGroup String in group parameters (optional, default to null) - * @param booleanGroup Boolean in group parameters (optional, default to null) - * @param int64Group Integer in group parameters (optional, default to null) + * @param stringGroup String in group parameters (optional) + * @param booleanGroup Boolean in group parameters (optional) + * @param int64Group Integer in group parameters (optional) * @return void */ - fun testGroupParameters(requiredStringGroup: kotlin.Int, requiredBooleanGroup: kotlin.Boolean, requiredInt64Group: kotlin.Long, stringGroup: kotlin.Int, booleanGroup: kotlin.Boolean, int64Group: kotlin.Long) : Unit { + fun testGroupParameters(requiredStringGroup: kotlin.Int, requiredBooleanGroup: kotlin.Boolean, requiredInt64Group: kotlin.Long, stringGroup: kotlin.Int?, booleanGroup: kotlin.Boolean?, int64Group: kotlin.Long?) : Unit { val localVariableBody: kotlin.Any? = null - val localVariableQuery: MultiValueMap = mapOf("required_string_group" to listOf("$requiredStringGroup"), "required_int64_group" to listOf("$requiredInt64Group"), "string_group" to listOf("$stringGroup"), "int64_group" to listOf("$int64Group")) - val localVariableHeaders: kotlin.collections.Map = mapOf("required_boolean_group" to requiredBooleanGroup.toString(), "boolean_group" to booleanGroup.toString()) + val localVariableQuery: MultiValueMap = mapOf("requiredStringGroup" to listOf("$requiredStringGroup"), "requiredInt64Group" to listOf("$requiredInt64Group"), "stringGroup" to listOf("$stringGroup"), "int64Group" to listOf("$int64Group")) + val localVariableHeaders: MutableMap = mutableMapOf("required_boolean_group" to requiredBooleanGroup.toString(), "boolean_group" to booleanGroup.toString()) val localVariableConfig = RequestConfig( RequestMethod.DELETE, "/fake", @@ -389,7 +389,6 @@ class FakeApi(basePath: kotlin.String = "http://petstore.swagger.io:80/v2") : Ap ResponseType.Redirection -> TODO() ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") - else -> throw kotlin.IllegalStateException("Undefined ResponseType.") } } @@ -402,7 +401,7 @@ class FakeApi(basePath: kotlin.String = "http://petstore.swagger.io:80/v2") : Ap fun testInlineAdditionalProperties(requestBody: kotlin.collections.Map) : Unit { val localVariableBody: kotlin.Any? = requestBody val localVariableQuery: MultiValueMap = mapOf() - val localVariableHeaders: kotlin.collections.Map = mapOf() + val localVariableHeaders: MutableMap = mutableMapOf() val localVariableConfig = RequestConfig( RequestMethod.POST, "/fake/inline-additionalProperties", @@ -420,7 +419,6 @@ class FakeApi(basePath: kotlin.String = "http://petstore.swagger.io:80/v2") : Ap ResponseType.Redirection -> TODO() ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") - else -> throw kotlin.IllegalStateException("Undefined ResponseType.") } } @@ -434,7 +432,7 @@ class FakeApi(basePath: kotlin.String = "http://petstore.swagger.io:80/v2") : Ap fun testJsonFormData(param: kotlin.String, param2: kotlin.String) : Unit { val localVariableBody: kotlin.Any? = mapOf("param" to "$param", "param2" to "$param2") val localVariableQuery: MultiValueMap = mapOf() - val localVariableHeaders: kotlin.collections.Map = mapOf("Content-Type" to "multipart/form-data") + val localVariableHeaders: MutableMap = mutableMapOf("Content-Type" to "") val localVariableConfig = RequestConfig( RequestMethod.GET, "/fake/jsonFormData", @@ -452,7 +450,6 @@ class FakeApi(basePath: kotlin.String = "http://petstore.swagger.io:80/v2") : Ap ResponseType.Redirection -> TODO() ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") - else -> throw kotlin.IllegalStateException("Undefined ResponseType.") } } diff --git a/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/apis/FakeClassnameTags123Api.kt b/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/apis/FakeClassnameTags123Api.kt index f2cdcae77df..3d5e0162ee7 100644 --- a/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/apis/FakeClassnameTags123Api.kt +++ b/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/apis/FakeClassnameTags123Api.kt @@ -2,7 +2,7 @@ * OpenAPI Petstore * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ * -* OpenAPI spec version: 1.0.0 +* The version of the OpenAPI document: 1.0.0 * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). @@ -13,7 +13,17 @@ package org.openapitools.client.apis import org.openapitools.client.models.Client -import org.openapitools.client.infrastructure.* +import org.openapitools.client.infrastructure.ApiClient +import org.openapitools.client.infrastructure.ClientException +import org.openapitools.client.infrastructure.ClientError +import org.openapitools.client.infrastructure.ServerException +import org.openapitools.client.infrastructure.ServerError +import org.openapitools.client.infrastructure.MultiValueMap +import org.openapitools.client.infrastructure.RequestConfig +import org.openapitools.client.infrastructure.RequestMethod +import org.openapitools.client.infrastructure.ResponseType +import org.openapitools.client.infrastructure.Success +import org.openapitools.client.infrastructure.toMultiValue class FakeClassnameTags123Api(basePath: kotlin.String = "http://petstore.swagger.io:80/v2") : ApiClient(basePath) { @@ -27,7 +37,7 @@ class FakeClassnameTags123Api(basePath: kotlin.String = "http://petstore.swagger fun testClassname(client: Client) : Client { val localVariableBody: kotlin.Any? = client val localVariableQuery: MultiValueMap = mapOf() - val localVariableHeaders: kotlin.collections.Map = mapOf() + val localVariableHeaders: MutableMap = mutableMapOf() val localVariableConfig = RequestConfig( RequestMethod.PATCH, "/fake_classname_test", @@ -45,7 +55,6 @@ class FakeClassnameTags123Api(basePath: kotlin.String = "http://petstore.swagger ResponseType.Redirection -> TODO() ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") - else -> throw kotlin.IllegalStateException("Undefined ResponseType.") } } diff --git a/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/apis/PetApi.kt b/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/apis/PetApi.kt index 129807a602f..1652bcba5d5 100644 --- a/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/apis/PetApi.kt +++ b/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/apis/PetApi.kt @@ -2,7 +2,7 @@ * OpenAPI Petstore * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ * -* OpenAPI spec version: 1.0.0 +* The version of the OpenAPI document: 1.0.0 * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). @@ -14,7 +14,17 @@ package org.openapitools.client.apis import org.openapitools.client.models.ApiResponse import org.openapitools.client.models.Pet -import org.openapitools.client.infrastructure.* +import org.openapitools.client.infrastructure.ApiClient +import org.openapitools.client.infrastructure.ClientException +import org.openapitools.client.infrastructure.ClientError +import org.openapitools.client.infrastructure.ServerException +import org.openapitools.client.infrastructure.ServerError +import org.openapitools.client.infrastructure.MultiValueMap +import org.openapitools.client.infrastructure.RequestConfig +import org.openapitools.client.infrastructure.RequestMethod +import org.openapitools.client.infrastructure.ResponseType +import org.openapitools.client.infrastructure.Success +import org.openapitools.client.infrastructure.toMultiValue class PetApi(basePath: kotlin.String = "http://petstore.swagger.io:80/v2") : ApiClient(basePath) { @@ -27,7 +37,7 @@ class PetApi(basePath: kotlin.String = "http://petstore.swagger.io:80/v2") : Api fun addPet(pet: Pet) : Unit { val localVariableBody: kotlin.Any? = pet val localVariableQuery: MultiValueMap = mapOf() - val localVariableHeaders: kotlin.collections.Map = mapOf() + val localVariableHeaders: MutableMap = mutableMapOf() val localVariableConfig = RequestConfig( RequestMethod.POST, "/pet", @@ -45,7 +55,6 @@ class PetApi(basePath: kotlin.String = "http://petstore.swagger.io:80/v2") : Api ResponseType.Redirection -> TODO() ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") - else -> throw kotlin.IllegalStateException("Undefined ResponseType.") } } @@ -53,13 +62,13 @@ class PetApi(basePath: kotlin.String = "http://petstore.swagger.io:80/v2") : Api * Deletes a pet * * @param petId Pet id to delete - * @param apiKey (optional, default to null) + * @param apiKey (optional) * @return void */ - fun deletePet(petId: kotlin.Long, apiKey: kotlin.String) : Unit { + fun deletePet(petId: kotlin.Long, apiKey: kotlin.String?) : Unit { val localVariableBody: kotlin.Any? = null val localVariableQuery: MultiValueMap = mapOf() - val localVariableHeaders: kotlin.collections.Map = mapOf("api_key" to apiKey.toString()) + val localVariableHeaders: MutableMap = mutableMapOf("api_key" to apiKey.toString()) val localVariableConfig = RequestConfig( RequestMethod.DELETE, "/pet/{petId}".replace("{"+"petId"+"}", "$petId"), @@ -77,7 +86,6 @@ class PetApi(basePath: kotlin.String = "http://petstore.swagger.io:80/v2") : Api ResponseType.Redirection -> TODO() ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") - else -> throw kotlin.IllegalStateException("Undefined ResponseType.") } } @@ -91,7 +99,7 @@ class PetApi(basePath: kotlin.String = "http://petstore.swagger.io:80/v2") : Api fun findPetsByStatus(status: kotlin.Array) : kotlin.Array { val localVariableBody: kotlin.Any? = null val localVariableQuery: MultiValueMap = mapOf("status" to toMultiValue(status.toList(), "csv")) - val localVariableHeaders: kotlin.collections.Map = mapOf() + val localVariableHeaders: MutableMap = mutableMapOf() val localVariableConfig = RequestConfig( RequestMethod.GET, "/pet/findByStatus", @@ -109,7 +117,6 @@ class PetApi(basePath: kotlin.String = "http://petstore.swagger.io:80/v2") : Api ResponseType.Redirection -> TODO() ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") - else -> throw kotlin.IllegalStateException("Undefined ResponseType.") } } @@ -123,7 +130,7 @@ class PetApi(basePath: kotlin.String = "http://petstore.swagger.io:80/v2") : Api fun findPetsByTags(tags: kotlin.Array) : kotlin.Array { val localVariableBody: kotlin.Any? = null val localVariableQuery: MultiValueMap = mapOf("tags" to toMultiValue(tags.toList(), "csv")) - val localVariableHeaders: kotlin.collections.Map = mapOf() + val localVariableHeaders: MutableMap = mutableMapOf() val localVariableConfig = RequestConfig( RequestMethod.GET, "/pet/findByTags", @@ -141,7 +148,6 @@ class PetApi(basePath: kotlin.String = "http://petstore.swagger.io:80/v2") : Api ResponseType.Redirection -> TODO() ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") - else -> throw kotlin.IllegalStateException("Undefined ResponseType.") } } @@ -155,7 +161,7 @@ class PetApi(basePath: kotlin.String = "http://petstore.swagger.io:80/v2") : Api fun getPetById(petId: kotlin.Long) : Pet { val localVariableBody: kotlin.Any? = null val localVariableQuery: MultiValueMap = mapOf() - val localVariableHeaders: kotlin.collections.Map = mapOf() + val localVariableHeaders: MutableMap = mutableMapOf() val localVariableConfig = RequestConfig( RequestMethod.GET, "/pet/{petId}".replace("{"+"petId"+"}", "$petId"), @@ -173,7 +179,6 @@ class PetApi(basePath: kotlin.String = "http://petstore.swagger.io:80/v2") : Api ResponseType.Redirection -> TODO() ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") - else -> throw kotlin.IllegalStateException("Undefined ResponseType.") } } @@ -186,7 +191,7 @@ class PetApi(basePath: kotlin.String = "http://petstore.swagger.io:80/v2") : Api fun updatePet(pet: Pet) : Unit { val localVariableBody: kotlin.Any? = pet val localVariableQuery: MultiValueMap = mapOf() - val localVariableHeaders: kotlin.collections.Map = mapOf() + val localVariableHeaders: MutableMap = mutableMapOf() val localVariableConfig = RequestConfig( RequestMethod.PUT, "/pet", @@ -204,7 +209,6 @@ class PetApi(basePath: kotlin.String = "http://petstore.swagger.io:80/v2") : Api ResponseType.Redirection -> TODO() ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") - else -> throw kotlin.IllegalStateException("Undefined ResponseType.") } } @@ -212,14 +216,14 @@ class PetApi(basePath: kotlin.String = "http://petstore.swagger.io:80/v2") : Api * Updates a pet in the store with form data * * @param petId ID of pet that needs to be updated - * @param name Updated name of the pet (optional, default to null) - * @param status Updated status of the pet (optional, default to null) + * @param name Updated name of the pet (optional) + * @param status Updated status of the pet (optional) * @return void */ - fun updatePetWithForm(petId: kotlin.Long, name: kotlin.String, status: kotlin.String) : Unit { + fun updatePetWithForm(petId: kotlin.Long, name: kotlin.String?, status: kotlin.String?) : Unit { val localVariableBody: kotlin.Any? = mapOf("name" to "$name", "status" to "$status") val localVariableQuery: MultiValueMap = mapOf() - val localVariableHeaders: kotlin.collections.Map = mapOf("Content-Type" to "multipart/form-data") + val localVariableHeaders: MutableMap = mutableMapOf("Content-Type" to "") val localVariableConfig = RequestConfig( RequestMethod.POST, "/pet/{petId}".replace("{"+"petId"+"}", "$petId"), @@ -237,7 +241,6 @@ class PetApi(basePath: kotlin.String = "http://petstore.swagger.io:80/v2") : Api ResponseType.Redirection -> TODO() ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") - else -> throw kotlin.IllegalStateException("Undefined ResponseType.") } } @@ -245,15 +248,15 @@ class PetApi(basePath: kotlin.String = "http://petstore.swagger.io:80/v2") : Api * uploads an image * * @param petId ID of pet to update - * @param additionalMetadata Additional data to pass to server (optional, default to null) - * @param file file to upload (optional, default to null) + * @param additionalMetadata Additional data to pass to server (optional) + * @param file file to upload (optional) * @return ApiResponse */ @Suppress("UNCHECKED_CAST") - fun uploadFile(petId: kotlin.Long, additionalMetadata: kotlin.String, file: java.io.File) : ApiResponse { + fun uploadFile(petId: kotlin.Long, additionalMetadata: kotlin.String?, file: java.io.File?) : ApiResponse { val localVariableBody: kotlin.Any? = mapOf("additionalMetadata" to "$additionalMetadata", "file" to "$file") val localVariableQuery: MultiValueMap = mapOf() - val localVariableHeaders: kotlin.collections.Map = mapOf("Content-Type" to "multipart/form-data") + val localVariableHeaders: MutableMap = mutableMapOf("Content-Type" to "") val localVariableConfig = RequestConfig( RequestMethod.POST, "/pet/{petId}/uploadImage".replace("{"+"petId"+"}", "$petId"), @@ -271,7 +274,6 @@ class PetApi(basePath: kotlin.String = "http://petstore.swagger.io:80/v2") : Api ResponseType.Redirection -> TODO() ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") - else -> throw kotlin.IllegalStateException("Undefined ResponseType.") } } @@ -280,14 +282,14 @@ class PetApi(basePath: kotlin.String = "http://petstore.swagger.io:80/v2") : Api * * @param petId ID of pet to update * @param requiredFile file to upload - * @param additionalMetadata Additional data to pass to server (optional, default to null) + * @param additionalMetadata Additional data to pass to server (optional) * @return ApiResponse */ @Suppress("UNCHECKED_CAST") - fun uploadFileWithRequiredFile(petId: kotlin.Long, requiredFile: java.io.File, additionalMetadata: kotlin.String) : ApiResponse { + fun uploadFileWithRequiredFile(petId: kotlin.Long, requiredFile: java.io.File, additionalMetadata: kotlin.String?) : ApiResponse { val localVariableBody: kotlin.Any? = mapOf("additionalMetadata" to "$additionalMetadata", "requiredFile" to "$requiredFile") val localVariableQuery: MultiValueMap = mapOf() - val localVariableHeaders: kotlin.collections.Map = mapOf("Content-Type" to "multipart/form-data") + val localVariableHeaders: MutableMap = mutableMapOf("Content-Type" to "") val localVariableConfig = RequestConfig( RequestMethod.POST, "/fake/{petId}/uploadImageWithRequiredFile".replace("{"+"petId"+"}", "$petId"), @@ -305,7 +307,6 @@ class PetApi(basePath: kotlin.String = "http://petstore.swagger.io:80/v2") : Api ResponseType.Redirection -> TODO() ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") - else -> throw kotlin.IllegalStateException("Undefined ResponseType.") } } diff --git a/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/apis/StoreApi.kt b/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/apis/StoreApi.kt index cee8ac6865a..59d3822c0ba 100644 --- a/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/apis/StoreApi.kt +++ b/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/apis/StoreApi.kt @@ -2,7 +2,7 @@ * OpenAPI Petstore * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ * -* OpenAPI spec version: 1.0.0 +* The version of the OpenAPI document: 1.0.0 * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). @@ -13,7 +13,17 @@ package org.openapitools.client.apis import org.openapitools.client.models.Order -import org.openapitools.client.infrastructure.* +import org.openapitools.client.infrastructure.ApiClient +import org.openapitools.client.infrastructure.ClientException +import org.openapitools.client.infrastructure.ClientError +import org.openapitools.client.infrastructure.ServerException +import org.openapitools.client.infrastructure.ServerError +import org.openapitools.client.infrastructure.MultiValueMap +import org.openapitools.client.infrastructure.RequestConfig +import org.openapitools.client.infrastructure.RequestMethod +import org.openapitools.client.infrastructure.ResponseType +import org.openapitools.client.infrastructure.Success +import org.openapitools.client.infrastructure.toMultiValue class StoreApi(basePath: kotlin.String = "http://petstore.swagger.io:80/v2") : ApiClient(basePath) { @@ -26,7 +36,7 @@ class StoreApi(basePath: kotlin.String = "http://petstore.swagger.io:80/v2") : A fun deleteOrder(orderId: kotlin.String) : Unit { val localVariableBody: kotlin.Any? = null val localVariableQuery: MultiValueMap = mapOf() - val localVariableHeaders: kotlin.collections.Map = mapOf() + val localVariableHeaders: MutableMap = mutableMapOf() val localVariableConfig = RequestConfig( RequestMethod.DELETE, "/store/order/{order_id}".replace("{"+"order_id"+"}", "$orderId"), @@ -44,7 +54,6 @@ class StoreApi(basePath: kotlin.String = "http://petstore.swagger.io:80/v2") : A ResponseType.Redirection -> TODO() ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") - else -> throw kotlin.IllegalStateException("Undefined ResponseType.") } } @@ -57,7 +66,7 @@ class StoreApi(basePath: kotlin.String = "http://petstore.swagger.io:80/v2") : A fun getInventory() : kotlin.collections.Map { val localVariableBody: kotlin.Any? = null val localVariableQuery: MultiValueMap = mapOf() - val localVariableHeaders: kotlin.collections.Map = mapOf() + val localVariableHeaders: MutableMap = mutableMapOf() val localVariableConfig = RequestConfig( RequestMethod.GET, "/store/inventory", @@ -75,7 +84,6 @@ class StoreApi(basePath: kotlin.String = "http://petstore.swagger.io:80/v2") : A ResponseType.Redirection -> TODO() ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") - else -> throw kotlin.IllegalStateException("Undefined ResponseType.") } } @@ -89,7 +97,7 @@ class StoreApi(basePath: kotlin.String = "http://petstore.swagger.io:80/v2") : A fun getOrderById(orderId: kotlin.Long) : Order { val localVariableBody: kotlin.Any? = null val localVariableQuery: MultiValueMap = mapOf() - val localVariableHeaders: kotlin.collections.Map = mapOf() + val localVariableHeaders: MutableMap = mutableMapOf() val localVariableConfig = RequestConfig( RequestMethod.GET, "/store/order/{order_id}".replace("{"+"order_id"+"}", "$orderId"), @@ -107,7 +115,6 @@ class StoreApi(basePath: kotlin.String = "http://petstore.swagger.io:80/v2") : A ResponseType.Redirection -> TODO() ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") - else -> throw kotlin.IllegalStateException("Undefined ResponseType.") } } @@ -121,7 +128,7 @@ class StoreApi(basePath: kotlin.String = "http://petstore.swagger.io:80/v2") : A fun placeOrder(order: Order) : Order { val localVariableBody: kotlin.Any? = order val localVariableQuery: MultiValueMap = mapOf() - val localVariableHeaders: kotlin.collections.Map = mapOf() + val localVariableHeaders: MutableMap = mutableMapOf() val localVariableConfig = RequestConfig( RequestMethod.POST, "/store/order", @@ -139,7 +146,6 @@ class StoreApi(basePath: kotlin.String = "http://petstore.swagger.io:80/v2") : A ResponseType.Redirection -> TODO() ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") - else -> throw kotlin.IllegalStateException("Undefined ResponseType.") } } diff --git a/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/apis/UserApi.kt b/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/apis/UserApi.kt index ef9fd3880f9..47151322588 100644 --- a/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/apis/UserApi.kt +++ b/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/apis/UserApi.kt @@ -2,7 +2,7 @@ * OpenAPI Petstore * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ * -* OpenAPI spec version: 1.0.0 +* The version of the OpenAPI document: 1.0.0 * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). @@ -13,7 +13,17 @@ package org.openapitools.client.apis import org.openapitools.client.models.User -import org.openapitools.client.infrastructure.* +import org.openapitools.client.infrastructure.ApiClient +import org.openapitools.client.infrastructure.ClientException +import org.openapitools.client.infrastructure.ClientError +import org.openapitools.client.infrastructure.ServerException +import org.openapitools.client.infrastructure.ServerError +import org.openapitools.client.infrastructure.MultiValueMap +import org.openapitools.client.infrastructure.RequestConfig +import org.openapitools.client.infrastructure.RequestMethod +import org.openapitools.client.infrastructure.ResponseType +import org.openapitools.client.infrastructure.Success +import org.openapitools.client.infrastructure.toMultiValue class UserApi(basePath: kotlin.String = "http://petstore.swagger.io:80/v2") : ApiClient(basePath) { @@ -26,7 +36,7 @@ class UserApi(basePath: kotlin.String = "http://petstore.swagger.io:80/v2") : Ap fun createUser(user: User) : Unit { val localVariableBody: kotlin.Any? = user val localVariableQuery: MultiValueMap = mapOf() - val localVariableHeaders: kotlin.collections.Map = mapOf() + val localVariableHeaders: MutableMap = mutableMapOf() val localVariableConfig = RequestConfig( RequestMethod.POST, "/user", @@ -44,7 +54,6 @@ class UserApi(basePath: kotlin.String = "http://petstore.swagger.io:80/v2") : Ap ResponseType.Redirection -> TODO() ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") - else -> throw kotlin.IllegalStateException("Undefined ResponseType.") } } @@ -57,7 +66,7 @@ class UserApi(basePath: kotlin.String = "http://petstore.swagger.io:80/v2") : Ap fun createUsersWithArrayInput(user: kotlin.Array) : Unit { val localVariableBody: kotlin.Any? = user val localVariableQuery: MultiValueMap = mapOf() - val localVariableHeaders: kotlin.collections.Map = mapOf() + val localVariableHeaders: MutableMap = mutableMapOf() val localVariableConfig = RequestConfig( RequestMethod.POST, "/user/createWithArray", @@ -75,7 +84,6 @@ class UserApi(basePath: kotlin.String = "http://petstore.swagger.io:80/v2") : Ap ResponseType.Redirection -> TODO() ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") - else -> throw kotlin.IllegalStateException("Undefined ResponseType.") } } @@ -88,7 +96,7 @@ class UserApi(basePath: kotlin.String = "http://petstore.swagger.io:80/v2") : Ap fun createUsersWithListInput(user: kotlin.Array) : Unit { val localVariableBody: kotlin.Any? = user val localVariableQuery: MultiValueMap = mapOf() - val localVariableHeaders: kotlin.collections.Map = mapOf() + val localVariableHeaders: MutableMap = mutableMapOf() val localVariableConfig = RequestConfig( RequestMethod.POST, "/user/createWithList", @@ -106,7 +114,6 @@ class UserApi(basePath: kotlin.String = "http://petstore.swagger.io:80/v2") : Ap ResponseType.Redirection -> TODO() ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") - else -> throw kotlin.IllegalStateException("Undefined ResponseType.") } } @@ -119,7 +126,7 @@ class UserApi(basePath: kotlin.String = "http://petstore.swagger.io:80/v2") : Ap fun deleteUser(username: kotlin.String) : Unit { val localVariableBody: kotlin.Any? = null val localVariableQuery: MultiValueMap = mapOf() - val localVariableHeaders: kotlin.collections.Map = mapOf() + val localVariableHeaders: MutableMap = mutableMapOf() val localVariableConfig = RequestConfig( RequestMethod.DELETE, "/user/{username}".replace("{"+"username"+"}", "$username"), @@ -137,7 +144,6 @@ class UserApi(basePath: kotlin.String = "http://petstore.swagger.io:80/v2") : Ap ResponseType.Redirection -> TODO() ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") - else -> throw kotlin.IllegalStateException("Undefined ResponseType.") } } @@ -151,7 +157,7 @@ class UserApi(basePath: kotlin.String = "http://petstore.swagger.io:80/v2") : Ap fun getUserByName(username: kotlin.String) : User { val localVariableBody: kotlin.Any? = null val localVariableQuery: MultiValueMap = mapOf() - val localVariableHeaders: kotlin.collections.Map = mapOf() + val localVariableHeaders: MutableMap = mutableMapOf() val localVariableConfig = RequestConfig( RequestMethod.GET, "/user/{username}".replace("{"+"username"+"}", "$username"), @@ -169,7 +175,6 @@ class UserApi(basePath: kotlin.String = "http://petstore.swagger.io:80/v2") : Ap ResponseType.Redirection -> TODO() ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") - else -> throw kotlin.IllegalStateException("Undefined ResponseType.") } } @@ -184,7 +189,7 @@ class UserApi(basePath: kotlin.String = "http://petstore.swagger.io:80/v2") : Ap fun loginUser(username: kotlin.String, password: kotlin.String) : kotlin.String { val localVariableBody: kotlin.Any? = null val localVariableQuery: MultiValueMap = mapOf("username" to listOf("$username"), "password" to listOf("$password")) - val localVariableHeaders: kotlin.collections.Map = mapOf() + val localVariableHeaders: MutableMap = mutableMapOf() val localVariableConfig = RequestConfig( RequestMethod.GET, "/user/login", @@ -202,7 +207,6 @@ class UserApi(basePath: kotlin.String = "http://petstore.swagger.io:80/v2") : Ap ResponseType.Redirection -> TODO() ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") - else -> throw kotlin.IllegalStateException("Undefined ResponseType.") } } @@ -214,7 +218,7 @@ class UserApi(basePath: kotlin.String = "http://petstore.swagger.io:80/v2") : Ap fun logoutUser() : Unit { val localVariableBody: kotlin.Any? = null val localVariableQuery: MultiValueMap = mapOf() - val localVariableHeaders: kotlin.collections.Map = mapOf() + val localVariableHeaders: MutableMap = mutableMapOf() val localVariableConfig = RequestConfig( RequestMethod.GET, "/user/logout", @@ -232,7 +236,6 @@ class UserApi(basePath: kotlin.String = "http://petstore.swagger.io:80/v2") : Ap ResponseType.Redirection -> TODO() ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") - else -> throw kotlin.IllegalStateException("Undefined ResponseType.") } } @@ -246,7 +249,7 @@ class UserApi(basePath: kotlin.String = "http://petstore.swagger.io:80/v2") : Ap fun updateUser(username: kotlin.String, user: User) : Unit { val localVariableBody: kotlin.Any? = user val localVariableQuery: MultiValueMap = mapOf() - val localVariableHeaders: kotlin.collections.Map = mapOf() + val localVariableHeaders: MutableMap = mutableMapOf() val localVariableConfig = RequestConfig( RequestMethod.PUT, "/user/{username}".replace("{"+"username"+"}", "$username"), @@ -264,7 +267,6 @@ class UserApi(basePath: kotlin.String = "http://petstore.swagger.io:80/v2") : Ap ResponseType.Redirection -> TODO() ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") - else -> throw kotlin.IllegalStateException("Undefined ResponseType.") } } diff --git a/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt b/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt index 9e79028a90b..ae4ed0fbdb6 100644 --- a/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt +++ b/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt @@ -1,86 +1,125 @@ package org.openapitools.client.infrastructure -import com.squareup.moshi.FromJson -import com.squareup.moshi.Moshi -import com.squareup.moshi.ToJson -import okhttp3.* +import okhttp3.OkHttpClient +import okhttp3.RequestBody +import okhttp3.MediaType +import okhttp3.FormBody +import okhttp3.HttpUrl +import okhttp3.ResponseBody +import okhttp3.Request import java.io.File -import java.util.* open class ApiClient(val baseUrl: String) { companion object { protected const val ContentType = "Content-Type" protected const val Accept = "Accept" + protected const val Authorization = "Authorization" protected const val JsonMediaType = "application/json" protected const val FormDataMediaType = "multipart/form-data" + protected const val FormUrlEncMediaType = "application/x-www-form-urlencoded" protected const val XmlMediaType = "application/xml" + val apiKey: MutableMap = mutableMapOf() + val apiKeyPrefix: MutableMap = mutableMapOf() + var username: String? = null + var password: String? = null + var accessToken: String? = null + @JvmStatic - val client by lazy { + val client: OkHttpClient by lazy { builder.build() } @JvmStatic val builder: OkHttpClient.Builder = OkHttpClient.Builder() - - @JvmStatic - var defaultHeaders: Map by ApplicationDelegates.setOnce(mapOf(ContentType to JsonMediaType, Accept to JsonMediaType)) - - @JvmStatic - val jsonHeaders: Map = mapOf(ContentType to JsonMediaType, Accept to JsonMediaType) } protected inline fun requestBody(content: T, mediaType: String = JsonMediaType): RequestBody = - when { - content is File -> RequestBody.create( - MediaType.parse(mediaType), content - ) - mediaType == FormDataMediaType -> { - var builder = FormBody.Builder() - // content's type *must* be Map - @Suppress("UNCHECKED_CAST") - (content as Map).forEach { key, value -> - builder = builder.add(key, value) - } - builder.build() - } - mediaType == JsonMediaType -> RequestBody.create( - MediaType.parse(mediaType), Serializer.moshi.adapter(T::class.java).toJson(content) - ) - mediaType == XmlMediaType -> TODO("xml not currently supported.") - // TODO: this should be extended with other serializers - else -> TODO("requestBody currently only supports JSON body and File body.") - } + when { + content is File -> RequestBody.create( + MediaType.parse(mediaType), content + ) + mediaType == FormDataMediaType || mediaType == FormUrlEncMediaType -> { + FormBody.Builder().apply { + // content's type *must* be Map + @Suppress("UNCHECKED_CAST") + (content as Map).forEach { (key, value) -> + add(key, value) + } + }.build() + } + mediaType == JsonMediaType -> RequestBody.create( + MediaType.parse(mediaType), Serializer.moshi.adapter(T::class.java).toJson(content) + ) + mediaType == XmlMediaType -> TODO("xml not currently supported.") + // TODO: this should be extended with other serializers + else -> TODO("requestBody currently only supports JSON body and File body.") + } - protected inline fun responseBody(body: ResponseBody?, mediaType: String = JsonMediaType): T? { - if(body == null) return null + protected inline fun responseBody(body: ResponseBody?, mediaType: String? = JsonMediaType): T? { + if(body == null) { + return null + } + val bodyContent = body.string() + if (bodyContent.isEmpty()) { + return null + } return when(mediaType) { - JsonMediaType -> Moshi.Builder().add(object { - @ToJson - fun toJson(uuid: UUID) = uuid.toString() - @FromJson - fun fromJson(s: String) = UUID.fromString(s) - }) - .add(ByteArrayAdapter()) - .build().adapter(T::class.java).fromJson(body.source()) - else -> TODO() + JsonMediaType -> Serializer.moshi.adapter(T::class.java).fromJson(bodyContent) + else -> TODO("responseBody currently only supports JSON body.") + } + } + + protected fun updateAuthParams(requestConfig: RequestConfig) { + if (requestConfig.headers["api_key"].isNullOrEmpty()) { + if (apiKeyPrefix["api_key"] != null) { + requestConfig.headers["api_key"] = apiKeyPrefix["api_key"] + " " + apiKey["api_key"] + } else { + requestConfig.headers["api_key"] = apiKey["api_key"] + } + } + if (requestConfig.query["api_key_query"].isNullOrEmpty()) { + if (apiKeyPrefix["api_key_query"] != null) { + requestConfig.query["api_key_query"] = apiKeyPrefix["api_key_query"] + " " + apiKey["api_key_query"] + } else { + requestConfig.query["api_key_query"] = apiKey["api_key_query"] + } + } + if (requestConfig.headers[Authorization].isNullOrEmpty()) { + requestConfig.headers[Authorization] = "Bearer " + accessToken + } + if (requestConfig.headers[Authorization].isNullOrEmpty()) { + requestConfig.headers[Authorization] = Credentials.basic(username, password) + } + if (requestConfig.headers[Authorization].isNullOrEmpty()) { + requestConfig.headers[Authorization] = "Bearer " + accessToken } } protected inline fun request(requestConfig: RequestConfig, body : Any? = null): ApiInfrastructureResponse { val httpUrl = HttpUrl.parse(baseUrl) ?: throw IllegalStateException("baseUrl is invalid.") - var urlBuilder = httpUrl.newBuilder() - .addPathSegments(requestConfig.path.trimStart('/')) + // take authMethod from operation + updateAuthParams(requestConfig) - requestConfig.query.forEach { query -> - query.value.forEach { queryValue -> - urlBuilder = urlBuilder.addQueryParameter(query.key, queryValue) - } + val url = httpUrl.newBuilder() + .addPathSegments(requestConfig.path.trimStart('/')) + .apply { + requestConfig.query.forEach { query -> + query.value.forEach { queryValue -> + addQueryParameter(query.key, queryValue) + } + } + }.build() + + // take content-type/accept from spec or set to default (application/json) if not defined + if (requestConfig.headers[ContentType].isNullOrEmpty()) { + requestConfig.headers[ContentType] = JsonMediaType } - - val url = urlBuilder.build() - val headers = requestConfig.headers + defaultHeaders + if (requestConfig.headers[Accept].isNullOrEmpty()) { + requestConfig.headers[Accept] = JsonMediaType + } + val headers = requestConfig.headers if(headers[ContentType] ?: "" == "") { throw kotlin.IllegalStateException("Missing Content-Type header. This is required.") @@ -90,11 +129,10 @@ open class ApiClient(val baseUrl: String) { throw kotlin.IllegalStateException("Missing Accept header. This is required.") } - // TODO: support multiple contentType,accept options here. + // TODO: support multiple contentType options here. val contentType = (headers[ContentType] as String).substringBefore(";").toLowerCase() - val accept = (headers[Accept] as String).substringBefore(";").toLowerCase() - var request : Request.Builder = when (requestConfig.method) { + val request = when (requestConfig.method) { RequestMethod.DELETE -> Request.Builder().url(url).delete() RequestMethod.GET -> Request.Builder().url(url) RequestMethod.HEAD -> Request.Builder().url(url).head() @@ -102,12 +140,12 @@ open class ApiClient(val baseUrl: String) { RequestMethod.PUT -> Request.Builder().url(url).put(requestBody(body, contentType)) RequestMethod.POST -> Request.Builder().url(url).post(requestBody(body, contentType)) RequestMethod.OPTIONS -> Request.Builder().url(url).method("OPTIONS", null) - } + }.apply { + headers.forEach { header -> addHeader(header.key, header.value) } + }.build() - headers.forEach { header -> request = request.addHeader(header.key, header.value) } - - val realRequest = request.build() - val response = client.newCall(realRequest).execute() + val response = client.newCall(request).execute() + val accept = response.header(ContentType)?.substringBefore(";")?.toLowerCase() // TODO: handle specific mapping types. e.g. Map> when { @@ -138,4 +176,4 @@ open class ApiClient(val baseUrl: String) { ) } } -} \ No newline at end of file +} diff --git a/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/infrastructure/LocalDateAdapter.kt b/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/infrastructure/LocalDateAdapter.kt new file mode 100644 index 00000000000..b2e1654479a --- /dev/null +++ b/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/infrastructure/LocalDateAdapter.kt @@ -0,0 +1,19 @@ +package org.openapitools.client.infrastructure + +import com.squareup.moshi.FromJson +import com.squareup.moshi.ToJson +import java.time.LocalDate +import java.time.format.DateTimeFormatter + +class LocalDateAdapter { + @ToJson + fun toJson(value: LocalDate): String { + return DateTimeFormatter.ISO_LOCAL_DATE.format(value) + } + + @FromJson + fun fromJson(value: String): LocalDate { + return LocalDate.parse(value, DateTimeFormatter.ISO_LOCAL_DATE) + } + +} diff --git a/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/infrastructure/LocalDateTimeAdapter.kt b/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/infrastructure/LocalDateTimeAdapter.kt new file mode 100644 index 00000000000..e082db94811 --- /dev/null +++ b/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/infrastructure/LocalDateTimeAdapter.kt @@ -0,0 +1,19 @@ +package org.openapitools.client.infrastructure + +import com.squareup.moshi.FromJson +import com.squareup.moshi.ToJson +import java.time.LocalDateTime +import java.time.format.DateTimeFormatter + +class LocalDateTimeAdapter { + @ToJson + fun toJson(value: LocalDateTime): String { + return DateTimeFormatter.ISO_LOCAL_DATE_TIME.format(value) + } + + @FromJson + fun fromJson(value: String): LocalDateTime { + return LocalDateTime.parse(value, DateTimeFormatter.ISO_LOCAL_DATE_TIME) + } + +} diff --git a/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/infrastructure/RequestConfig.kt b/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/infrastructure/RequestConfig.kt index 86e2dadf9a8..53e689237d7 100644 --- a/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/infrastructure/RequestConfig.kt +++ b/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/infrastructure/RequestConfig.kt @@ -11,6 +11,6 @@ package org.openapitools.client.infrastructure data class RequestConfig( val method: RequestMethod, val path: String, - val headers: Map = mapOf(), + val headers: MutableMap = mutableMapOf(), val query: Map> = mapOf() ) \ No newline at end of file diff --git a/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/infrastructure/Serializer.kt b/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/infrastructure/Serializer.kt index cf3fe8203d5..7c5a353e0f7 100644 --- a/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/infrastructure/Serializer.kt +++ b/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/infrastructure/Serializer.kt @@ -1,14 +1,18 @@ package org.openapitools.client.infrastructure -import com.squareup.moshi.KotlinJsonAdapterFactory import com.squareup.moshi.Moshi -import com.squareup.moshi.Rfc3339DateJsonAdapter -import java.util.* +import com.squareup.moshi.adapters.Rfc3339DateJsonAdapter +import com.squareup.moshi.kotlin.reflect.KotlinJsonAdapterFactory +import java.util.Date object Serializer { @JvmStatic val moshi: Moshi = Moshi.Builder() - .add(KotlinJsonAdapterFactory()) .add(Date::class.java, Rfc3339DateJsonAdapter().nullSafe()) + .add(LocalDateTimeAdapter()) + .add(LocalDateAdapter()) + .add(UUIDAdapter()) + .add(ByteArrayAdapter()) + .add(KotlinJsonAdapterFactory()) .build() } diff --git a/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/infrastructure/UUIDAdapter.kt b/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/infrastructure/UUIDAdapter.kt new file mode 100644 index 00000000000..a4a44cc18b7 --- /dev/null +++ b/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/infrastructure/UUIDAdapter.kt @@ -0,0 +1,13 @@ +package org.openapitools.client.infrastructure + +import com.squareup.moshi.FromJson +import com.squareup.moshi.ToJson +import java.util.UUID + +class UUIDAdapter { + @ToJson + fun toJson(uuid: UUID) = uuid.toString() + + @FromJson + fun fromJson(s: String) = UUID.fromString(s) +} diff --git a/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/AdditionalPropertiesClass.kt b/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/AdditionalPropertiesClass.kt index f5baace226b..ad9d5f84c57 100644 --- a/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/AdditionalPropertiesClass.kt +++ b/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/AdditionalPropertiesClass.kt @@ -2,7 +2,7 @@ * OpenAPI Petstore * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ * -* OpenAPI spec version: 1.0.0 +* The version of the OpenAPI document: 1.0.0 * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). @@ -12,13 +12,16 @@ package org.openapitools.client.models +import com.squareup.moshi.Json /** * * @param mapProperty * @param mapOfMapProperty */ data class AdditionalPropertiesClass ( + @Json(name = "map_property") val mapProperty: kotlin.collections.Map? = null, + @Json(name = "map_of_map_property") val mapOfMapProperty: kotlin.collections.Map>? = null ) { diff --git a/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/Animal.kt b/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/Animal.kt index 7b24a5575cc..655306a7e89 100644 --- a/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/Animal.kt +++ b/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/Animal.kt @@ -2,7 +2,7 @@ * OpenAPI Petstore * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ * -* OpenAPI spec version: 1.0.0 +* The version of the OpenAPI document: 1.0.0 * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). @@ -12,13 +12,16 @@ package org.openapitools.client.models +import com.squareup.moshi.Json /** * * @param className * @param color */ data class Animal ( + @Json(name = "className") val className: kotlin.String, + @Json(name = "color") val color: kotlin.String? = null ) { diff --git a/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/ApiResponse.kt b/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/ApiResponse.kt index e63d35308de..f79e529c2fc 100644 --- a/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/ApiResponse.kt +++ b/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/ApiResponse.kt @@ -2,7 +2,7 @@ * OpenAPI Petstore * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ * -* OpenAPI spec version: 1.0.0 +* The version of the OpenAPI document: 1.0.0 * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). @@ -12,6 +12,7 @@ package org.openapitools.client.models +import com.squareup.moshi.Json /** * * @param code @@ -19,8 +20,11 @@ package org.openapitools.client.models * @param message */ data class ApiResponse ( + @Json(name = "code") val code: kotlin.Int? = null, + @Json(name = "type") val type: kotlin.String? = null, + @Json(name = "message") val message: kotlin.String? = null ) { diff --git a/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/ArrayOfArrayOfNumberOnly.kt b/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/ArrayOfArrayOfNumberOnly.kt index eeaf6870d43..3be01f40411 100644 --- a/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/ArrayOfArrayOfNumberOnly.kt +++ b/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/ArrayOfArrayOfNumberOnly.kt @@ -2,7 +2,7 @@ * OpenAPI Petstore * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ * -* OpenAPI spec version: 1.0.0 +* The version of the OpenAPI document: 1.0.0 * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). @@ -12,11 +12,13 @@ package org.openapitools.client.models +import com.squareup.moshi.Json /** * * @param arrayArrayNumber */ data class ArrayOfArrayOfNumberOnly ( + @Json(name = "ArrayArrayNumber") val arrayArrayNumber: kotlin.Array>? = null ) { diff --git a/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/ArrayOfNumberOnly.kt b/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/ArrayOfNumberOnly.kt index a936cbfb37a..d4d24cd34ed 100644 --- a/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/ArrayOfNumberOnly.kt +++ b/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/ArrayOfNumberOnly.kt @@ -2,7 +2,7 @@ * OpenAPI Petstore * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ * -* OpenAPI spec version: 1.0.0 +* The version of the OpenAPI document: 1.0.0 * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). @@ -12,11 +12,13 @@ package org.openapitools.client.models +import com.squareup.moshi.Json /** * * @param arrayNumber */ data class ArrayOfNumberOnly ( + @Json(name = "ArrayNumber") val arrayNumber: kotlin.Array? = null ) { diff --git a/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/ArrayTest.kt b/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/ArrayTest.kt index 4f3ac37d99b..51fd93eec0e 100644 --- a/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/ArrayTest.kt +++ b/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/ArrayTest.kt @@ -2,7 +2,7 @@ * OpenAPI Petstore * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ * -* OpenAPI spec version: 1.0.0 +* The version of the OpenAPI document: 1.0.0 * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). @@ -13,6 +13,7 @@ package org.openapitools.client.models import org.openapitools.client.models.ReadOnlyFirst +import com.squareup.moshi.Json /** * * @param arrayOfString @@ -20,8 +21,11 @@ import org.openapitools.client.models.ReadOnlyFirst * @param arrayArrayOfModel */ data class ArrayTest ( + @Json(name = "array_of_string") val arrayOfString: kotlin.Array? = null, + @Json(name = "array_array_of_integer") val arrayArrayOfInteger: kotlin.Array>? = null, + @Json(name = "array_array_of_model") val arrayArrayOfModel: kotlin.Array>? = null ) { diff --git a/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/Capitalization.kt b/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/Capitalization.kt index 2d4717e2f83..ec12c128324 100644 --- a/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/Capitalization.kt +++ b/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/Capitalization.kt @@ -2,7 +2,7 @@ * OpenAPI Petstore * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ * -* OpenAPI spec version: 1.0.0 +* The version of the OpenAPI document: 1.0.0 * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). @@ -12,6 +12,7 @@ package org.openapitools.client.models +import com.squareup.moshi.Json /** * * @param smallCamel @@ -22,12 +23,18 @@ package org.openapitools.client.models * @param ATT_NAME Name of the pet */ data class Capitalization ( + @Json(name = "smallCamel") val smallCamel: kotlin.String? = null, + @Json(name = "CapitalCamel") val capitalCamel: kotlin.String? = null, + @Json(name = "small_Snake") val smallSnake: kotlin.String? = null, + @Json(name = "Capital_Snake") val capitalSnake: kotlin.String? = null, + @Json(name = "SCA_ETH_Flow_Points") val scAETHFlowPoints: kotlin.String? = null, /* Name of the pet */ + @Json(name = "ATT_NAME") val ATT_NAME: kotlin.String? = null ) { diff --git a/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/Cat.kt b/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/Cat.kt index 92d95e6ac52..f7fc445d9ef 100644 --- a/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/Cat.kt +++ b/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/Cat.kt @@ -2,7 +2,7 @@ * OpenAPI Petstore * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ * -* OpenAPI spec version: 1.0.0 +* The version of the OpenAPI document: 1.0.0 * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). @@ -12,14 +12,19 @@ package org.openapitools.client.models import org.openapitools.client.models.Animal +import org.openapitools.client.models.CatAllOf +import com.squareup.moshi.Json /** * * @param declawed */ data class Cat ( + @Json(name = "className") val className: kotlin.String, + @Json(name = "declawed") val declawed: kotlin.Boolean? = null, + @Json(name = "color") val color: kotlin.String? = null ) { diff --git a/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/CatAllOf.kt b/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/CatAllOf.kt new file mode 100644 index 00000000000..c20830cfc99 --- /dev/null +++ b/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/CatAllOf.kt @@ -0,0 +1,26 @@ +/** +* OpenAPI Petstore +* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ +* +* The version of the OpenAPI document: 1.0.0 +* +* +* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). +* https://openapi-generator.tech +* Do not edit the class manually. +*/ +package org.openapitools.client.models + + +import com.squareup.moshi.Json +/** + * + * @param declawed + */ +data class CatAllOf ( + @Json(name = "declawed") + val declawed: kotlin.Boolean? = null +) { + +} + diff --git a/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/Category.kt b/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/Category.kt index 1d8c9699b5d..637d8f39fdb 100644 --- a/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/Category.kt +++ b/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/Category.kt @@ -2,7 +2,7 @@ * OpenAPI Petstore * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ * -* OpenAPI spec version: 1.0.0 +* The version of the OpenAPI document: 1.0.0 * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). @@ -12,13 +12,16 @@ package org.openapitools.client.models +import com.squareup.moshi.Json /** * * @param id * @param name */ data class Category ( + @Json(name = "name") val name: kotlin.String, + @Json(name = "id") val id: kotlin.Long? = null ) { diff --git a/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/ClassModel.kt b/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/ClassModel.kt index 556f5db0ee2..92425fba564 100644 --- a/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/ClassModel.kt +++ b/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/ClassModel.kt @@ -2,7 +2,7 @@ * OpenAPI Petstore * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ * -* OpenAPI spec version: 1.0.0 +* The version of the OpenAPI document: 1.0.0 * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). @@ -12,11 +12,13 @@ package org.openapitools.client.models +import com.squareup.moshi.Json /** * Model for testing model with \"_class\" property * @param propertyClass */ data class ClassModel ( + @Json(name = "_class") val propertyClass: kotlin.String? = null ) { diff --git a/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/Client.kt b/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/Client.kt index dca68a1d290..656eff708d2 100644 --- a/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/Client.kt +++ b/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/Client.kt @@ -2,7 +2,7 @@ * OpenAPI Petstore * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ * -* OpenAPI spec version: 1.0.0 +* The version of the OpenAPI document: 1.0.0 * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). @@ -12,11 +12,13 @@ package org.openapitools.client.models +import com.squareup.moshi.Json /** * * @param client */ data class Client ( + @Json(name = "client") val client: kotlin.String? = null ) { diff --git a/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/Dog.kt b/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/Dog.kt index 6da240f947e..6f194f25a80 100644 --- a/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/Dog.kt +++ b/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/Dog.kt @@ -2,7 +2,7 @@ * OpenAPI Petstore * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ * -* OpenAPI spec version: 1.0.0 +* The version of the OpenAPI document: 1.0.0 * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). @@ -12,14 +12,19 @@ package org.openapitools.client.models import org.openapitools.client.models.Animal +import org.openapitools.client.models.DogAllOf +import com.squareup.moshi.Json /** * * @param breed */ data class Dog ( + @Json(name = "className") val className: kotlin.String, + @Json(name = "breed") val breed: kotlin.String? = null, + @Json(name = "color") val color: kotlin.String? = null ) { diff --git a/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/DogAllOf.kt b/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/DogAllOf.kt new file mode 100644 index 00000000000..fab37948f8c --- /dev/null +++ b/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/DogAllOf.kt @@ -0,0 +1,26 @@ +/** +* OpenAPI Petstore +* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ +* +* The version of the OpenAPI document: 1.0.0 +* +* +* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). +* https://openapi-generator.tech +* Do not edit the class manually. +*/ +package org.openapitools.client.models + + +import com.squareup.moshi.Json +/** + * + * @param breed + */ +data class DogAllOf ( + @Json(name = "breed") + val breed: kotlin.String? = null +) { + +} + diff --git a/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/EnumArrays.kt b/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/EnumArrays.kt index ee1d36cee63..d791eb136eb 100644 --- a/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/EnumArrays.kt +++ b/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/EnumArrays.kt @@ -2,7 +2,7 @@ * OpenAPI Petstore * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ * -* OpenAPI spec version: 1.0.0 +* The version of the OpenAPI document: 1.0.0 * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). @@ -19,7 +19,9 @@ import com.squareup.moshi.Json * @param arrayEnum */ data class EnumArrays ( + @Json(name = "just_symbol") val justSymbol: EnumArrays.JustSymbol? = null, + @Json(name = "array_enum") val arrayEnum: EnumArrays.ArrayEnum? = null ) { @@ -29,9 +31,11 @@ data class EnumArrays ( */ enum class JustSymbol(val value: kotlin.String){ - @Json(name = ">=") greaterThanEqual(">="), + @Json(name = ">=") + greaterThanEqual(">="), - @Json(name = "$") dollar("$"); + @Json(name = "$") + dollar("$"); } @@ -41,9 +45,11 @@ data class EnumArrays ( */ enum class ArrayEnum(val value: kotlin.Array<kotlin.String>){ - @Json(name = "fish") fish("fish"), + @Json(name = "fish") + fish("fish"), - @Json(name = "crab") crab("crab"); + @Json(name = "crab") + crab("crab"); } diff --git a/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/EnumClass.kt b/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/EnumClass.kt index 64030e0d539..089f8037e31 100644 --- a/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/EnumClass.kt +++ b/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/EnumClass.kt @@ -2,7 +2,7 @@ * OpenAPI Petstore * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ * -* OpenAPI spec version: 1.0.0 +* The version of the OpenAPI document: 1.0.0 * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). @@ -20,11 +20,14 @@ import com.squareup.moshi.Json */ enum class EnumClass(val value: kotlin.String){ - @Json(name = "_abc") abc("_abc"), + @Json(name = "_abc") + abc("_abc"), - @Json(name = "-efg") minusEfg("-efg"), + @Json(name = "-efg") + minusEfg("-efg"), - @Json(name = "(xyz)") leftParenthesisXyzRightParenthesis("(xyz)"); + @Json(name = "(xyz)") + leftParenthesisXyzRightParenthesis("(xyz)"); } diff --git a/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/EnumTest.kt b/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/EnumTest.kt index a124fce0669..59cd40f659e 100644 --- a/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/EnumTest.kt +++ b/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/EnumTest.kt @@ -2,7 +2,7 @@ * OpenAPI Petstore * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ * -* OpenAPI spec version: 1.0.0 +* The version of the OpenAPI document: 1.0.0 * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). @@ -29,13 +29,21 @@ import com.squareup.moshi.Json * @param outerEnumIntegerDefaultValue */ data class EnumTest ( + @Json(name = "enum_string_required") val enumStringRequired: EnumTest.EnumStringRequired, + @Json(name = "enum_string") val enumString: EnumTest.EnumString? = null, + @Json(name = "enum_integer") val enumInteger: EnumTest.EnumInteger? = null, + @Json(name = "enum_number") val enumNumber: EnumTest.EnumNumber? = null, + @Json(name = "outerEnum") val outerEnum: OuterEnum? = null, + @Json(name = "outerEnumInteger") val outerEnumInteger: OuterEnumInteger? = null, + @Json(name = "outerEnumDefaultValue") val outerEnumDefaultValue: OuterEnumDefaultValue? = null, + @Json(name = "outerEnumIntegerDefaultValue") val outerEnumIntegerDefaultValue: OuterEnumIntegerDefaultValue? = null ) { @@ -45,11 +53,14 @@ data class EnumTest ( */ enum class EnumString(val value: kotlin.String){ - @Json(name = "UPPER") uPPER("UPPER"), + @Json(name = "UPPER") + uPPER("UPPER"), - @Json(name = "lower") lower("lower"), + @Json(name = "lower") + lower("lower"), - @Json(name = "") eMPTY(""); + @Json(name = "") + eMPTY(""); } @@ -59,11 +70,14 @@ data class EnumTest ( */ enum class EnumStringRequired(val value: kotlin.String){ - @Json(name = "UPPER") uPPER("UPPER"), + @Json(name = "UPPER") + uPPER("UPPER"), - @Json(name = "lower") lower("lower"), + @Json(name = "lower") + lower("lower"), - @Json(name = "") eMPTY(""); + @Json(name = "") + eMPTY(""); } @@ -73,9 +87,11 @@ data class EnumTest ( */ enum class EnumInteger(val value: kotlin.Int){ - @Json(name = 1) _1(1), + @Json(name = 1) + _1(1), - @Json(name = -1) minus1(-1); + @Json(name = -1) + minus1(-1); } @@ -85,9 +101,11 @@ data class EnumTest ( */ enum class EnumNumber(val value: kotlin.Double){ - @Json(name = 1.1) _1period1(1.1), + @Json(name = 1.1) + _1period1(1.1), - @Json(name = -1.2) minus1Period2(-1.2); + @Json(name = -1.2) + minus1Period2(-1.2); } diff --git a/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/FileSchemaTestClass.kt b/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/FileSchemaTestClass.kt index ecece52046d..003bc5c6b69 100644 --- a/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/FileSchemaTestClass.kt +++ b/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/FileSchemaTestClass.kt @@ -2,7 +2,7 @@ * OpenAPI Petstore * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ * -* OpenAPI spec version: 1.0.0 +* The version of the OpenAPI document: 1.0.0 * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). @@ -12,13 +12,16 @@ package org.openapitools.client.models +import com.squareup.moshi.Json /** * * @param file * @param files */ data class FileSchemaTestClass ( + @Json(name = "file") val file: java.io.File? = null, + @Json(name = "files") val files: kotlin.Array? = null ) { diff --git a/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/Foo.kt b/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/Foo.kt index 90a3d1e5408..40d0f465db3 100644 --- a/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/Foo.kt +++ b/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/Foo.kt @@ -2,7 +2,7 @@ * OpenAPI Petstore * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ * -* OpenAPI spec version: 1.0.0 +* The version of the OpenAPI document: 1.0.0 * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). @@ -12,11 +12,13 @@ package org.openapitools.client.models +import com.squareup.moshi.Json /** * * @param bar */ data class Foo ( + @Json(name = "bar") val bar: kotlin.String? = null ) { diff --git a/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/FormatTest.kt b/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/FormatTest.kt index 14817038f57..79c8dc6968e 100644 --- a/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/FormatTest.kt +++ b/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/FormatTest.kt @@ -2,7 +2,7 @@ * OpenAPI Petstore * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ * -* OpenAPI spec version: 1.0.0 +* The version of the OpenAPI document: 1.0.0 * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). @@ -12,6 +12,7 @@ package org.openapitools.client.models +import com.squareup.moshi.Json /** * * @param integer @@ -31,22 +32,37 @@ package org.openapitools.client.models * @param patternWithDigitsAndDelimiter A string starting with 'image_' (case insensitive) and one to three digits following i.e. Image_01. */ data class FormatTest ( + @Json(name = "number") val number: java.math.BigDecimal, + @Json(name = "byte") val byte: kotlin.ByteArray, - val date: java.time.LocalDateTime, + @Json(name = "date") + val date: java.time.LocalDate, + @Json(name = "password") val password: kotlin.String, + @Json(name = "integer") val integer: kotlin.Int? = null, + @Json(name = "int32") val int32: kotlin.Int? = null, + @Json(name = "int64") val int64: kotlin.Long? = null, + @Json(name = "float") val float: kotlin.Float? = null, + @Json(name = "double") val double: kotlin.Double? = null, + @Json(name = "string") val string: kotlin.String? = null, + @Json(name = "binary") val binary: java.io.File? = null, + @Json(name = "dateTime") val dateTime: java.time.LocalDateTime? = null, + @Json(name = "uuid") val uuid: java.util.UUID? = null, /* A string that is a 10 digit number. Can have leading zeros. */ + @Json(name = "pattern_with_digits") val patternWithDigits: kotlin.String? = null, /* A string starting with 'image_' (case insensitive) and one to three digits following i.e. Image_01. */ + @Json(name = "pattern_with_digits_and_delimiter") val patternWithDigitsAndDelimiter: kotlin.String? = null ) { diff --git a/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/HasOnlyReadOnly.kt b/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/HasOnlyReadOnly.kt index fc05361d3ec..2fae9267987 100644 --- a/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/HasOnlyReadOnly.kt +++ b/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/HasOnlyReadOnly.kt @@ -2,7 +2,7 @@ * OpenAPI Petstore * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ * -* OpenAPI spec version: 1.0.0 +* The version of the OpenAPI document: 1.0.0 * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). @@ -12,13 +12,16 @@ package org.openapitools.client.models +import com.squareup.moshi.Json /** * * @param bar * @param foo */ data class HasOnlyReadOnly ( + @Json(name = "bar") val bar: kotlin.String? = null, + @Json(name = "foo") val foo: kotlin.String? = null ) { diff --git a/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/HealthCheckResult.kt b/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/HealthCheckResult.kt index d8f7ec1fb8a..f0466b799b4 100644 --- a/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/HealthCheckResult.kt +++ b/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/HealthCheckResult.kt @@ -2,7 +2,7 @@ * OpenAPI Petstore * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ * -* OpenAPI spec version: 1.0.0 +* The version of the OpenAPI document: 1.0.0 * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). @@ -12,11 +12,13 @@ package org.openapitools.client.models +import com.squareup.moshi.Json /** * Just a string to inform instance is up and running. Make it nullable in hope to get it as pointer in generated model. * @param nullableMessage */ data class HealthCheckResult ( + @Json(name = "NullableMessage") val nullableMessage: kotlin.String? = null ) { diff --git a/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/InlineObject.kt b/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/InlineObject.kt index c11ccb2405a..53a7082ac0a 100644 --- a/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/InlineObject.kt +++ b/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/InlineObject.kt @@ -2,7 +2,7 @@ * OpenAPI Petstore * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ * -* OpenAPI spec version: 1.0.0 +* The version of the OpenAPI document: 1.0.0 * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). @@ -12,6 +12,7 @@ package org.openapitools.client.models +import com.squareup.moshi.Json /** * * @param name Updated name of the pet @@ -19,8 +20,10 @@ package org.openapitools.client.models */ data class InlineObject ( /* Updated name of the pet */ + @Json(name = "name") val name: kotlin.String? = null, /* Updated status of the pet */ + @Json(name = "status") val status: kotlin.String? = null ) { diff --git a/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/InlineObject1.kt b/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/InlineObject1.kt index 645734260b8..0917219b4ef 100644 --- a/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/InlineObject1.kt +++ b/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/InlineObject1.kt @@ -2,7 +2,7 @@ * OpenAPI Petstore * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ * -* OpenAPI spec version: 1.0.0 +* The version of the OpenAPI document: 1.0.0 * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). @@ -12,6 +12,7 @@ package org.openapitools.client.models +import com.squareup.moshi.Json /** * * @param additionalMetadata Additional data to pass to server @@ -19,8 +20,10 @@ package org.openapitools.client.models */ data class InlineObject1 ( /* Additional data to pass to server */ + @Json(name = "additionalMetadata") val additionalMetadata: kotlin.String? = null, /* file to upload */ + @Json(name = "file") val file: java.io.File? = null ) { diff --git a/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/InlineObject2.kt b/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/InlineObject2.kt index 1e08e601172..989561cbeb6 100644 --- a/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/InlineObject2.kt +++ b/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/InlineObject2.kt @@ -2,7 +2,7 @@ * OpenAPI Petstore * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ * -* OpenAPI spec version: 1.0.0 +* The version of the OpenAPI document: 1.0.0 * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). @@ -20,8 +20,10 @@ import com.squareup.moshi.Json */ data class InlineObject2 ( /* Form parameter enum test (string array) */ + @Json(name = "enum_form_string_array") val enumFormStringArray: InlineObject2.EnumFormStringArray? = null, /* Form parameter enum test (string) */ + @Json(name = "enum_form_string") val enumFormString: InlineObject2.EnumFormString? = null ) { @@ -31,9 +33,11 @@ data class InlineObject2 ( */ enum class EnumFormStringArray(val value: kotlin.Array<kotlin.String>){ - @Json(name = ">") greaterThan(">"), + @Json(name = ">") + greaterThan(">"), - @Json(name = "$") dollar("$"); + @Json(name = "$") + dollar("$"); } @@ -43,11 +47,14 @@ data class InlineObject2 ( */ enum class EnumFormString(val value: kotlin.String){ - @Json(name = "_abc") abc("_abc"), + @Json(name = "_abc") + abc("_abc"), - @Json(name = "-efg") minusEfg("-efg"), + @Json(name = "-efg") + minusEfg("-efg"), - @Json(name = "(xyz)") leftParenthesisXyzRightParenthesis("(xyz)"); + @Json(name = "(xyz)") + leftParenthesisXyzRightParenthesis("(xyz)"); } diff --git a/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/InlineObject3.kt b/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/InlineObject3.kt index a3a0c0c9465..4ade4913675 100644 --- a/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/InlineObject3.kt +++ b/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/InlineObject3.kt @@ -2,7 +2,7 @@ * OpenAPI Petstore * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ * -* OpenAPI spec version: 1.0.0 +* The version of the OpenAPI document: 1.0.0 * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). @@ -12,6 +12,7 @@ package org.openapitools.client.models +import com.squareup.moshi.Json /** * * @param integer None @@ -31,32 +32,46 @@ package org.openapitools.client.models */ data class InlineObject3 ( /* None */ + @Json(name = "number") val number: java.math.BigDecimal, /* None */ + @Json(name = "double") val double: kotlin.Double, /* None */ + @Json(name = "pattern_without_delimiter") val patternWithoutDelimiter: kotlin.String, /* None */ + @Json(name = "byte") val byte: kotlin.ByteArray, /* None */ + @Json(name = "integer") val integer: kotlin.Int? = null, /* None */ + @Json(name = "int32") val int32: kotlin.Int? = null, /* None */ + @Json(name = "int64") val int64: kotlin.Long? = null, /* None */ + @Json(name = "float") val float: kotlin.Float? = null, /* None */ + @Json(name = "string") val string: kotlin.String? = null, /* None */ + @Json(name = "binary") val binary: java.io.File? = null, /* None */ - val date: java.time.LocalDateTime? = null, + @Json(name = "date") + val date: java.time.LocalDate? = null, /* None */ + @Json(name = "dateTime") val dateTime: java.time.LocalDateTime? = null, /* None */ + @Json(name = "password") val password: kotlin.String? = null, /* None */ + @Json(name = "callback") val callback: kotlin.String? = null ) { diff --git a/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/InlineObject4.kt b/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/InlineObject4.kt index 091288caa5b..91b9c2a9cdf 100644 --- a/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/InlineObject4.kt +++ b/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/InlineObject4.kt @@ -2,7 +2,7 @@ * OpenAPI Petstore * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ * -* OpenAPI spec version: 1.0.0 +* The version of the OpenAPI document: 1.0.0 * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). @@ -12,6 +12,7 @@ package org.openapitools.client.models +import com.squareup.moshi.Json /** * * @param param field1 @@ -19,8 +20,10 @@ package org.openapitools.client.models */ data class InlineObject4 ( /* field1 */ + @Json(name = "param") val param: kotlin.String, /* field2 */ + @Json(name = "param2") val param2: kotlin.String ) { diff --git a/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/InlineObject5.kt b/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/InlineObject5.kt index 7dd6bf7ae29..f058f58c444 100644 --- a/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/InlineObject5.kt +++ b/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/InlineObject5.kt @@ -2,7 +2,7 @@ * OpenAPI Petstore * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ * -* OpenAPI spec version: 1.0.0 +* The version of the OpenAPI document: 1.0.0 * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). @@ -12,6 +12,7 @@ package org.openapitools.client.models +import com.squareup.moshi.Json /** * * @param additionalMetadata Additional data to pass to server @@ -19,8 +20,10 @@ package org.openapitools.client.models */ data class InlineObject5 ( /* file to upload */ + @Json(name = "requiredFile") val requiredFile: java.io.File, /* Additional data to pass to server */ + @Json(name = "additionalMetadata") val additionalMetadata: kotlin.String? = null ) { diff --git a/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/InlineResponseDefault.kt b/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/InlineResponseDefault.kt index 5eb84f603fd..ea862cef739 100644 --- a/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/InlineResponseDefault.kt +++ b/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/InlineResponseDefault.kt @@ -2,7 +2,7 @@ * OpenAPI Petstore * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ * -* OpenAPI spec version: 1.0.0 +* The version of the OpenAPI document: 1.0.0 * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). @@ -13,11 +13,13 @@ package org.openapitools.client.models import org.openapitools.client.models.Foo +import com.squareup.moshi.Json /** * * @param string */ data class InlineResponseDefault ( + @Json(name = "string") val string: Foo? = null ) { diff --git a/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/List.kt b/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/List.kt index 14b0b3615d6..533fb21cc80 100644 --- a/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/List.kt +++ b/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/List.kt @@ -2,7 +2,7 @@ * OpenAPI Petstore * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ * -* OpenAPI spec version: 1.0.0 +* The version of the OpenAPI document: 1.0.0 * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). @@ -12,12 +12,14 @@ package org.openapitools.client.models +import com.squareup.moshi.Json /** * - * @param `123list` + * @param `123minusList` */ data class List ( - val `123list`: kotlin.String? = null + @Json(name = "123-list") + val `123minusList`: kotlin.String? = null ) { } diff --git a/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/MapTest.kt b/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/MapTest.kt index 7e681520018..bde64f1b11c 100644 --- a/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/MapTest.kt +++ b/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/MapTest.kt @@ -2,7 +2,7 @@ * OpenAPI Petstore * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ * -* OpenAPI spec version: 1.0.0 +* The version of the OpenAPI document: 1.0.0 * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). @@ -21,9 +21,13 @@ import com.squareup.moshi.Json * @param indirectMap */ data class MapTest ( + @Json(name = "map_map_of_string") val mapMapOfString: kotlin.collections.Map>? = null, + @Json(name = "map_of_enum_string") val mapOfEnumString: MapTest.MapOfEnumString? = null, + @Json(name = "direct_map") val directMap: kotlin.collections.Map? = null, + @Json(name = "indirect_map") val indirectMap: kotlin.collections.Map? = null ) { @@ -33,9 +37,11 @@ data class MapTest ( */ enum class MapOfEnumString(val value: kotlin.collections.Map<kotlin.String, kotlin.String>){ - @Json(name = "UPPER") uPPER("UPPER"), + @Json(name = "UPPER") + uPPER("UPPER"), - @Json(name = "lower") lower("lower"); + @Json(name = "lower") + lower("lower"); } diff --git a/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/MixedPropertiesAndAdditionalPropertiesClass.kt b/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/MixedPropertiesAndAdditionalPropertiesClass.kt index 74559242c8b..63bf58d8b93 100644 --- a/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/MixedPropertiesAndAdditionalPropertiesClass.kt +++ b/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/MixedPropertiesAndAdditionalPropertiesClass.kt @@ -2,7 +2,7 @@ * OpenAPI Petstore * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ * -* OpenAPI spec version: 1.0.0 +* The version of the OpenAPI document: 1.0.0 * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). @@ -13,6 +13,7 @@ package org.openapitools.client.models import org.openapitools.client.models.Animal +import com.squareup.moshi.Json /** * * @param uuid @@ -20,8 +21,11 @@ import org.openapitools.client.models.Animal * @param map */ data class MixedPropertiesAndAdditionalPropertiesClass ( + @Json(name = "uuid") val uuid: java.util.UUID? = null, + @Json(name = "dateTime") val dateTime: java.time.LocalDateTime? = null, + @Json(name = "map") val map: kotlin.collections.Map? = null ) { diff --git a/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/Model200Response.kt b/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/Model200Response.kt index 579aa048b05..42c48fa7fd1 100644 --- a/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/Model200Response.kt +++ b/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/Model200Response.kt @@ -2,7 +2,7 @@ * OpenAPI Petstore * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ * -* OpenAPI spec version: 1.0.0 +* The version of the OpenAPI document: 1.0.0 * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). @@ -12,13 +12,16 @@ package org.openapitools.client.models +import com.squareup.moshi.Json /** * Model for testing model name starting with number * @param name * @param propertyClass */ data class Model200Response ( + @Json(name = "name") val name: kotlin.Int? = null, + @Json(name = "class") val propertyClass: kotlin.String? = null ) { diff --git a/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/Name.kt b/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/Name.kt index b181422f4ce..d46b4b1c511 100644 --- a/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/Name.kt +++ b/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/Name.kt @@ -2,7 +2,7 @@ * OpenAPI Petstore * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ * -* OpenAPI spec version: 1.0.0 +* The version of the OpenAPI document: 1.0.0 * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). @@ -12,6 +12,7 @@ package org.openapitools.client.models +import com.squareup.moshi.Json /** * Model for testing model name same as property name * @param name @@ -20,9 +21,13 @@ package org.openapitools.client.models * @param `123number` */ data class Name ( + @Json(name = "name") val name: kotlin.Int, + @Json(name = "snake_case") val snakeCase: kotlin.Int? = null, + @Json(name = "property") val property: kotlin.String? = null, + @Json(name = "123Number") val `123number`: kotlin.Int? = null ) { diff --git a/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/NullableClass.kt b/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/NullableClass.kt new file mode 100644 index 00000000000..4b75b41a9d7 --- /dev/null +++ b/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/NullableClass.kt @@ -0,0 +1,59 @@ +/** +* OpenAPI Petstore +* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ +* +* The version of the OpenAPI document: 1.0.0 +* +* +* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). +* https://openapi-generator.tech +* Do not edit the class manually. +*/ +package org.openapitools.client.models + + +import com.squareup.moshi.Json +/** + * + * @param integerProp + * @param numberProp + * @param booleanProp + * @param stringProp + * @param dateProp + * @param datetimeProp + * @param arrayNullableProp + * @param arrayAndItemsNullableProp + * @param arrayItemsNullable + * @param objectNullableProp + * @param objectAndItemsNullableProp + * @param objectItemsNullable + */ +data class NullableClass ( + @Json(name = "integer_prop") + val integerProp: kotlin.Int? = null, + @Json(name = "number_prop") + val numberProp: java.math.BigDecimal? = null, + @Json(name = "boolean_prop") + val booleanProp: kotlin.Boolean? = null, + @Json(name = "string_prop") + val stringProp: kotlin.String? = null, + @Json(name = "date_prop") + val dateProp: java.time.LocalDate? = null, + @Json(name = "datetime_prop") + val datetimeProp: java.time.LocalDateTime? = null, + @Json(name = "array_nullable_prop") + val arrayNullableProp: kotlin.Array? = null, + @Json(name = "array_and_items_nullable_prop") + val arrayAndItemsNullableProp: kotlin.Array? = null, + @Json(name = "array_items_nullable") + val arrayItemsNullable: kotlin.Array? = null, + @Json(name = "object_nullable_prop") + val objectNullableProp: kotlin.collections.Map? = null, + @Json(name = "object_and_items_nullable_prop") + val objectAndItemsNullableProp: kotlin.collections.Map? = null, + @Json(name = "object_items_nullable") + val objectItemsNullable: kotlin.collections.Map? = null +) { + +} + diff --git a/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/NumberOnly.kt b/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/NumberOnly.kt index b49d4f28e6c..c8126af0848 100644 --- a/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/NumberOnly.kt +++ b/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/NumberOnly.kt @@ -2,7 +2,7 @@ * OpenAPI Petstore * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ * -* OpenAPI spec version: 1.0.0 +* The version of the OpenAPI document: 1.0.0 * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). @@ -12,11 +12,13 @@ package org.openapitools.client.models +import com.squareup.moshi.Json /** * * @param justNumber */ data class NumberOnly ( + @Json(name = "JustNumber") val justNumber: java.math.BigDecimal? = null ) { diff --git a/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/Order.kt b/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/Order.kt index 2950a744551..296d77047cc 100644 --- a/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/Order.kt +++ b/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/Order.kt @@ -2,7 +2,7 @@ * OpenAPI Petstore * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ * -* OpenAPI spec version: 1.0.0 +* The version of the OpenAPI document: 1.0.0 * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). @@ -23,12 +23,18 @@ import com.squareup.moshi.Json * @param complete */ data class Order ( + @Json(name = "id") val id: kotlin.Long? = null, + @Json(name = "petId") val petId: kotlin.Long? = null, + @Json(name = "quantity") val quantity: kotlin.Int? = null, + @Json(name = "shipDate") val shipDate: java.time.LocalDateTime? = null, /* Order Status */ + @Json(name = "status") val status: Order.Status? = null, + @Json(name = "complete") val complete: kotlin.Boolean? = null ) { @@ -38,11 +44,14 @@ data class Order ( */ enum class Status(val value: kotlin.String){ - @Json(name = "placed") placed("placed"), + @Json(name = "placed") + placed("placed"), - @Json(name = "approved") approved("approved"), + @Json(name = "approved") + approved("approved"), - @Json(name = "delivered") delivered("delivered"); + @Json(name = "delivered") + delivered("delivered"); } diff --git a/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/OuterComposite.kt b/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/OuterComposite.kt index 20b31892877..a0bc846a09b 100644 --- a/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/OuterComposite.kt +++ b/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/OuterComposite.kt @@ -2,7 +2,7 @@ * OpenAPI Petstore * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ * -* OpenAPI spec version: 1.0.0 +* The version of the OpenAPI document: 1.0.0 * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). @@ -12,6 +12,7 @@ package org.openapitools.client.models +import com.squareup.moshi.Json /** * * @param myNumber @@ -19,8 +20,11 @@ package org.openapitools.client.models * @param myBoolean */ data class OuterComposite ( + @Json(name = "my_number") val myNumber: java.math.BigDecimal? = null, + @Json(name = "my_string") val myString: kotlin.String? = null, + @Json(name = "my_boolean") val myBoolean: kotlin.Boolean? = null ) { diff --git a/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/OuterEnum.kt b/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/OuterEnum.kt index 22f42f500ec..bd3b936859f 100644 --- a/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/OuterEnum.kt +++ b/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/OuterEnum.kt @@ -2,7 +2,7 @@ * OpenAPI Petstore * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ * -* OpenAPI spec version: 1.0.0 +* The version of the OpenAPI document: 1.0.0 * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). @@ -20,11 +20,14 @@ import com.squareup.moshi.Json */ enum class OuterEnum(val value: kotlin.String){ - @Json(name = "placed") placed("placed"), + @Json(name = "placed") + placed("placed"), - @Json(name = "approved") approved("approved"), + @Json(name = "approved") + approved("approved"), - @Json(name = "delivered") delivered("delivered"); + @Json(name = "delivered") + delivered("delivered"); } diff --git a/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/OuterEnumDefaultValue.kt b/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/OuterEnumDefaultValue.kt index 12a37749139..48a990701be 100644 --- a/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/OuterEnumDefaultValue.kt +++ b/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/OuterEnumDefaultValue.kt @@ -2,7 +2,7 @@ * OpenAPI Petstore * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ * -* OpenAPI spec version: 1.0.0 +* The version of the OpenAPI document: 1.0.0 * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). @@ -20,11 +20,14 @@ import com.squareup.moshi.Json */ enum class OuterEnumDefaultValue(val value: kotlin.String){ - @Json(name = "placed") placed("placed"), + @Json(name = "placed") + placed("placed"), - @Json(name = "approved") approved("approved"), + @Json(name = "approved") + approved("approved"), - @Json(name = "delivered") delivered("delivered"); + @Json(name = "delivered") + delivered("delivered"); } diff --git a/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/OuterEnumInteger.kt b/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/OuterEnumInteger.kt index 0e61152c6d9..cbaa42709a8 100644 --- a/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/OuterEnumInteger.kt +++ b/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/OuterEnumInteger.kt @@ -2,7 +2,7 @@ * OpenAPI Petstore * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ * -* OpenAPI spec version: 1.0.0 +* The version of the OpenAPI document: 1.0.0 * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). @@ -20,11 +20,14 @@ import com.squareup.moshi.Json */ enum class OuterEnumInteger(val value: kotlin.Int){ - @Json(name = "0") _0(0), + @Json(name = "0") + _0(0), - @Json(name = "1") _1(1), + @Json(name = "1") + _1(1), - @Json(name = "2") _2(2); + @Json(name = "2") + _2(2); } diff --git a/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/OuterEnumIntegerDefaultValue.kt b/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/OuterEnumIntegerDefaultValue.kt index b5592bd8570..348b303d6cd 100644 --- a/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/OuterEnumIntegerDefaultValue.kt +++ b/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/OuterEnumIntegerDefaultValue.kt @@ -2,7 +2,7 @@ * OpenAPI Petstore * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ * -* OpenAPI spec version: 1.0.0 +* The version of the OpenAPI document: 1.0.0 * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). @@ -20,11 +20,14 @@ import com.squareup.moshi.Json */ enum class OuterEnumIntegerDefaultValue(val value: kotlin.Int){ - @Json(name = "0") _0(0), + @Json(name = "0") + _0(0), - @Json(name = "1") _1(1), + @Json(name = "1") + _1(1), - @Json(name = "2") _2(2); + @Json(name = "2") + _2(2); } diff --git a/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/Pet.kt b/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/Pet.kt index 4c3ee418894..5adf5a0e5f3 100644 --- a/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/Pet.kt +++ b/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/Pet.kt @@ -2,7 +2,7 @@ * OpenAPI Petstore * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ * -* OpenAPI spec version: 1.0.0 +* The version of the OpenAPI document: 1.0.0 * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). @@ -25,12 +25,18 @@ import com.squareup.moshi.Json * @param status pet status in the store */ data class Pet ( + @Json(name = "name") val name: kotlin.String, + @Json(name = "photoUrls") val photoUrls: kotlin.Array, + @Json(name = "id") val id: kotlin.Long? = null, + @Json(name = "category") val category: Category? = null, + @Json(name = "tags") val tags: kotlin.Array? = null, /* pet status in the store */ + @Json(name = "status") val status: Pet.Status? = null ) { @@ -40,11 +46,14 @@ data class Pet ( */ enum class Status(val value: kotlin.String){ - @Json(name = "available") available("available"), + @Json(name = "available") + available("available"), - @Json(name = "pending") pending("pending"), + @Json(name = "pending") + pending("pending"), - @Json(name = "sold") sold("sold"); + @Json(name = "sold") + sold("sold"); } diff --git a/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/ReadOnlyFirst.kt b/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/ReadOnlyFirst.kt index b923cebdc88..b47c5617c83 100644 --- a/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/ReadOnlyFirst.kt +++ b/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/ReadOnlyFirst.kt @@ -2,7 +2,7 @@ * OpenAPI Petstore * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ * -* OpenAPI spec version: 1.0.0 +* The version of the OpenAPI document: 1.0.0 * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). @@ -12,13 +12,16 @@ package org.openapitools.client.models +import com.squareup.moshi.Json /** * * @param bar * @param baz */ data class ReadOnlyFirst ( + @Json(name = "bar") val bar: kotlin.String? = null, + @Json(name = "baz") val baz: kotlin.String? = null ) { diff --git a/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/Return.kt b/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/Return.kt index f258953c49f..59a24cd8351 100644 --- a/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/Return.kt +++ b/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/Return.kt @@ -2,7 +2,7 @@ * OpenAPI Petstore * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ * -* OpenAPI spec version: 1.0.0 +* The version of the OpenAPI document: 1.0.0 * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). @@ -12,11 +12,13 @@ package org.openapitools.client.models +import com.squareup.moshi.Json /** * Model for testing reserved words * @param `return` */ data class Return ( + @Json(name = "return") val `return`: kotlin.Int? = null ) { diff --git a/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/SpecialModelname.kt b/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/SpecialModelname.kt index 47688614c78..2768460ff67 100644 --- a/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/SpecialModelname.kt +++ b/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/SpecialModelname.kt @@ -2,7 +2,7 @@ * OpenAPI Petstore * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ * -* OpenAPI spec version: 1.0.0 +* The version of the OpenAPI document: 1.0.0 * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). @@ -12,12 +12,14 @@ package org.openapitools.client.models +import com.squareup.moshi.Json /** * - * @param `$specialPropertyName` + * @param dollarSpecialLeftSquareBracketPropertyPeriodNameRightSquareBracket */ data class SpecialModelname ( - val `$specialPropertyName`: kotlin.Long? = null + @Json(name = "$special[property.name]") + val dollarSpecialLeftSquareBracketPropertyPeriodNameRightSquareBracket: kotlin.Long? = null ) { } diff --git a/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/Tag.kt b/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/Tag.kt index 8e3bc218e1b..bb7bf2ec073 100644 --- a/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/Tag.kt +++ b/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/Tag.kt @@ -2,7 +2,7 @@ * OpenAPI Petstore * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ * -* OpenAPI spec version: 1.0.0 +* The version of the OpenAPI document: 1.0.0 * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). @@ -12,13 +12,16 @@ package org.openapitools.client.models +import com.squareup.moshi.Json /** * * @param id * @param name */ data class Tag ( + @Json(name = "id") val id: kotlin.Long? = null, + @Json(name = "name") val name: kotlin.String? = null ) { diff --git a/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/User.kt b/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/User.kt index 2c77d12201f..d0384bc2069 100644 --- a/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/User.kt +++ b/samples/openapi3/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/User.kt @@ -2,7 +2,7 @@ * OpenAPI Petstore * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ * -* OpenAPI spec version: 1.0.0 +* The version of the OpenAPI document: 1.0.0 * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). @@ -12,6 +12,7 @@ package org.openapitools.client.models +import com.squareup.moshi.Json /** * * @param id @@ -24,14 +25,22 @@ package org.openapitools.client.models * @param userStatus User Status */ data class User ( + @Json(name = "id") val id: kotlin.Long? = null, + @Json(name = "username") val username: kotlin.String? = null, + @Json(name = "firstName") val firstName: kotlin.String? = null, + @Json(name = "lastName") val lastName: kotlin.String? = null, + @Json(name = "email") val email: kotlin.String? = null, + @Json(name = "password") val password: kotlin.String? = null, + @Json(name = "phone") val phone: kotlin.String? = null, /* User Status */ + @Json(name = "userStatus") val userStatus: kotlin.Int? = null ) {