File tree Expand file tree Collapse file tree 16 files changed +50
-39
lines changed
modules/swagger-codegen/src/main/resources/kotlin-client
src/main/kotlin/io/swagger/client
src/main/kotlin/io/swagger/client
src/main/kotlin/io/swagger/client Expand file tree Collapse file tree 16 files changed +50
-39
lines changed Original file line number Diff line number Diff line change
1
+ { {#hasEnums} }
2
+ import com.squareup.moshi.Json
3
+ { {/hasEnums} }
1
4
/**
2
5
* { {{description} }}
3
6
{ {#vars} }
@@ -18,7 +21,7 @@ data class {{classname}} (
18
21
*/
19
22
enum class { {nameInCamelCase} }(val value: { {datatype} }){
20
23
{{#allowableValues} }{ {#enumVars} }
21
- { {&name} }({ {{value} }}){ {^-last} },{ {/-last} }{ {#-last} };{ {/-last} }
24
+ @Json(name = { {{value } }}) { {&name} }({ {{value} }}){ {^-last} },{ {/-last} }{ {#-last} };{ {/-last} }
22
25
{ {/enumVars} }{ {/allowableValues} }
23
26
}
24
27
{ {/isEnum} }{ {/vars} }{ {/hasEnums} }
Original file line number Diff line number Diff line change
1
+ import com.squareup.moshi.Json
2
+
1
3
/**
2
4
* { {{description} }}
3
5
* Values: { {#allowableValues} }{ {#enumVars} }{ {&name} }{ {^-last} },{ {/-last} }{ {/enumVars} }{ {/allowableValues} }
4
6
*/
5
7
enum class { {classname} }(val value: { {dataType} }){
6
8
{{#allowableValues} }{ {#enumVars} }
7
- { {&name} }({ {{value} }}){ {^-last} },{ {/-last} }{ {#-last} };{ {/-last} }
9
+ @Json(name = { {{value } }}) { {&name} }({ {{value} }}){ {^-last} },{ {/-last} }{ {#-last} };{ {/-last} }
8
10
{ {/enumVars} }{ {/allowableValues} }
9
11
}
Original file line number Diff line number Diff line change @@ -213,7 +213,7 @@ Get user by user name
213
213
// import io.swagger.client.models.*
214
214
215
215
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.
217
217
try {
218
218
val result : User = apiInstance.getUserByName(username)
219
219
println (result)
@@ -230,7 +230,7 @@ try {
230
230
231
231
Name | Type | Description | Notes
232
232
------------- | ------------- | ------------- | -------------
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. |
234
234
235
235
### Return type
236
236
Original file line number Diff line number Diff line change @@ -144,7 +144,7 @@ class UserApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCl
144
144
/* *
145
145
* Get user by user name
146
146
*
147
- * @param username The name that needs to be fetched. Use user1 for testing.
147
+ * @param username The name that needs to be fetched. Use user1 for testing.
148
148
* @return User
149
149
*/
150
150
@Suppress(" UNCHECKED_CAST" )
Original file line number Diff line number Diff line change @@ -85,9 +85,9 @@ open class ApiClient(val baseUrl: String) {
85
85
RequestMethod .DELETE -> Request .Builder ().url(url).delete()
86
86
RequestMethod .GET -> Request .Builder ().url(url)
87
87
RequestMethod .HEAD -> Request .Builder ().url(url).head()
88
- RequestMethod .PATCH -> Request .Builder ().url(url).patch(requestBody(body!! , contentType))
89
- RequestMethod .PUT -> Request .Builder ().url(url).put(requestBody(body!! , contentType))
90
- RequestMethod .POST -> Request .Builder ().url(url).post(requestBody(body!! , contentType))
88
+ RequestMethod .PATCH -> Request .Builder ().url(url).patch(requestBody(body, contentType))
89
+ RequestMethod .PUT -> Request .Builder ().url(url).put(requestBody(body, contentType))
90
+ RequestMethod .POST -> Request .Builder ().url(url).post(requestBody(body, contentType))
91
91
RequestMethod .OPTIONS -> Request .Builder ().url(url).method(" OPTIONS" , null )
92
92
}
93
93
Original file line number Diff line number Diff line change 12
12
package io.swagger.client.models
13
13
14
14
15
+ import com.squareup.moshi.Json
15
16
/* *
16
17
* An order for a pets from the pet store
17
18
* @param id
@@ -35,13 +36,13 @@ data class Order (
35
36
* Order Status
36
37
* Values: placed,approved,delivered
37
38
*/
38
- enum class Status (val value : kotlin.Any ){
39
+ enum class Status (val value : kotlin.String ){
39
40
40
- placed(" placed" ),
41
+ @Json(name = " placed " ) placed(" placed" ),
41
42
42
- approved(" approved" ),
43
+ @Json(name = " approved " ) approved(" approved" ),
43
44
44
- delivered(" delivered" );
45
+ @Json(name = " delivered " ) delivered(" delivered" );
45
46
46
47
}
47
48
Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ package io.swagger.client.models
14
14
import io.swagger.client.models.Category
15
15
import io.swagger.client.models.Tag
16
16
17
+ import com.squareup.moshi.Json
17
18
/* *
18
19
* A pet for sale in the pet store
19
20
* @param id
@@ -37,13 +38,13 @@ data class Pet (
37
38
* pet status in the store
38
39
* Values: available,pending,sold
39
40
*/
40
- enum class Status (val value : kotlin.Any ){
41
+ enum class Status (val value : kotlin.String ){
41
42
42
- available(" available" ),
43
+ @Json(name = " available " ) available(" available" ),
43
44
44
- pending(" pending" ),
45
+ @Json(name = " pending " ) pending(" pending" ),
45
46
46
- sold(" sold" );
47
+ @Json(name = " sold " ) sold(" sold" );
47
48
48
49
}
49
50
Original file line number Diff line number Diff line change @@ -213,7 +213,7 @@ Get user by user name
213
213
// import io.swagger.client.models.*
214
214
215
215
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.
217
217
try {
218
218
val result : User = apiInstance.getUserByName(username)
219
219
println (result)
@@ -230,7 +230,7 @@ try {
230
230
231
231
Name | Type | Description | Notes
232
232
------------- | ------------- | ------------- | -------------
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. |
234
234
235
235
### Return type
236
236
Original file line number Diff line number Diff line change @@ -145,7 +145,7 @@ class UserApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCl
145
145
/* *
146
146
* Get user by user name
147
147
*
148
- * @param username The name that needs to be fetched. Use user1 for testing.
148
+ * @param username The name that needs to be fetched. Use user1 for testing.
149
149
* @return User
150
150
*/
151
151
@Suppress(" UNCHECKED_CAST" )
Original file line number Diff line number Diff line change @@ -85,9 +85,9 @@ open class ApiClient(val baseUrl: String) {
85
85
RequestMethod .DELETE -> Request .Builder ().url(url).delete()
86
86
RequestMethod .GET -> Request .Builder ().url(url)
87
87
RequestMethod .HEAD -> Request .Builder ().url(url).head()
88
- RequestMethod .PATCH -> Request .Builder ().url(url).patch(requestBody(body!! , contentType))
89
- RequestMethod .PUT -> Request .Builder ().url(url).put(requestBody(body!! , contentType))
90
- RequestMethod .POST -> Request .Builder ().url(url).post(requestBody(body!! , contentType))
88
+ RequestMethod .PATCH -> Request .Builder ().url(url).patch(requestBody(body, contentType))
89
+ RequestMethod .PUT -> Request .Builder ().url(url).put(requestBody(body, contentType))
90
+ RequestMethod .POST -> Request .Builder ().url(url).post(requestBody(body, contentType))
91
91
RequestMethod .OPTIONS -> Request .Builder ().url(url).method(" OPTIONS" , null )
92
92
}
93
93
You can’t perform that action at this time.
0 commit comments