Skip to content

Commit 74e733f

Browse files
committed
update spec, add tests
1 parent 55761f9 commit 74e733f

File tree

17 files changed

+188
-125
lines changed

17 files changed

+188
-125
lines changed

bin/configs/kotlin-gson.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
generatorName: kotlin
22
outputDir: samples/client/petstore/kotlin-gson
3-
inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore.yaml
3+
inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore.yaml
44
templateDir: modules/openapi-generator/src/main/resources/kotlin-client
55
additionalProperties:
66
serializationLibrary: gson
77
artifactId: kotlin-petstore-gson
8+
companionObject: true

docs/generators/kotlin-spring.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
2727
|autoXSpringPaginated|Automatically add x-spring-paginated to operations that have 'page', 'size', and 'sort' query parameters. When enabled, operations with all three parameters will have Pageable support automatically applied. Operations with x-spring-paginated explicitly set to false will not be auto-detected.| |false|
2828
|basePackage|base package (invokerPackage) for generated code| |org.openapitools|
2929
|beanQualifiers|Whether to add fully-qualifier class names as bean qualifiers in @Component and @RestController annotations. May be used to prevent bean names clash if multiple generated libraries (contexts) added to single project.| |false|
30+
|companionObject|Whether to generate companion objects in data classes, enabling companion extensions.| |false|
3031
|configPackage|configuration package for generated code| |org.openapitools.configuration|
3132
|declarativeInterfaceReactiveMode|What type of reactive style to use in Spring Http declarative interface|<dl><dt>**coroutines**</dt><dd>Use kotlin-idiomatic 'suspend' functions</dd><dt>**reactor**</dt><dd>Use reactor return wrappers 'Mono' and 'Flux'</dd></dl>|coroutines|
3233
|delegatePattern|Whether to generate the server files using the delegate pattern| |false|

docs/generators/kotlin.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
2323
|artifactId|Generated artifact id (name of jar).| |kotlin-client|
2424
|artifactVersion|Generated artifact's package version.| |1.0.0|
2525
|collectionType|Option. Collection type to use|<dl><dt>**array**</dt><dd>kotlin.Array</dd><dt>**list**</dt><dd>kotlin.collections.List</dd></dl>|list|
26+
|companionObject|Whether to generate companion objects in data classes, enabling companion extensions.| |false|
2627
|dateLibrary|Option. Date library to use|<dl><dt>**threetenbp-localdatetime**</dt><dd>Threetenbp - Backport of JSR310 (jvm only, for legacy app only)</dd><dt>**kotlinx-datetime**</dt><dd>kotlinx-datetime (preferred for multiplatform)</dd><dt>**string**</dt><dd>String</dd><dt>**java8-localdatetime**</dt><dd>Java 8 native JSR310 (jvm only, for legacy app only)</dd><dt>**java8**</dt><dd>Java 8 native JSR310 (jvm only, preferred for jdk 1.8+)</dd><dt>**threetenbp**</dt><dd>Threetenbp - Backport of JSR310 (jvm only, preferred for jdk &lt; 1.8)</dd></dl>|java8|
2728
|enumPropertyNaming|Naming convention for enum properties: 'camelCase', 'PascalCase', 'snake_case', 'UPPERCASE', and 'original'| |original|
2829
|explicitApi|Generates code with explicit access modifiers to comply with Kotlin Explicit API Mode.| |false|

