Skip to content

Commit 0c47ca2

Browse files
committed
use 3.0 petstore test spec
1 parent d55b57f commit 0c47ca2

File tree

13 files changed

+208
-134
lines changed

13 files changed

+208
-134
lines changed

bin/configs/kotlin-spring-boot-reactive.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
generatorName: kotlin-spring
22
outputDir: samples/server/petstore/kotlin-springboot-reactive
33
library: spring-boot
4-
inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore.yaml
4+
inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore.yaml
55
templateDir: modules/openapi-generator/src/main/resources/kotlin-spring
66
additionalProperties:
77
documentationProvider: springdoc

samples/server/petstore/kotlin-springboot-reactive/src/main/kotlin/org/openapitools/api/PetApiController.kt

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,18 @@ class PetApiController(@Autowired(required = true) val service: PetApiService) {
4040
operationId = "addPet",
4141
description = """""",
4242
responses = [
43+
ApiResponse(responseCode = "200", description = "successful operation", content = [Content(schema = Schema(implementation = Pet::class))]),
4344
ApiResponse(responseCode = "405", description = "Invalid input") ],
4445
security = [ SecurityRequirement(name = "petstore_auth", scopes = [ "write:pets", "read:pets" ]) ]
4546
)
4647
@RequestMapping(
4748
method = [RequestMethod.POST],
4849
value = ["/pet"],
50+
produces = ["application/xml", "application/json"],
4951
consumes = ["application/json", "application/xml"]
5052
)
51-
suspend fun addPet(@Parameter(description = "Pet object that needs to be added to the store", required = true) @Valid @RequestBody body: Pet): ResponseEntity<Unit> {
52-
return ResponseEntity(service.addPet(body), HttpStatus.valueOf(405))
53+
suspend fun addPet(@Parameter(description = "Pet object that needs to be added to the store", required = true) @Valid @RequestBody pet: Pet): ResponseEntity<Pet> {
54+
return ResponseEntity(service.addPet(pet), HttpStatus.valueOf(200))
5355
}
5456

5557
@Operation(
@@ -75,14 +77,14 @@ class PetApiController(@Autowired(required = true) val service: PetApiService) {
7577
responses = [
7678
ApiResponse(responseCode = "200", description = "successful operation", content = [Content(array = ArraySchema(schema = Schema(implementation = Pet::class)))]),
7779
ApiResponse(responseCode = "400", description = "Invalid status value") ],
78-
security = [ SecurityRequirement(name = "petstore_auth", scopes = [ "write:pets", "read:pets" ]) ]
80+
security = [ SecurityRequirement(name = "petstore_auth", scopes = [ "read:pets" ]) ]
7981
)
8082
@RequestMapping(
8183
method = [RequestMethod.GET],
8284
value = ["/pet/findByStatus"],
8385
produces = ["application/xml", "application/json"]
8486
)
85-
fun findPetsByStatus(@NotNull @Parameter(description = "Status values that need to be considered for filter", required = true, schema = Schema(allowableValues = ["available", "pending", "sold"])) @Valid @RequestParam(value = "status", required = true) status: kotlin.collections.List<kotlin.String>): ResponseEntity<Flow<Pet>> {
87+
fun findPetsByStatus(@NotNull @Parameter(description = "Status values that need to be considered for filter", required = true, schema = Schema(allowableValues = ["available", "pending", "sold"])) @Valid @RequestParam(value = "status", required = true) status: kotlin.collections.List<kotlin.String>): ResponseEntity<List<Pet>> {
8688
return ResponseEntity(service.findPetsByStatus(status), HttpStatus.valueOf(200))
8789
}
8890

@@ -93,14 +95,14 @@ class PetApiController(@Autowired(required = true) val service: PetApiService) {
9395
responses = [
9496
ApiResponse(responseCode = "200", description = "successful operation", content = [Content(array = ArraySchema(schema = Schema(implementation = Pet::class)))]),
9597
ApiResponse(responseCode = "400", description = "Invalid tag value") ],
96-
security = [ SecurityRequirement(name = "petstore_auth", scopes = [ "write:pets", "read:pets" ]) ]
98+
security = [ SecurityRequirement(name = "petstore_auth", scopes = [ "read:pets" ]) ]
9799
)
98100
@RequestMapping(
99101
method = [RequestMethod.GET],
100102
value = ["/pet/findByTags"],
101103
produces = ["application/xml", "application/json"]
102104
)
103-
fun findPetsByTags(@NotNull @Parameter(description = "Tags to filter by", required = true) @Valid @RequestParam(value = "tags", required = true) tags: kotlin.collections.List<kotlin.String>): ResponseEntity<Flow<Pet>> {
105+
fun findPetsByTags(@NotNull @Parameter(description = "Tags to filter by", required = true) @Valid @RequestParam(value = "tags", required = true) tags: kotlin.collections.List<kotlin.String>): ResponseEntity<List<Pet>> {
104106
return ResponseEntity(service.findPetsByTags(tags), HttpStatus.valueOf(200))
105107
}
106108

@@ -128,6 +130,7 @@ class PetApiController(@Autowired(required = true) val service: PetApiService) {
128130
operationId = "updatePet",
129131
description = """""",
130132
responses = [
133+
ApiResponse(responseCode = "200", description = "successful operation", content = [Content(schema = Schema(implementation = Pet::class))]),
131134
ApiResponse(responseCode = "400", description = "Invalid ID supplied"),
132135
ApiResponse(responseCode = "404", description = "Pet not found"),
133136
ApiResponse(responseCode = "405", description = "Validation exception") ],
@@ -136,10 +139,11 @@ class PetApiController(@Autowired(required = true) val service: PetApiService) {
136139
@RequestMapping(
137140
method = [RequestMethod.PUT],
138141
value = ["/pet"],
142+
produces = ["application/xml", "application/json"],
139143
consumes = ["application/json", "application/xml"]
140144
)
141-
suspend fun updatePet(@Parameter(description = "Pet object that needs to be added to the store", required = true) @Valid @RequestBody body: Pet): ResponseEntity<Unit> {
142-
return ResponseEntity(service.updatePet(body), HttpStatus.valueOf(400))
145+
suspend fun updatePet(@Parameter(description = "Pet object that needs to be added to the store", required = true) @Valid @RequestBody pet: Pet): ResponseEntity<Pet> {
146+
return ResponseEntity(service.updatePet(pet), HttpStatus.valueOf(200))
143147
}
144148

145149
@Operation(

samples/server/petstore/kotlin-springboot-reactive/src/main/kotlin/org/openapitools/api/PetApiService.kt

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,18 @@ interface PetApiService {
88

99
/**
1010
* POST /pet : Add a new pet to the store
11+
*
1112
*
12-
* @param body Pet object that needs to be added to the store (required)
13-
* @return Invalid input (status code 405)
13+
* @param pet Pet object that needs to be added to the store (required)
14+
* @return successful operation (status code 200)
15+
* or Invalid input (status code 405)
1416
* @see PetApi#addPet
1517
*/
16-
suspend fun addPet(body: Pet): Unit
18+
suspend fun addPet(pet: Pet): Pet
1719

1820
/**
1921
* DELETE /pet/{petId} : Deletes a pet
22+
*
2023
*
2124
* @param petId Pet id to delete (required)
2225
* @param apiKey (optional)
@@ -34,7 +37,7 @@ interface PetApiService {
3437
* or Invalid status value (status code 400)
3538
* @see PetApi#findPetsByStatus
3639
*/
37-
fun findPetsByStatus(status: kotlin.collections.List<kotlin.String>): Flow<Pet>
40+
fun findPetsByStatus(status: kotlin.collections.List<kotlin.String>): List<Pet>
3841

3942
/**
4043
* GET /pet/findByTags : Finds Pets by tags
@@ -46,7 +49,7 @@ interface PetApiService {
4649
* @deprecated
4750
* @see PetApi#findPetsByTags
4851
*/
49-
fun findPetsByTags(tags: kotlin.collections.List<kotlin.String>): Flow<Pet>
52+
fun findPetsByTags(tags: kotlin.collections.List<kotlin.String>): List<Pet>
5053

5154
/**
5255
* GET /pet/{petId} : Find pet by ID
@@ -62,17 +65,22 @@ interface PetApiService {
6265

6366
/**
6467
* PUT /pet : Update an existing pet
68+
*
6569
*
66-
* @param body Pet object that needs to be added to the store (required)
67-
* @return Invalid ID supplied (status code 400)
70+
* @param pet Pet object that needs to be added to the store (required)
71+
* @return successful operation (status code 200)
72+
* or Invalid ID supplied (status code 400)
6873
* or Pet not found (status code 404)
6974
* or Validation exception (status code 405)
75+
* API documentation for the updatePet operation
76+
* @see <a href="http://petstore.swagger.io/v2/doc/updatePet">Update an existing pet Documentation</a>
7077
* @see PetApi#updatePet
7178
*/
72-
suspend fun updatePet(body: Pet): Unit
79+
suspend fun updatePet(pet: Pet): Pet
7380

7481
/**
7582
* POST /pet/{petId} : Updates a pet in the store with form data
83+
*
7684
*
7785
* @param petId ID of pet that needs to be updated (required)
7886
* @param name Updated name of the pet (optional)
@@ -84,6 +92,7 @@ interface PetApiService {
8492

8593
/**
8694
* POST /pet/{petId}/uploadImage : uploads an image
95+
*
8796
*
8897
* @param petId ID of pet to update (required)
8998
* @param additionalMetadata Additional data to pass to server (optional)

samples/server/petstore/kotlin-springboot-reactive/src/main/kotlin/org/openapitools/api/PetApiServiceImpl.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,27 +7,27 @@ import org.springframework.stereotype.Service
77
@Service
88
class PetApiServiceImpl : PetApiService {
99

10-
override suspend fun addPet(body: Pet): Unit {
10+
override suspend fun addPet(pet: Pet): Pet {
1111
TODO("Implement me")
1212
}
1313

1414
override suspend fun deletePet(petId: kotlin.Long, apiKey: kotlin.String?): Unit {
1515
TODO("Implement me")
1616
}
1717

18-
override fun findPetsByStatus(status: kotlin.collections.List<kotlin.String>): Flow<Pet> {
18+
override fun findPetsByStatus(status: kotlin.collections.List<kotlin.String>): List<Pet> {
1919
TODO("Implement me")
2020
}
2121

22-
override fun findPetsByTags(tags: kotlin.collections.List<kotlin.String>): Flow<Pet> {
22+
override fun findPetsByTags(tags: kotlin.collections.List<kotlin.String>): List<Pet> {
2323
TODO("Implement me")
2424
}
2525

2626
override suspend fun getPetById(petId: kotlin.Long): Pet {
2727
TODO("Implement me")
2828
}
2929

30-
override suspend fun updatePet(body: Pet): Unit {
30+
override suspend fun updatePet(pet: Pet): Pet {
3131
TODO("Implement me")
3232
}
3333

samples/server/petstore/kotlin-springboot-reactive/src/main/kotlin/org/openapitools/api/StoreApiController.kt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,10 @@ class StoreApiController(@Autowired(required = true) val service: StoreApiServic
9696
@RequestMapping(
9797
method = [RequestMethod.POST],
9898
value = ["/store/order"],
99-
produces = ["application/xml", "application/json"]
99+
produces = ["application/xml", "application/json"],
100+
consumes = ["application/json"]
100101
)
101-
suspend fun placeOrder(@Parameter(description = "order placed for purchasing the pet", required = true) @Valid @RequestBody body: Order): ResponseEntity<Order> {
102-
return ResponseEntity(service.placeOrder(body), HttpStatus.valueOf(200))
102+
suspend fun placeOrder(@Parameter(description = "order placed for purchasing the pet", required = true) @Valid @RequestBody order: Order): ResponseEntity<Order> {
103+
return ResponseEntity(service.placeOrder(order), HttpStatus.valueOf(200))
103104
}
104105
}

samples/server/petstore/kotlin-springboot-reactive/src/main/kotlin/org/openapitools/api/StoreApiService.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,12 @@ interface StoreApiService {
3939

4040
/**
4141
* POST /store/order : Place an order for a pet
42+
*
4243
*
43-
* @param body order placed for purchasing the pet (required)
44+
* @param order order placed for purchasing the pet (required)
4445
* @return successful operation (status code 200)
4546
* or Invalid Order (status code 400)
4647
* @see StoreApi#placeOrder
4748
*/
48-
suspend fun placeOrder(body: Order): Order
49+
suspend fun placeOrder(order: Order): Order
4950
}

samples/server/petstore/kotlin-springboot-reactive/src/main/kotlin/org/openapitools/api/StoreApiServiceImpl.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class StoreApiServiceImpl : StoreApiService {
1818
TODO("Implement me")
1919
}
2020

21-
override suspend fun placeOrder(body: Order): Order {
21+
override suspend fun placeOrder(order: Order): Order {
2222
TODO("Implement me")
2323
}
2424
}

samples/server/petstore/kotlin-springboot-reactive/src/main/kotlin/org/openapitools/api/UserApiController.kt

Lines changed: 29 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -39,44 +39,50 @@ class UserApiController(@Autowired(required = true) val service: UserApiService)
3939
operationId = "createUser",
4040
description = """This can only be done by the logged in user.""",
4141
responses = [
42-
ApiResponse(responseCode = "200", description = "successful operation") ]
42+
ApiResponse(responseCode = "200", description = "successful operation") ],
43+
security = [ SecurityRequirement(name = "api_key") ]
4344
)
4445
@RequestMapping(
4546
method = [RequestMethod.POST],
46-
value = ["/user"]
47+
value = ["/user"],
48+
consumes = ["application/json"]
4749
)
48-
suspend fun createUser(@Parameter(description = "Created user object", required = true) @Valid @RequestBody body: User): ResponseEntity<Unit> {
49-
return ResponseEntity(service.createUser(body), HttpStatus.valueOf(200))
50+
suspend fun createUser(@Parameter(description = "Created user object", required = true) @Valid @RequestBody user: User): ResponseEntity<Unit> {
51+
return ResponseEntity(service.createUser(user), HttpStatus.valueOf(200))
5052
}
5153

5254
@Operation(
5355
summary = "Creates list of users with given input array",
5456
operationId = "createUsersWithArrayInput",
5557
description = """""",
5658
responses = [
57-
ApiResponse(responseCode = "200", description = "successful operation") ]
59+
ApiResponse(responseCode = "200", description = "successful operation") ],
60+
security = [ SecurityRequirement(name = "api_key") ]
5861
)
5962
@RequestMapping(
6063
method = [RequestMethod.POST],
61-
value = ["/user/createWithArray"]
64+
value = ["/user/createWithArray"],
65+
consumes = ["application/json"]
6266
)
63-
suspend fun createUsersWithArrayInput(@Parameter(description = "List of user object", required = true) @Valid @RequestBody body: Flow<User>): ResponseEntity<Unit> {
64-
return ResponseEntity(service.createUsersWithArrayInput(body), HttpStatus.valueOf(200))
67+
suspend fun createUsersWithArrayInput(@Parameter(description = "List of user object", required = true) @Valid @RequestBody user: Flow<User>): ResponseEntity<Unit> {
68+
return ResponseEntity(service.createUsersWithArrayInput(user), HttpStatus.valueOf(200))
6569
}
6670

6771
@Operation(
6872
summary = "Creates list of users with given input array",
6973
operationId = "createUsersWithListInput",
7074
description = """""",
7175
responses = [
72-
ApiResponse(responseCode = "200", description = "successful operation") ]
76+
ApiResponse(responseCode = "200", description = "successful operation") ],
77+
security = [ SecurityRequirement(name = "api_key") ]
7378
)
7479
@RequestMapping(
7580
method = [RequestMethod.POST],
76-
value = ["/user/createWithList"]
81+
value = ["/user/createWithList"],
82+
consumes = ["application/json"]
7783
)
78-
suspend fun createUsersWithListInput(@Parameter(description = "List of user object", required = true) @Valid @RequestBody body: Flow<User>): ResponseEntity<Unit> {
79-
return ResponseEntity(service.createUsersWithListInput(body), HttpStatus.valueOf(200))
84+
suspend fun createUsersWithListInput(@Parameter(description = "List of user object", required = true) @Valid @RequestBody user: Flow<User>): ResponseEntity<Unit> {
85+
return ResponseEntity(service.createUsersWithListInput(user), HttpStatus.valueOf(200))
8086
}
8187

8288
@Operation(
@@ -85,7 +91,8 @@ class UserApiController(@Autowired(required = true) val service: UserApiService)
8591
description = """This can only be done by the logged in user.""",
8692
responses = [
8793
ApiResponse(responseCode = "400", description = "Invalid username supplied"),
88-
ApiResponse(responseCode = "404", description = "User not found") ]
94+
ApiResponse(responseCode = "404", description = "User not found") ],
95+
security = [ SecurityRequirement(name = "api_key") ]
8996
)
9097
@RequestMapping(
9198
method = [RequestMethod.DELETE],
@@ -126,7 +133,7 @@ class UserApiController(@Autowired(required = true) val service: UserApiService)
126133
value = ["/user/login"],
127134
produces = ["application/xml", "application/json"]
128135
)
129-
suspend fun loginUser(@NotNull @Parameter(description = "The user name for login", required = true) @Valid @RequestParam(value = "username", required = true) username: kotlin.String,@NotNull @Parameter(description = "The password for login in clear text", required = true) @Valid @RequestParam(value = "password", required = true) password: kotlin.String): ResponseEntity<kotlin.String> {
136+
suspend fun loginUser(@NotNull @Pattern(regexp="^[a-zA-Z0-9]+[a-zA-Z0-9\\.\\-_]*[a-zA-Z0-9]+$") @Parameter(description = "The user name for login", required = true) @Valid @RequestParam(value = "username", required = true) username: kotlin.String,@NotNull @Parameter(description = "The password for login in clear text", required = true) @Valid @RequestParam(value = "password", required = true) password: kotlin.String): ResponseEntity<kotlin.String> {
130137
return ResponseEntity(service.loginUser(username, password), HttpStatus.valueOf(200))
131138
}
132139

@@ -135,7 +142,8 @@ class UserApiController(@Autowired(required = true) val service: UserApiService)
135142
operationId = "logoutUser",
136143
description = """""",
137144
responses = [
138-
ApiResponse(responseCode = "200", description = "successful operation") ]
145+
ApiResponse(responseCode = "200", description = "successful operation") ],
146+
security = [ SecurityRequirement(name = "api_key") ]
139147
)
140148
@RequestMapping(
141149
method = [RequestMethod.GET],
@@ -151,13 +159,15 @@ class UserApiController(@Autowired(required = true) val service: UserApiService)
151159
description = """This can only be done by the logged in user.""",
152160
responses = [
153161
ApiResponse(responseCode = "400", description = "Invalid user supplied"),
154-
ApiResponse(responseCode = "404", description = "User not found") ]
162+
ApiResponse(responseCode = "404", description = "User not found") ],
163+
security = [ SecurityRequirement(name = "api_key") ]
155164
)
156165
@RequestMapping(
157166
method = [RequestMethod.PUT],
158-
value = ["/user/{username}"]
167+
value = ["/user/{username}"],
168+
consumes = ["application/json"]
159169
)
160-
suspend fun updateUser(@Parameter(description = "name that need to be deleted", required = true) @PathVariable("username") username: kotlin.String,@Parameter(description = "Updated user object", required = true) @Valid @RequestBody body: User): ResponseEntity<Unit> {
161-
return ResponseEntity(service.updateUser(username, body), HttpStatus.valueOf(400))
170+
suspend fun updateUser(@Parameter(description = "name that need to be deleted", required = true) @PathVariable("username") username: kotlin.String,@Parameter(description = "Updated user object", required = true) @Valid @RequestBody user: User): ResponseEntity<Unit> {
171+
return ResponseEntity(service.updateUser(username, user), HttpStatus.valueOf(400))
162172
}
163173
}

0 commit comments

Comments
 (0)