Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions bin/utils/ensure-up-to-date
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ declare -a scripts=(
"./bin/kotlin-client-threetenbp.sh"
"./bin/kotlin-server-petstore.sh"
"./bin/kotlin-springboot-petstore-server.sh"
"./bin/kotlin-springboot-petstore-server-reactive.sh"
"./bin/mysql-schema-petstore.sh"
"./bin/python-petstore-all.sh"
"./bin/openapi3/python-petstore.sh"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ package {{package}}
{{/imports}}
import org.junit.jupiter.api.Test

{{#reactive}}
import kotlinx.coroutines.flow.Flow;
import kotlinx.coroutines.test.runBlockingTest
{{/reactive}}
import org.springframework.http.ResponseEntity

class {{classname}}Test {
Expand All @@ -21,7 +25,7 @@ class {{classname}}Test {
* if the Api call fails
*/
@Test
fun {{operationId}}Test() {
fun {{operationId}}Test() {{#reactive}}= runBlockingTest {{/reactive}}{
{{#allParams}}
val {{paramName}}:{{{dataType}}}? = null
{{/allParams}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ dependencies {
testCompile("org.springframework.boot:spring-boot-starter-test") {
exclude(module = "junit")
}
{{#reactive}}
testCompile("org.jetbrains.kotlinx:kotlinx-coroutines-test:$kotlinxCoroutinesVersion")
{{/reactive}}
}

repositories {
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4.0.1-SNAPSHOT
4.0.2-SNAPSHOT
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,11 @@ dependencies {
compile("com.fasterxml.jackson.dataformat:jackson-dataformat-xml")
compile("com.fasterxml.jackson.module:jackson-module-kotlin")

testCompile("org.jetbrains.kotlin:kotlin-test-junit5")
testCompile("org.springframework.boot:spring-boot-starter-test") {
exclude(module = "junit")
}
testCompile("org.jetbrains.kotlinx:kotlinx-coroutines-test:$kotlinxCoroutinesVersion")
}

repositories {
Expand Down
6 changes: 6 additions & 0 deletions samples/server/petstore/kotlin-springboot-reactive/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,12 @@
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-test-junit5</artifactId>
<version>1.3.31</version>
<scope>test</scope>
</dependency>
</dependencies>
<repositories>
<repository>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class PetApiController(@Autowired(required = true) val service: PetApiService) {
method = [RequestMethod.POST])
suspend fun addPet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody body: Pet
): ResponseEntity<Unit> {
return ResponseEntity(service.addPet(body), HttpStatus.OK)
return ResponseEntity(service.addPet(body), HttpStatus.valueOf(405))
}

@ApiOperation(
Expand All @@ -70,10 +70,10 @@ class PetApiController(@Autowired(required = true) val service: PetApiService) {
@RequestMapping(
value = ["/pet/{petId}"],
method = [RequestMethod.DELETE])
suspend fun deletePet(@ApiParam(value = "Pet id to delete", required=true) @PathVariable("petId") petId: Long
,@ApiParam(value = "" ) @RequestHeader(value="api_key", required=false) apiKey: String?
suspend fun deletePet(@ApiParam(value = "Pet id to delete", required=true) @PathVariable("petId") petId: kotlin.Long
,@ApiParam(value = "" ) @RequestHeader(value="api_key", required=false) apiKey: kotlin.String?
): ResponseEntity<Unit> {
return ResponseEntity(service.deletePet(petId, apiKey), HttpStatus.OK)
return ResponseEntity(service.deletePet(petId, apiKey), HttpStatus.valueOf(400))
}

@ApiOperation(
Expand All @@ -89,9 +89,9 @@ class PetApiController(@Autowired(required = true) val service: PetApiService) {
value = ["/pet/findByStatus"],
produces = ["application/xml", "application/json"],
method = [RequestMethod.GET])
fun findPetsByStatus(@NotNull @ApiParam(value = "Status values that need to be considered for filter", required = true, allowableValues = "available, pending, sold") @Valid @RequestParam(value = "status", required = true) status: List<String>
fun findPetsByStatus(@NotNull @ApiParam(value = "Status values that need to be considered for filter", required = true, allowableValues = "available, pending, sold") @Valid @RequestParam(value = "status", required = true) status: kotlin.collections.List<kotlin.String>
): ResponseEntity<Flow<Pet>> {
return ResponseEntity(service.findPetsByStatus(status), HttpStatus.OK)
return ResponseEntity(service.findPetsByStatus(status), HttpStatus.valueOf(200))
}

@ApiOperation(
Expand All @@ -107,9 +107,9 @@ class PetApiController(@Autowired(required = true) val service: PetApiService) {
value = ["/pet/findByTags"],
produces = ["application/xml", "application/json"],
method = [RequestMethod.GET])
fun findPetsByTags(@NotNull @ApiParam(value = "Tags to filter by", required = true) @Valid @RequestParam(value = "tags", required = true) tags: List<String>
fun findPetsByTags(@NotNull @ApiParam(value = "Tags to filter by", required = true) @Valid @RequestParam(value = "tags", required = true) tags: kotlin.collections.List<kotlin.String>
): ResponseEntity<Flow<Pet>> {
return ResponseEntity(service.findPetsByTags(tags), HttpStatus.OK)
return ResponseEntity(service.findPetsByTags(tags), HttpStatus.valueOf(200))
}

@ApiOperation(
Expand All @@ -124,9 +124,9 @@ class PetApiController(@Autowired(required = true) val service: PetApiService) {
value = ["/pet/{petId}"],
produces = ["application/xml", "application/json"],
method = [RequestMethod.GET])
suspend fun getPetById(@ApiParam(value = "ID of pet to return", required=true) @PathVariable("petId") petId: Long
suspend fun getPetById(@ApiParam(value = "ID of pet to return", required=true) @PathVariable("petId") petId: kotlin.Long
): ResponseEntity<Pet> {
return ResponseEntity(service.getPetById(petId), HttpStatus.OK)
return ResponseEntity(service.getPetById(petId), HttpStatus.valueOf(200))
}

@ApiOperation(
Expand All @@ -142,7 +142,7 @@ class PetApiController(@Autowired(required = true) val service: PetApiService) {
method = [RequestMethod.PUT])
suspend fun updatePet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody body: Pet
): ResponseEntity<Unit> {
return ResponseEntity(service.updatePet(body), HttpStatus.OK)
return ResponseEntity(service.updatePet(body), HttpStatus.valueOf(400))
}

@ApiOperation(
Expand All @@ -156,11 +156,11 @@ class PetApiController(@Autowired(required = true) val service: PetApiService) {
value = ["/pet/{petId}"],
consumes = ["application/x-www-form-urlencoded"],
method = [RequestMethod.POST])
suspend fun updatePetWithForm(@ApiParam(value = "ID of pet that needs to be updated", required=true) @PathVariable("petId") petId: Long
,@ApiParam(value = "Updated name of the pet") @RequestParam(value="name", required=false) name: String?
,@ApiParam(value = "Updated status of the pet") @RequestParam(value="status", required=false) status: String?
suspend fun updatePetWithForm(@ApiParam(value = "ID of pet that needs to be updated", required=true) @PathVariable("petId") petId: kotlin.Long
,@ApiParam(value = "Updated name of the pet") @RequestParam(value="name", required=false) name: kotlin.String?
,@ApiParam(value = "Updated status of the pet") @RequestParam(value="status", required=false) status: kotlin.String?
): ResponseEntity<Unit> {
return ResponseEntity(service.updatePetWithForm(petId, name, status), HttpStatus.OK)
return ResponseEntity(service.updatePetWithForm(petId, name, status), HttpStatus.valueOf(405))
}

@ApiOperation(
Expand All @@ -176,10 +176,10 @@ class PetApiController(@Autowired(required = true) val service: PetApiService) {
produces = ["application/json"],
consumes = ["multipart/form-data"],
method = [RequestMethod.POST])
suspend fun uploadFile(@ApiParam(value = "ID of pet to update", required=true) @PathVariable("petId") petId: Long
,@ApiParam(value = "Additional data to pass to server") @RequestParam(value="additionalMetadata", required=false) additionalMetadata: String?
suspend fun uploadFile(@ApiParam(value = "ID of pet to update", required=true) @PathVariable("petId") petId: kotlin.Long
,@ApiParam(value = "Additional data to pass to server") @RequestParam(value="additionalMetadata", required=false) additionalMetadata: kotlin.String?
,@ApiParam(value = "file detail") @Valid @RequestPart("file") file: org.springframework.core.io.Resource?
): ResponseEntity<ModelApiResponse> {
return ResponseEntity(service.uploadFile(petId, additionalMetadata, file), HttpStatus.OK)
return ResponseEntity(service.uploadFile(petId, additionalMetadata, file), HttpStatus.valueOf(200))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@ interface PetApiService {

suspend fun addPet(body: Pet): Unit

suspend fun deletePet(petId: Long, apiKey: String?): Unit
suspend fun deletePet(petId: kotlin.Long, apiKey: kotlin.String?): Unit

fun findPetsByStatus(status: List<String>): Flow<Pet>
fun findPetsByStatus(status: kotlin.collections.List<kotlin.String>): Flow<Pet>

fun findPetsByTags(tags: List<String>): Flow<Pet>
fun findPetsByTags(tags: kotlin.collections.List<kotlin.String>): Flow<Pet>

suspend fun getPetById(petId: Long): Pet
suspend fun getPetById(petId: kotlin.Long): Pet

suspend fun updatePet(body: Pet): Unit

suspend fun updatePetWithForm(petId: Long, name: String?, status: String?): Unit
suspend fun updatePetWithForm(petId: kotlin.Long, name: kotlin.String?, status: kotlin.String?): Unit

suspend fun uploadFile(petId: Long, additionalMetadata: String?, file: org.springframework.core.io.Resource?): ModelApiResponse
suspend fun uploadFile(petId: kotlin.Long, additionalMetadata: kotlin.String?, file: org.springframework.core.io.Resource?): ModelApiResponse
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,31 +11,31 @@ class PetApiServiceImpl : PetApiService {
TODO("Implement me")
}

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

override fun findPetsByStatus(status: List<String>): Flow<Pet> {
override fun findPetsByStatus(status: kotlin.collections.List<kotlin.String>): Flow<Pet> {
TODO("Implement me")
}

override fun findPetsByTags(tags: List<String>): Flow<Pet> {
override fun findPetsByTags(tags: kotlin.collections.List<kotlin.String>): Flow<Pet> {
TODO("Implement me")
}

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

override suspend fun updatePet(body: Pet): Unit {
TODO("Implement me")
}

override suspend fun updatePetWithForm(petId: Long, name: String?, status: String?): Unit {
override suspend fun updatePetWithForm(petId: kotlin.Long, name: kotlin.String?, status: kotlin.String?): Unit {
TODO("Implement me")
}

override suspend fun uploadFile(petId: Long, additionalMetadata: String?, file: org.springframework.core.io.Resource?): ModelApiResponse {
override suspend fun uploadFile(petId: kotlin.Long, additionalMetadata: kotlin.String?, file: org.springframework.core.io.Resource?): ModelApiResponse {
TODO("Implement me")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,26 +52,26 @@ class StoreApiController(@Autowired(required = true) val service: StoreApiServic
@RequestMapping(
value = ["/store/order/{orderId}"],
method = [RequestMethod.DELETE])
suspend fun deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted", required=true) @PathVariable("orderId") orderId: String
suspend fun deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted", required=true) @PathVariable("orderId") orderId: kotlin.String
): ResponseEntity<Unit> {
return ResponseEntity(service.deleteOrder(orderId), HttpStatus.OK)
return ResponseEntity(service.deleteOrder(orderId), HttpStatus.valueOf(400))
}

@ApiOperation(
value = "Returns pet inventories by status",
nickname = "getInventory",
notes = "Returns a map of status codes to quantities",
response = Int::class,
response = kotlin.Int::class,
responseContainer = "Map",
authorizations = [Authorization(value = "api_key")])
@ApiResponses(
value = [ApiResponse(code = 200, message = "successful operation", response = Map::class, responseContainer = "Map")])
value = [ApiResponse(code = 200, message = "successful operation", response = kotlin.collections.Map::class, responseContainer = "Map")])
@RequestMapping(
value = ["/store/inventory"],
produces = ["application/json"],
method = [RequestMethod.GET])
suspend fun getInventory(): ResponseEntity<Map<String, Int>> {
return ResponseEntity(service.getInventory(), HttpStatus.OK)
suspend fun getInventory(): ResponseEntity<Map<String, kotlin.Int>> {
return ResponseEntity(service.getInventory(), HttpStatus.valueOf(200))
}

@ApiOperation(
Expand All @@ -85,9 +85,9 @@ class StoreApiController(@Autowired(required = true) val service: StoreApiServic
value = ["/store/order/{orderId}"],
produces = ["application/xml", "application/json"],
method = [RequestMethod.GET])
suspend fun getOrderById(@Min(1L) @Max(5L) @ApiParam(value = "ID of pet that needs to be fetched", required=true) @PathVariable("orderId") orderId: Long
suspend fun getOrderById(@Min(1L) @Max(5L) @ApiParam(value = "ID of pet that needs to be fetched", required=true) @PathVariable("orderId") orderId: kotlin.Long
): ResponseEntity<Order> {
return ResponseEntity(service.getOrderById(orderId), HttpStatus.OK)
return ResponseEntity(service.getOrderById(orderId), HttpStatus.valueOf(200))
}

@ApiOperation(
Expand All @@ -103,6 +103,6 @@ class StoreApiController(@Autowired(required = true) val service: StoreApiServic
method = [RequestMethod.POST])
suspend fun placeOrder(@ApiParam(value = "order placed for purchasing the pet" ,required=true ) @Valid @RequestBody body: Order
): ResponseEntity<Order> {
return ResponseEntity(service.placeOrder(body), HttpStatus.OK)
return ResponseEntity(service.placeOrder(body), HttpStatus.valueOf(200))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import org.openapitools.model.Order
import kotlinx.coroutines.flow.Flow;
interface StoreApiService {

suspend fun deleteOrder(orderId: String): Unit
suspend fun deleteOrder(orderId: kotlin.String): Unit

suspend fun getInventory(): Map<String, Int>
suspend fun getInventory(): Map<String, kotlin.Int>

suspend fun getOrderById(orderId: Long): Order
suspend fun getOrderById(orderId: kotlin.Long): Order

suspend fun placeOrder(body: Order): Order
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ import org.springframework.stereotype.Service
@Service
class StoreApiServiceImpl : StoreApiService {

override suspend fun deleteOrder(orderId: String): Unit {
override suspend fun deleteOrder(orderId: kotlin.String): Unit {
TODO("Implement me")
}

override suspend fun getInventory(): Map<String, Int> {
override suspend fun getInventory(): Map<String, kotlin.Int> {
TODO("Implement me")
}

override suspend fun getOrderById(orderId: Long): Order {
override suspend fun getOrderById(orderId: kotlin.Long): Order {
TODO("Implement me")
}

Expand Down
Loading