samples/client/petstore/java/resttemplate-springBoot4-jackson2/docs/PetApi.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ public class Example {
261261
petstore_auth.setAccessToken("YOUR ACCESS TOKEN");
262262

263263
PetApi apiInstance = new PetApi(defaultClient);
264-
Set<String> tags = Arrays.asList(); // Set<String> | Tags to filter by
264+
Set<String> tags = new LinkedHashSet<>(); // Set<String> | Tags to filter by
265265
try {
266266
Set<Pet> result = apiInstance.findPetsByTags(tags);
267267
System.out.println(result);

samples/client/petstore/java/resttemplate-springBoot4-jackson3/docs/PetApi.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ public class Example {
261261
petstore_auth.setAccessToken("YOUR ACCESS TOKEN");
262262

263263
PetApi apiInstance = new PetApi(defaultClient);
264-
Set<String> tags = Arrays.asList(); // Set<String> | Tags to filter by
264+
Set<String> tags = new LinkedHashSet<>(); // Set<String> | Tags to filter by
265265
try {
266266
Set<Pet> result = apiInstance.findPetsByTags(tags);
267267
System.out.println(result);

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

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,23 @@ All URIs are relative to *http://petstore.swagger.io/v2*
1616

1717
<a id="addPet"></a>
1818
# **addPet**
19-
> addPet(body)
19+
> Pet addPet(pet)
2020
2121
Add a new pet to the store
2222

23+
24+
2325
### Example
2426
```kotlin
2527
// Import classes:
2628
//import org.openapitools.client.infrastructure.*
2729
//import org.openapitools.client.models.*
2830

2931
val apiInstance = PetApi()
30-
val body : Pet = // Pet | Pet object that needs to be added to the store
32+
val pet : Pet = // Pet | Pet object that needs to be added to the store
3133
try {
32-
apiInstance.addPet(body)
34+
val result : Pet = apiInstance.addPet(pet)
35+
println(result)
3336
} catch (e: ClientException) {
3437
println("4xx response calling PetApi#addPet")
3538
e.printStackTrace()
@@ -42,11 +45,11 @@ try {
4245
### Parameters
4346
| Name | Type | Description | Notes |
4447
| ------------- | ------------- | ------------- | ------------- |
45-
| **body** | [**Pet**](Pet.md)| Pet object that needs to be added to the store | |
48+
| **pet** | [**Pet**](Pet.md)| Pet object that needs to be added to the store | |
4649

4750
### Return type
4851

49-
null (empty response body)
52+
[**Pet**](Pet.md)
5053

5154
### Authorization
5255

@@ -57,14 +60,16 @@ Configure petstore_auth:
5760
### HTTP request headers
5861

5962
- **Content-Type**: application/json
60-
- **Accept**: Not defined
63+
- **Accept**: application/json
6164

6265
<a id="deletePet"></a>
6366
# **deletePet**
6467
> deletePet(petId, apiKey)
6568
6669
Deletes a pet
6770

71+
72+
6873
### Example
6974
```kotlin
7075
// Import classes:
@@ -253,20 +258,23 @@ Configure api_key:
253258

254259
<a id="updatePet"></a>
255260
# **updatePet**
256-
> updatePet(body)
261+
> Pet updatePet(pet)
257262
258263
Update an existing pet
259264

265+
266+
260267
### Example
261268
```kotlin
262269
// Import classes:
263270
//import org.openapitools.client.infrastructure.*
264271
//import org.openapitools.client.models.*
265272

266273
val apiInstance = PetApi()
267-
val body : Pet = // Pet | Pet object that needs to be added to the store
274+
val pet : Pet = // Pet | Pet object that needs to be added to the store
268275
try {
269-
apiInstance.updatePet(body)
276+
val result : Pet = apiInstance.updatePet(pet)
277+
println(result)
270278
} catch (e: ClientException) {
271279
println("4xx response calling PetApi#updatePet")
272280
e.printStackTrace()
@@ -279,11 +287,11 @@ try {
279287
### Parameters
280288
| Name | Type | Description | Notes |
281289
| ------------- | ------------- | ------------- | ------------- |
282-
| **body** | [**Pet**](Pet.md)| Pet object that needs to be added to the store | |
290+
| **pet** | [**Pet**](Pet.md)| Pet object that needs to be added to the store | |
283291

284292
### Return type
285293

286-
null (empty response body)
294+
[**Pet**](Pet.md)
287295

288296
### Authorization
289297

@@ -294,14 +302,16 @@ Configure petstore_auth:
294302
### HTTP request headers
295303

296304
- **Content-Type**: application/json
297-
- **Accept**: Not defined
305+
- **Accept**: application/json
298306

299307
<a id="updatePetWithForm"></a>
300308
# **updatePetWithForm**
301309
> updatePetWithForm(petId, name, status)
302310
303311
Updates a pet in the store with form data
304312

313+
314+
305315
### Example
306316
```kotlin
307317
// Import classes:
@@ -351,6 +361,8 @@ Configure petstore_auth:
351361
352362
uploads an image
353363

364+
365+
354366
### Example
355367
```kotlin
356368
// Import classes:

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

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -149,20 +149,22 @@ No authorization required
149149

150150
<a id="placeOrder"></a>
151151
# **placeOrder**
152-
> Order placeOrder(body)
152+
> Order placeOrder(order)
153153
154154
Place an order for a pet
155155

156+
157+
156158
### Example
157159
```kotlin
158160
// Import classes:
159161
//import org.openapitools.client.infrastructure.*
160162
//import org.openapitools.client.models.*
161163

162164
val apiInstance = StoreApi()
163-
val body : Order = // Order | order placed for purchasing the pet
165+
val order : Order = // Order | order placed for purchasing the pet
164166
try {
165-
val result : Order = apiInstance.placeOrder(body)
167+
val result : Order = apiInstance.placeOrder(order)
166168
println(result)
167169
} catch (e: ClientException) {
168170
println("4xx response calling StoreApi#placeOrder")
@@ -176,7 +178,7 @@ try {
176178
### Parameters
177179
| Name | Type | Description | Notes |
178180
| ------------- | ------------- | ------------- | ------------- |
179-
| **body** | [**Order**](Order.md)| order placed for purchasing the pet | |
181+
| **order** | [**Order**](Order.md)| order placed for purchasing the pet | |
180182

181183
### Return type
182184

@@ -188,6 +190,6 @@ No authorization required
188190

189191
### HTTP request headers
190192

191-
- **Content-Type**: Not defined
193+
- **Content-Type**: application/json
192194
- **Accept**: application/json
193195

0 commit comments

Comments
 (0)