Skip to content

Commit

Permalink
[Test] Migrate samples from 2.0 Spec to 3.0 spec (OpenAPITools#9347)
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
wing328 authored Apr 29, 2021
1 parent 5d94628 commit 18cdb36
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 17 deletions.
4 changes: 2 additions & 2 deletions bin/configs/ktorm-schema.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
generatorName: ktorm-schema
outputDir: samples/schema/petstore/ktorm
inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore.yaml
inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore.yaml
templateDir: modules/openapi-generator/src/main/resources/ktorm-schema
additionalProperties:
hideGenerationTimestamp: true
importModelPackageName: org.openapitools.client.models
importModelPackageName: org.openapitools.client.models
2 changes: 1 addition & 1 deletion bin/configs/nim.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
generatorName: nim
outputDir: samples/client/petstore/nim
inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore.yaml
inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore.yaml
templateDir: modules/openapi-generator/src/main/resources/nim-client
additionalProperties:
packageName: petstore
12 changes: 8 additions & 4 deletions samples/client/petstore/nim/petstore/apis/api_pet.nim
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,12 @@ template constructResult[T](response: Response): untyped =
(none(T.typedesc), response)


proc addPet*(httpClient: HttpClient, body: Pet): Response =
proc addPet*(httpClient: HttpClient, pet: Pet): (Option[Pet], Response) =
## Add a new pet to the store
httpClient.headers["Content-Type"] = "application/json"
httpClient.post(basepath & "/pet", $(%body))

let response = httpClient.post(basepath & "/pet", $(%pet))
constructResult[Pet](response)


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


proc updatePet*(httpClient: HttpClient, body: Pet): Response =
proc updatePet*(httpClient: HttpClient, pet: Pet): (Option[Pet], Response) =
## Update an existing pet
httpClient.headers["Content-Type"] = "application/json"
httpClient.put(basepath & "/pet", $(%body))

let response = httpClient.put(basepath & "/pet", $(%pet))
constructResult[Pet](response)


proc updatePetWithForm*(httpClient: HttpClient, petId: int64, name: string, status: string): Response =
Expand Down
4 changes: 2 additions & 2 deletions samples/client/petstore/nim/petstore/apis/api_store.nim
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@ proc getOrderById*(httpClient: HttpClient, orderId: int64): (Option[Order], Resp
constructResult[Order](response)


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

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

16 changes: 8 additions & 8 deletions samples/client/petstore/nim/petstore/apis/api_user.nim
Original file line number Diff line number Diff line change
Expand Up @@ -38,22 +38,22 @@ template constructResult[T](response: Response): untyped =
(none(T.typedesc), response)


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


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


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


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


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

0 comments on commit 18cdb36

Please sign in to comment.