Skip to content

Commit 18cdb36

Browse files
authored
[Test] Migrate samples from 2.0 Spec to 3.0 spec (#9347)
* nim petstore to use 3.0 spec * ktorm to use 3.0 spec * update c petstore to use 3.0 spec * Revert "update c petstore to use 3.0 spec" This reverts commit a8ff051.
1 parent 5d94628 commit 18cdb36

5 files changed

Lines changed: 21 additions & 17 deletions

File tree

bin/configs/ktorm-schema.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
generatorName: ktorm-schema
22
outputDir: samples/schema/petstore/ktorm
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/ktorm-schema
55
additionalProperties:
66
hideGenerationTimestamp: true
7-
importModelPackageName: org.openapitools.client.models
7+
importModelPackageName: org.openapitools.client.models

bin/configs/nim.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
generatorName: nim
22
outputDir: samples/client/petstore/nim
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/nim-client
55
additionalProperties:
66
packageName: petstore

samples/client/petstore/nim/petstore/apis/api_pet.nim

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,12 @@ template constructResult[T](response: Response): untyped =
3939
(none(T.typedesc), response)
4040

4141

42-
proc addPet*(httpClient: HttpClient, body: Pet): Response =
42+
proc addPet*(httpClient: HttpClient, pet: Pet): (Option[Pet], Response) =
4343
## Add a new pet to the store
4444
httpClient.headers["Content-Type"] = "application/json"
45-
httpClient.post(basepath & "/pet", $(%body))
45+
46+
let response = httpClient.post(basepath & "/pet", $(%pet))
47+
constructResult[Pet](response)
4648

4749

4850
proc deletePet*(httpClient: HttpClient, petId: int64, apiKey: string): Response =
@@ -78,10 +80,12 @@ proc getPetById*(httpClient: HttpClient, petId: int64): (Option[Pet], Response)
7880
constructResult[Pet](response)
7981

8082

81-
proc updatePet*(httpClient: HttpClient, body: Pet): Response =
83+
proc updatePet*(httpClient: HttpClient, pet: Pet): (Option[Pet], Response) =
8284
## Update an existing pet
8385
httpClient.headers["Content-Type"] = "application/json"
84-
httpClient.put(basepath & "/pet", $(%body))
86+
87+
let response = httpClient.put(basepath & "/pet", $(%pet))
88+
constructResult[Pet](response)
8589

8690

8791
proc updatePetWithForm*(httpClient: HttpClient, petId: int64, name: string, status: string): Response =

samples/client/petstore/nim/petstore/apis/api_store.nim

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,10 @@ proc getOrderById*(httpClient: HttpClient, orderId: int64): (Option[Order], Resp
5757
constructResult[Order](response)
5858

5959

60-
proc placeOrder*(httpClient: HttpClient, body: Order): (Option[Order], Response) =
60+
proc placeOrder*(httpClient: HttpClient, order: Order): (Option[Order], Response) =
6161
## Place an order for a pet
6262
httpClient.headers["Content-Type"] = "application/json"
6363

64-
let response = httpClient.post(basepath & "/store/order", $(%body))
64+
let response = httpClient.post(basepath & "/store/order", $(%order))
6565
constructResult[Order](response)
6666

samples/client/petstore/nim/petstore/apis/api_user.nim

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,22 +38,22 @@ template constructResult[T](response: Response): untyped =
3838
(none(T.typedesc), response)
3939

4040

41-
proc createUser*(httpClient: HttpClient, body: User): Response =
41+
proc createUser*(httpClient: HttpClient, user: User): Response =
4242
## Create user
4343
httpClient.headers["Content-Type"] = "application/json"
44-
httpClient.post(basepath & "/user", $(%body))
44+
httpClient.post(basepath & "/user", $(%user))
4545

4646

47-
proc createUsersWithArrayInput*(httpClient: HttpClient, body: seq[User]): Response =
47+
proc createUsersWithArrayInput*(httpClient: HttpClient, user: seq[User]): Response =
4848
## Creates list of users with given input array
4949
httpClient.headers["Content-Type"] = "application/json"
50-
httpClient.post(basepath & "/user/createWithArray", $(%body))
50+
httpClient.post(basepath & "/user/createWithArray", $(%user))
5151

5252

53-
proc createUsersWithListInput*(httpClient: HttpClient, body: seq[User]): Response =
53+
proc createUsersWithListInput*(httpClient: HttpClient, user: seq[User]): Response =
5454
## Creates list of users with given input array
5555
httpClient.headers["Content-Type"] = "application/json"
56-
httpClient.post(basepath & "/user/createWithList", $(%body))
56+
httpClient.post(basepath & "/user/createWithList", $(%user))
5757

5858

5959
proc deleteUser*(httpClient: HttpClient, username: string): Response =
@@ -84,8 +84,8 @@ proc logoutUser*(httpClient: HttpClient): Response =
8484
httpClient.get(basepath & "/user/logout")
8585

8686

87-
proc updateUser*(httpClient: HttpClient, username: string, body: User): Response =
87+
proc updateUser*(httpClient: HttpClient, username: string, user: User): Response =
8888
## Updated user
8989
httpClient.headers["Content-Type"] = "application/json"
90-
httpClient.put(basepath & fmt"/user/{username}", $(%body))
90+
httpClient.put(basepath & fmt"/user/{username}", $(%user))
9191

0 commit comments

Comments
 (0)