Skip to content

Commit babecc1

Browse files
wing328Goopher Maijenburg
authored andcommitted
Add tests for numeric form data (kotlin - jvm-ktor) (OpenAPITools#21952)
* add tests for numeric form data (kotlin) * remove null check as its done already
1 parent 60715a3 commit babecc1

File tree

37 files changed

+1629
-88
lines changed

37 files changed

+1629
-88
lines changed

bin/configs/kotlin-jvm-ktor-gson.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
generatorName: kotlin
22
outputDir: samples/client/petstore/kotlin-jvm-ktor-gson
33
library: jvm-ktor
4-
inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore.yaml
4+
inputSpec: modules/openapi-generator/src/test/resources/3_0/kotlin/petstore.yaml
55
templateDir: modules/openapi-generator/src/main/resources/kotlin-client
66
additionalProperties:
77
artifactId: kotlin-petstore-jvm-ktor-gson

modules/openapi-generator/src/main/resources/kotlin-client/libraries/jvm-ktor/api.mustache

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,10 @@ import com.fasterxml.jackson.databind.ObjectMapper
6969
{{^isArray}}
7070
{{^isString}}
7171
{{^isNumber}}
72-
{{{paramName}}}?.apply { append("{{{baseName}}}", {{{paramName}}}?.toString()) }
72+
{{{paramName}}}?.apply { append("{{{baseName}}}", {{{paramName}}}.toString()) }
7373
{{/isNumber}}
7474
{{#isNumber}}
75-
{{{paramName}}}?.apply { append("{{{baseName}}}", {{{paramName}}}?.toString()) }
75+
{{{paramName}}}?.apply { append("{{{baseName}}}", {{{paramName}}}.toString()) }
7676
{{/isNumber}}
7777
{{/isString}}
7878
{{#isString}}
@@ -98,10 +98,10 @@ import com.fasterxml.jackson.databind.ObjectMapper
9898
{{^isArray}}
9999
{{^isString}}
100100
{{^isNumber}}
101-
{{{paramName}}}?.apply { it.append("{{{baseName}}}", {{{paramName}}}?.toString()) }
101+
{{{paramName}}}?.apply { it.append("{{{baseName}}}", {{{paramName}}}.toString()) }
102102
{{/isNumber}}
103103
{{#isNumber}}
104-
{{{paramName}}}?.apply { it.append("{{{baseName}}}", {{{paramName}}}?.toString()) }
104+
{{{paramName}}}?.apply { it.append("{{{baseName}}}", {{{paramName}}}.toString()) }
105105
{{/isNumber}}
106106
{{/isString}}
107107
{{#isString}}

modules/openapi-generator/src/test/resources/3_0/kotlin/petstore.yaml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -584,6 +584,42 @@ paths:
584584
responses:
585585
'200':
586586
description: OK
587+
put:
588+
tags:
589+
- fake
590+
summary: Updates a pet in the store with form data (number)
591+
description: ''
592+
operationId: updatePetWithFormNumber
593+
parameters:
594+
- name: petId
595+
in: path
596+
description: ID of pet that needs to be updated
597+
required: true
598+
schema:
599+
type: integer
600+
format: int64
601+
responses:
602+
'405':
603+
description: Invalid input
604+
security:
605+
- petstore_auth:
606+
- 'write:pets'
607+
- 'read:pets'
608+
requestBody:
609+
content:
610+
application/x-www-form-urlencoded:
611+
schema:
612+
type: object
613+
properties:
614+
name:
615+
description: Updated name of the pet
616+
type: string
617+
status:
618+
description: integer type
619+
type: integer
620+
status2:
621+
description: number type
622+
type: number
587623
externalDocs:
588624
description: Find out more about Swagger
589625
url: 'http://swagger.io'

samples/client/petstore/kotlin-jvm-ktor-gson/.openapi-generator/FILES

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,26 @@
11
README.md
22
build.gradle
3+
docs/Annotation.md
4+
docs/AnyOfUserOrPet.md
5+
docs/AnyOfUserOrPetOrArrayString.md
36
docs/ApiResponse.md
47
docs/Category.md
8+
docs/FakeApi.md
59
docs/Order.md
610
docs/Pet.md
711
docs/PetApi.md
812
docs/StoreApi.md
913
docs/Tag.md
1014
docs/User.md
1115
docs/UserApi.md
16+
docs/UserOrPet.md
17+
docs/UserOrPetOrArrayString.md
1218
gradle/wrapper/gradle-wrapper.jar
1319
gradle/wrapper/gradle-wrapper.properties
1420
gradlew
1521
gradlew.bat
1622
settings.gradle
23+
src/main/kotlin/org/openapitools/client/apis/FakeApi.kt
1724
src/main/kotlin/org/openapitools/client/apis/PetApi.kt
1825
src/main/kotlin/org/openapitools/client/apis/StoreApi.kt
1926
src/main/kotlin/org/openapitools/client/apis/UserApi.kt
@@ -27,9 +34,14 @@ src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt
2734
src/main/kotlin/org/openapitools/client/infrastructure/HttpResponse.kt
2835
src/main/kotlin/org/openapitools/client/infrastructure/RequestConfig.kt
2936
src/main/kotlin/org/openapitools/client/infrastructure/RequestMethod.kt
37+
src/main/kotlin/org/openapitools/client/models/Annotation.kt
38+
src/main/kotlin/org/openapitools/client/models/AnyOfUserOrPet.kt
39+
src/main/kotlin/org/openapitools/client/models/AnyOfUserOrPetOrArrayString.kt
3040
src/main/kotlin/org/openapitools/client/models/Category.kt
3141
src/main/kotlin/org/openapitools/client/models/ModelApiResponse.kt
3242
src/main/kotlin/org/openapitools/client/models/Order.kt
3343
src/main/kotlin/org/openapitools/client/models/Pet.kt
3444
src/main/kotlin/org/openapitools/client/models/Tag.kt
3545
src/main/kotlin/org/openapitools/client/models/User.kt
46+
src/main/kotlin/org/openapitools/client/models/UserOrPet.kt
47+
src/main/kotlin/org/openapitools/client/models/UserOrPetOrArrayString.kt

samples/client/petstore/kotlin-jvm-ktor-gson/README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ All URIs are relative to *http://petstore.swagger.io/v2*
4545

4646
| Class | Method | HTTP request | Description |
4747
| ------------ | ------------- | ------------- | ------------- |
48+
| *FakeApi* | [**annotations**](docs/FakeApi.md#annotations) | **POST** /fake/annotations | annotate |
49+
| *FakeApi* | [**updatePetWithFormNumber**](docs/FakeApi.md#updatepetwithformnumber) | **PUT** /fake/annotations | Updates a pet in the store with form data (number) |
4850
| *PetApi* | [**addPet**](docs/PetApi.md#addpet) | **POST** /pet | Add a new pet to the store |
4951
| *PetApi* | [**deletePet**](docs/PetApi.md#deletepet) | **DELETE** /pet/{petId} | Deletes a pet |
5052
| *PetApi* | [**findPetsByStatus**](docs/PetApi.md#findpetsbystatus) | **GET** /pet/findByStatus | Finds Pets by status |
@@ -70,12 +72,17 @@ All URIs are relative to *http://petstore.swagger.io/v2*
7072
<a id="documentation-for-models"></a>
7173
## Documentation for Models
7274

75+
- [org.openapitools.client.models.Annotation](docs/Annotation.md)
76+
- [org.openapitools.client.models.AnyOfUserOrPet](docs/AnyOfUserOrPet.md)
77+
- [org.openapitools.client.models.AnyOfUserOrPetOrArrayString](docs/AnyOfUserOrPetOrArrayString.md)
7378
- [org.openapitools.client.models.Category](docs/Category.md)
7479
- [org.openapitools.client.models.ModelApiResponse](docs/ModelApiResponse.md)
7580
- [org.openapitools.client.models.Order](docs/Order.md)
7681
- [org.openapitools.client.models.Pet](docs/Pet.md)
7782
- [org.openapitools.client.models.Tag](docs/Tag.md)
7883
- [org.openapitools.client.models.User](docs/User.md)
84+
- [org.openapitools.client.models.UserOrPet](docs/UserOrPet.md)
85+
- [org.openapitools.client.models.UserOrPetOrArrayString](docs/UserOrPetOrArrayString.md)
7986

8087

8188
<a id="documentation-for-authorization"></a>
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
2+
# Annotation
3+
4+
## Properties
5+
| Name | Type | Description | Notes |
6+
| ------------ | ------------- | ------------- | ------------- |
7+
| **id** | [**java.util.UUID**](java.util.UUID.md) | | [optional] |
8+
9+
10+
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
2+
# AnyOfUserOrPet
3+
4+
## Properties
5+
| Name | Type | Description | Notes |
6+
| ------------ | ------------- | ------------- | ------------- |
7+
| **username** | **kotlin.String** | | |
8+
| **name** | **kotlin.String** | | |
9+
| **photoUrls** | **kotlin.collections.List&lt;kotlin.String&gt;** | | |
10+
| **id** | **kotlin.Long** | | [optional] |
11+
| **firstName** | **kotlin.String** | | [optional] |
12+
| **lastName** | **kotlin.String** | | [optional] |
13+
| **email** | **kotlin.String** | | [optional] |
14+
| **password** | **kotlin.String** | | [optional] |
15+
| **phone** | **kotlin.String** | | [optional] |
16+
| **userStatus** | **kotlin.Int** | User Status | [optional] |
17+
| **category** | [**Category**](Category.md) | | [optional] |
18+
| **tags** | [**kotlin.collections.List&lt;Tag&gt;**](Tag.md) | | [optional] |
19+
| **status** | [**inline**](#Status) | pet status in the store | [optional] |
20+
21+
22+
<a id="Status"></a>
23+
## Enum: status
24+
| Name | Value |
25+
| ---- | ----- |
26+
| status | available, pending, sold |
27+
28+
29+
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
2+
# AnyOfUserOrPetOrArrayString
3+
4+
## Properties
5+
| Name | Type | Description | Notes |
6+
| ------------ | ------------- | ------------- | ------------- |
7+
| **username** | **kotlin.String** | | |
8+
| **name** | **kotlin.String** | | |
9+
| **photoUrls** | **kotlin.collections.List&lt;kotlin.String&gt;** | | |
10+
| **id** | **kotlin.Long** | | [optional] |
11+
| **firstName** | **kotlin.String** | | [optional] |
12+
| **lastName** | **kotlin.String** | | [optional] |
13+
| **email** | **kotlin.String** | | [optional] |
14+
| **password** | **kotlin.String** | | [optional] |
15+
| **phone** | **kotlin.String** | | [optional] |
16+
| **userStatus** | **kotlin.Int** | User Status | [optional] |
17+
| **category** | [**Category**](Category.md) | | [optional] |
18+
| **tags** | [**kotlin.collections.List&lt;Tag&gt;**](Tag.md) | | [optional] |
19+
| **status** | [**inline**](#Status) | pet status in the store | [optional] |
20+
21+
22+
<a id="Status"></a>
23+
## Enum: status
24+
| Name | Value |
25+
| ---- | ----- |
26+
| status | available, pending, sold |
27+
28+
29+
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
# FakeApi
2+
3+
All URIs are relative to *http://petstore.swagger.io/v2*
4+
5+
| Method | HTTP request | Description |
6+
| ------------- | ------------- | ------------- |
7+
| [**annotations**](FakeApi.md#annotations) | **POST** /fake/annotations | annotate |
8+
| [**updatePetWithFormNumber**](FakeApi.md#updatePetWithFormNumber) | **PUT** /fake/annotations | Updates a pet in the store with form data (number) |
9+
10+
11+
<a id="annotations"></a>
12+
# **annotations**
13+
> annotations(`annotation`)
14+
15+
annotate
16+
17+
### Example
18+
```kotlin
19+
// Import classes:
20+
//import org.openapitools.client.infrastructure.*
21+
//import org.openapitools.client.models.*
22+
23+
val apiInstance = FakeApi()
24+
val `annotation` : Annotation = // Annotation |
25+
try {
26+
apiInstance.annotations(`annotation`)
27+
} catch (e: ClientException) {
28+
println("4xx response calling FakeApi#annotations")
29+
e.printStackTrace()
30+
} catch (e: ServerException) {
31+
println("5xx response calling FakeApi#annotations")
32+
e.printStackTrace()
33+
}
34+
```
35+
36+
### Parameters
37+
| Name | Type | Description | Notes |
38+
| ------------- | ------------- | ------------- | ------------- |
39+
| **&#x60;annotation&#x60;** | [**Annotation**](Annotation.md)| | |
40+
41+
### Return type
42+
43+
null (empty response body)
44+
45+
### Authorization
46+
47+
No authorization required
48+
49+
### HTTP request headers
50+
51+
- **Content-Type**: application/json
52+
- **Accept**: Not defined
53+
54+
<a id="updatePetWithFormNumber"></a>
55+
# **updatePetWithFormNumber**
56+
> updatePetWithFormNumber(petId, name, status, status2)
57+
58+
Updates a pet in the store with form data (number)
59+
60+
61+
62+
### Example
63+
```kotlin
64+
// Import classes:
65+
//import org.openapitools.client.infrastructure.*
66+
//import org.openapitools.client.models.*
67+
68+
val apiInstance = FakeApi()
69+
val petId : kotlin.Long = 789 // kotlin.Long | ID of pet that needs to be updated
70+
val name : kotlin.String = name_example // kotlin.String | Updated name of the pet
71+
val status : kotlin.Int = 56 // kotlin.Int | integer type
72+
val status2 : java.math.BigDecimal = 8.14 // java.math.BigDecimal | number type
73+
try {
74+
apiInstance.updatePetWithFormNumber(petId, name, status, status2)
75+
} catch (e: ClientException) {
76+
println("4xx response calling FakeApi#updatePetWithFormNumber")
77+
e.printStackTrace()
78+
} catch (e: ServerException) {
79+
println("5xx response calling FakeApi#updatePetWithFormNumber")
80+
e.printStackTrace()
81+
}
82+
```
83+
84+
### Parameters
85+
| **petId** | **kotlin.Long**| ID of pet that needs to be updated | |
86+
| **name** | **kotlin.String**| Updated name of the pet | [optional] |
87+
| **status** | **kotlin.Int**| integer type | [optional] |
88+
| Name | Type | Description | Notes |
89+
| ------------- | ------------- | ------------- | ------------- |
90+
| **status2** | **java.math.BigDecimal**| number type | [optional] |
91+
92+
### Return type
93+
94+
null (empty response body)
95+
96+
### Authorization
97+
98+
99+
Configure petstore_auth:
100+
ApiClient.accessToken = ""
101+
102+
### HTTP request headers
103+
104+
- **Content-Type**: application/x-www-form-urlencoded
105+
- **Accept**: Not defined
106+

0 commit comments

Comments
 (0)