Skip to content

Commit 9f2e8fb

Browse files
Astakhov, AndrewAstakhov, Andrew
authored andcommitted
[Kotlin] Void Response Type Fix
1 parent 2e0b730 commit 9f2e8fb

File tree

21 files changed

+113
-44
lines changed

21 files changed

+113
-44
lines changed

modules/swagger-codegen/src/main/resources/kotlin-client/api.mustache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class {{classname}}(basePath: kotlin.String = "{{{basePath}}}") : ApiClient(base
3636
query = localVariableQuery,
3737
headers = localVariableHeaders
3838
)
39-
val response = request<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Any?{{/returnType}}>(
39+
val response = request<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Unit{{/returnType}}>(
4040
localVariableConfig,
4141
localVariableBody
4242
)

modules/swagger-codegen/src/main/resources/kotlin-client/infrastructure/ApiClient.kt.mustache

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ open class ApiClient(val baseUrl: String) {
5858
5959
if(T::class.java == java.io.File::class.java){
6060
return downloadFileFromResponse(response) as T
61+
} else if(T::class == kotlin.Unit::class) {
62+
return kotlin.Unit as T
6163
}
6264
6365
var contentType = response.headers().get("Content-Type")

samples/client/petstore/kotlin/README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ This runs all tests and packages the library.
3131
<a name="documentation-for-api-endpoints"></a>
3232
## Documentation for API Endpoints
3333

34-
All URIs are relative to *https://petstore.swagger.io/v2*
34+
All URIs are relative to *http://petstore.swagger.io/v2*
3535

3636
Class | Method | HTTP request | Description
3737
------------ | ------------- | ------------- | -------------
@@ -60,8 +60,10 @@ Class | Method | HTTP request | Description
6060
<a name="documentation-for-models"></a>
6161
## Documentation for Models
6262

63+
- [io.swagger.client.models.Amount](docs/Amount.md)
6364
- [io.swagger.client.models.ApiResponse](docs/ApiResponse.md)
6465
- [io.swagger.client.models.Category](docs/Category.md)
66+
- [io.swagger.client.models.Currency](docs/Currency.md)
6567
- [io.swagger.client.models.Order](docs/Order.md)
6668
- [io.swagger.client.models.Pet](docs/Pet.md)
6769
- [io.swagger.client.models.Tag](docs/Tag.md)
@@ -83,7 +85,7 @@ Class | Method | HTTP request | Description
8385

8486
- **Type**: OAuth
8587
- **Flow**: implicit
86-
- **Authorization URL**: https://petstore.swagger.io/oauth/dialog
88+
- **Authorization URL**: http://petstore.swagger.io/api/oauth/dialog
8789
- **Scopes**:
8890
- write:pets: modify pets in your account
8991
- read:pets: read your pets
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
2+
# Amount
3+
4+
## Properties
5+
Name | Type | Description | Notes
6+
------------ | ------------- | ------------- | -------------
7+
**value** | **kotlin.Double** | some description |
8+
**currency** | [**Currency**](Currency.md) | |
9+
10+
11+
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
2+
# Currency
3+
4+
## Properties
5+
Name | Type | Description | Notes
6+
------------ | ------------- | ------------- | -------------
7+
8+
9+

samples/client/petstore/kotlin/docs/PetApi.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# PetApi
22

3-
All URIs are relative to *https://petstore.swagger.io/v2*
3+
All URIs are relative to *http://petstore.swagger.io/v2*
44

55
Method | HTTP request | Description
66
------------- | ------------- | -------------
@@ -161,7 +161,7 @@ Name | Type | Description | Notes
161161
162162
Finds Pets by tags
163163

164-
Muliple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
164+
Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
165165

166166
### Example
167167
```kotlin

samples/client/petstore/kotlin/docs/StoreApi.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# StoreApi
22

3-
All URIs are relative to *https://petstore.swagger.io/v2*
3+
All URIs are relative to *http://petstore.swagger.io/v2*
44

55
Method | HTTP request | Description
66
------------- | ------------- | -------------
@@ -16,7 +16,7 @@ Method | HTTP request | Description
1616
1717
Delete purchase order by ID
1818

19-
For valid response try integer IDs with positive integer value. Negative or non-integer values will generate API errors
19+
For valid response try integer IDs with value &lt; 1000. Anything above 1000 or nonintegers will generate API errors
2020

2121
### Example
2222
```kotlin
@@ -25,7 +25,7 @@ For valid response try integer IDs with positive integer value. Negative or non-
2525
//import io.swagger.client.models.*
2626

2727
val apiInstance = StoreApi()
28-
val orderId : kotlin.Long = 789 // kotlin.Long | ID of the order that needs to be deleted
28+
val orderId : kotlin.String = orderId_example // kotlin.String | ID of the order that needs to be deleted
2929
try {
3030
apiInstance.deleteOrder(orderId)
3131
} catch (e: ClientException) {
@@ -41,7 +41,7 @@ try {
4141

4242
Name | Type | Description | Notes
4343
------------- | ------------- | ------------- | -------------
44-
**orderId** | **kotlin.Long**| ID of the order that needs to be deleted |
44+
**orderId** | **kotlin.String**| ID of the order that needs to be deleted |
4545

4646
### Return type
4747

@@ -105,7 +105,7 @@ This endpoint does not need any parameter.
105105
106106
Find purchase order by ID
107107

108-
For valid response try integer IDs with value &gt;&#x3D; 1 and &lt;&#x3D; 10. Other values will generated exceptions
108+
For valid response try integer IDs with value &lt;&#x3D; 5 or &gt; 10. Other values will generated exceptions
109109

110110
### Example
111111
```kotlin

samples/client/petstore/kotlin/docs/UserApi.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# UserApi
22

3-
All URIs are relative to *https://petstore.swagger.io/v2*
3+
All URIs are relative to *http://petstore.swagger.io/v2*
44

55
Method | HTTP request | Description
66
------------- | ------------- | -------------
@@ -213,7 +213,7 @@ Get user by user name
213213
//import io.swagger.client.models.*
214214

215215
val apiInstance = UserApi()
216-
val username : kotlin.String = username_example // kotlin.String | The name that needs to be fetched. Use user1 for testing.
216+
val username : kotlin.String = username_example // kotlin.String | The name that needs to be fetched. Use user1 for testing.
217217
try {
218218
val result : User = apiInstance.getUserByName(username)
219219
println(result)
@@ -230,7 +230,7 @@ try {
230230

231231
Name | Type | Description | Notes
232232
------------- | ------------- | ------------- | -------------
233-
**username** | **kotlin.String**| The name that needs to be fetched. Use user1 for testing. |
233+
**username** | **kotlin.String**| The name that needs to be fetched. Use user1 for testing. |
234234

235235
### Return type
236236

@@ -351,7 +351,7 @@ This can only be done by the logged in user.
351351
//import io.swagger.client.models.*
352352

353353
val apiInstance = UserApi()
354-
val username : kotlin.String = username_example // kotlin.String | name that need to be updated
354+
val username : kotlin.String = username_example // kotlin.String | name that need to be deleted
355355
val body : User = // User | Updated user object
356356
try {
357357
apiInstance.updateUser(username, body)
@@ -368,7 +368,7 @@ try {
368368

369369
Name | Type | Description | Notes
370370
------------- | ------------- | ------------- | -------------
371-
**username** | **kotlin.String**| name that need to be updated |
371+
**username** | **kotlin.String**| name that need to be deleted |
372372
**body** | [**User**](User.md)| Updated user object |
373373

374374
### Return type
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
rootProject.name = 'kotlin-client'
1+
rootProject.name = 'kotlin-petstore-client'

samples/client/petstore/kotlin/src/main/kotlin/io/swagger/client/apis/PetApi.kt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import io.swagger.client.models.Pet
1616

1717
import io.swagger.client.infrastructure.*
1818

19-
class PetApi(basePath: kotlin.String = "https://petstore.swagger.io/v2") : ApiClient(basePath) {
19+
class PetApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiClient(basePath) {
2020

2121
/**
2222
* Add a new pet to the store
@@ -40,7 +40,7 @@ class PetApi(basePath: kotlin.String = "https://petstore.swagger.io/v2") : ApiCl
4040
query = localVariableQuery,
4141
headers = localVariableHeaders
4242
)
43-
val response = request<Any?>(
43+
val response = request<Unit>(
4444
localVariableConfig,
4545
localVariableBody
4646
)
@@ -78,7 +78,7 @@ class PetApi(basePath: kotlin.String = "https://petstore.swagger.io/v2") : ApiCl
7878
query = localVariableQuery,
7979
headers = localVariableHeaders
8080
)
81-
val response = request<Any?>(
81+
val response = request<Unit>(
8282
localVariableConfig,
8383
localVariableBody
8484
)
@@ -102,7 +102,7 @@ class PetApi(basePath: kotlin.String = "https://petstore.swagger.io/v2") : ApiCl
102102
@Suppress("UNCHECKED_CAST")
103103
fun findPetsByStatus(status: kotlin.Array<kotlin.String>) : kotlin.Array<Pet> {
104104
val localVariableBody: kotlin.Any? = null
105-
val localVariableQuery: MultiValueMap = mapOf("status" to toMultiValue(status.toList(), "multi"))
105+
val localVariableQuery: MultiValueMap = mapOf("status" to toMultiValue(status.toList(), "csv"))
106106

107107
val contentHeaders: kotlin.collections.Map<kotlin.String,kotlin.String> = mapOf()
108108
val acceptsHeaders: kotlin.collections.Map<kotlin.String,kotlin.String> = mapOf("Accept" to "application/xml, application/json")
@@ -133,14 +133,14 @@ class PetApi(basePath: kotlin.String = "https://petstore.swagger.io/v2") : ApiCl
133133

134134
/**
135135
* Finds Pets by tags
136-
* Muliple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
136+
* Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
137137
* @param tags Tags to filter by
138138
* @return kotlin.Array<Pet>
139139
*/
140140
@Suppress("UNCHECKED_CAST")
141141
fun findPetsByTags(tags: kotlin.Array<kotlin.String>) : kotlin.Array<Pet> {
142142
val localVariableBody: kotlin.Any? = null
143-
val localVariableQuery: MultiValueMap = mapOf("tags" to toMultiValue(tags.toList(), "multi"))
143+
val localVariableQuery: MultiValueMap = mapOf("tags" to toMultiValue(tags.toList(), "csv"))
144144

145145
val contentHeaders: kotlin.collections.Map<kotlin.String,kotlin.String> = mapOf()
146146
val acceptsHeaders: kotlin.collections.Map<kotlin.String,kotlin.String> = mapOf("Accept" to "application/xml, application/json")
@@ -229,7 +229,7 @@ class PetApi(basePath: kotlin.String = "https://petstore.swagger.io/v2") : ApiCl
229229
query = localVariableQuery,
230230
headers = localVariableHeaders
231231
)
232-
val response = request<Any?>(
232+
val response = request<Unit>(
233233
localVariableConfig,
234234
localVariableBody
235235
)
@@ -268,7 +268,7 @@ class PetApi(basePath: kotlin.String = "https://petstore.swagger.io/v2") : ApiCl
268268
query = localVariableQuery,
269269
headers = localVariableHeaders
270270
)
271-
val response = request<Any?>(
271+
val response = request<Unit>(
272272
localVariableConfig,
273273
localVariableBody
274274
)

0 commit comments

Comments
 (0)