From 0a513785aae601cd8581e54885965d2fabea9775 Mon Sep 17 00:00:00 2001 From: Sylvain Moindron Date: Tue, 19 Mar 2019 17:03:37 +0100 Subject: [PATCH 1/7] [kotlin-spring] use org.springframework.core.io.Resource for file handling --- .../languages/KotlinSpringServerCodegen.java | 35 ++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/KotlinSpringServerCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/KotlinSpringServerCodegen.java index d106870887fe..61c6fd996193 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/KotlinSpringServerCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/KotlinSpringServerCodegen.java @@ -44,7 +44,7 @@ public class KotlinSpringServerCodegen extends AbstractKotlinCodegen LoggerFactory.getLogger(KotlinSpringServerCodegen.class); private static final HashSet VARIABLE_RESERVED_WORDS = - new HashSet(Arrays.asList( + new HashSet<>(Arrays.asList( "ApiClient", "ApiException", "ApiResponse" @@ -109,6 +109,10 @@ public KotlinSpringServerCodegen() { importMapping.put("Date", "java.time.LocalDate"); importMapping.put("DateTime", "java.time.OffsetDateTime"); + // use resource for file handling + typeMapping.put("file", "org.springframework.core.io.Resource"); + + languageSpecificPrimitives.addAll(Arrays.asList( "Any", "Byte", @@ -562,4 +566,33 @@ public CodegenModel fromModel(String name, Schema schema) { return m; } + + /** + * Output the proper model name (capitalized). + * In case the name belongs to the TypeSystem it won't be renamed. + * + * @param name the name of the model + * @return capitalized model name + */ + @Override + public String toModelName(final String name) { + // Allow for explicitly configured spring.* + if (name.startsWith("org.springframework.") ) { + return name; + } + return super.toModelName(name); + } + + /** + * Check the type to see if it needs import the library/module/package + * + * @param type name of the type + * @return true if the library/module/package of the corresponding type needs to be imported + */ + @Override + protected boolean needToImport(String type) { + // provides extra protection against improperly trying to import language primitives and java types + boolean imports = !type.startsWith("org.springframework.") && super.needToImport(type); + return imports; + } } From fa0aaab80e2bab15c698afde22b6783befc91bea Mon Sep 17 00:00:00 2001 From: Sylvain Moindron Date: Tue, 19 Mar 2019 23:13:29 +0100 Subject: [PATCH 2/7] run ./bin/kotlin-springboot-petstore-server.sh --- .../.openapi-generator/VERSION | 2 +- .../kotlin/org/openapitools/api/PetApi.kt | 21 +++++++++--------- .../org/openapitools/api/PetApiService.kt | 7 +++--- .../org/openapitools/api/PetApiServiceImpl.kt | 7 +++--- .../kotlin/org/openapitools/api/StoreApi.kt | 8 +++---- .../org/openapitools/api/StoreApiService.kt | 2 +- .../openapitools/api/StoreApiServiceImpl.kt | 2 +- .../kotlin/org/openapitools/api/UserApi.kt | 22 +++++++++---------- .../org/openapitools/api/UserApiService.kt | 8 +++---- .../openapitools/api/UserApiServiceImpl.kt | 8 +++---- .../kotlin/org/openapitools/model/Category.kt | 4 ++-- .../openapitools/model/ModelApiResponse.kt | 6 ++--- .../kotlin/org/openapitools/model/Order.kt | 12 +++++----- .../main/kotlin/org/openapitools/model/Pet.kt | 10 ++++----- .../main/kotlin/org/openapitools/model/Tag.kt | 4 ++-- .../kotlin/org/openapitools/model/User.kt | 16 +++++++------- 16 files changed, 71 insertions(+), 68 deletions(-) diff --git a/samples/server/petstore/kotlin-springboot/.openapi-generator/VERSION b/samples/server/petstore/kotlin-springboot/.openapi-generator/VERSION index 6d94c9c2e12a..afa636560641 100644 --- a/samples/server/petstore/kotlin-springboot/.openapi-generator/VERSION +++ b/samples/server/petstore/kotlin-springboot/.openapi-generator/VERSION @@ -1 +1 @@ -3.3.0-SNAPSHOT \ No newline at end of file +4.0.0-SNAPSHOT \ No newline at end of file diff --git a/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/api/PetApi.kt b/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/api/PetApi.kt index 17b87c74fdfb..1892bd6342e7 100644 --- a/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/api/PetApi.kt +++ b/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/api/PetApi.kt @@ -1,6 +1,7 @@ package org.openapitools.api import org.openapitools.model.ModelApiResponse +import org.openapitools.model.OrgspringframeworkcoreioResource import org.openapitools.model.Pet import io.swagger.annotations.* import org.springframework.http.HttpStatus @@ -42,8 +43,8 @@ class PetApiController(@Autowired(required = true) val service: PetApiService) { value = ["/pet"], consumes = ["application/json", "application/xml"], method = [RequestMethod.POST]) - fun addPet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody pet: Pet): ResponseEntity { - return ResponseEntity(service.addPet(pet), HttpStatus.OK) + fun addPet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody body: Pet): ResponseEntity { + return ResponseEntity(service.addPet(body), HttpStatus.OK) } @ApiOperation( @@ -56,7 +57,7 @@ class PetApiController(@Autowired(required = true) val service: PetApiService) { @RequestMapping( value = ["/pet/{petId}"], method = [RequestMethod.DELETE]) - fun deletePet(@ApiParam(value = "Pet id to delete", required=true) @PathVariable("petId") petId: Long,@ApiParam(value = "" ) @RequestHeader(value="api_key", required=false) apiKey: String?): ResponseEntity { + fun deletePet(@ApiParam(value = "Pet id to delete", required=true, defaultValue="null") @PathVariable("petId") petId: Long,@ApiParam(value = "" , defaultValue="null") @RequestHeader(value="api_key", required=false) apiKey: String): ResponseEntity { return ResponseEntity(service.deletePet(petId, apiKey), HttpStatus.OK) } @@ -73,7 +74,7 @@ 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): ResponseEntity> { + fun findPetsByStatus(@NotNull @ApiParam(value = "Status values that need to be considered for filter", required = true, allowableValues = "available, pending, sold", defaultValue = "null") @Valid @RequestParam(value = "status", required = true, defaultValue="null") status: List): ResponseEntity> { return ResponseEntity(service.findPetsByStatus(status), HttpStatus.OK) } @@ -90,7 +91,7 @@ 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): ResponseEntity> { + fun findPetsByTags(@NotNull @ApiParam(value = "Tags to filter by", required = true, defaultValue = "null") @Valid @RequestParam(value = "tags", required = true, defaultValue="null") tags: List): ResponseEntity> { return ResponseEntity(service.findPetsByTags(tags), HttpStatus.OK) } @@ -106,7 +107,7 @@ class PetApiController(@Autowired(required = true) val service: PetApiService) { value = ["/pet/{petId}"], produces = ["application/xml", "application/json"], method = [RequestMethod.GET]) - fun getPetById(@ApiParam(value = "ID of pet to return", required=true) @PathVariable("petId") petId: Long): ResponseEntity { + fun getPetById(@ApiParam(value = "ID of pet to return", required=true, defaultValue="null") @PathVariable("petId") petId: Long): ResponseEntity { return ResponseEntity(service.getPetById(petId), HttpStatus.OK) } @@ -121,8 +122,8 @@ class PetApiController(@Autowired(required = true) val service: PetApiService) { value = ["/pet"], consumes = ["application/json", "application/xml"], method = [RequestMethod.PUT]) - fun updatePet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody pet: Pet): ResponseEntity { - return ResponseEntity(service.updatePet(pet), HttpStatus.OK) + fun updatePet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody body: Pet): ResponseEntity { + return ResponseEntity(service.updatePet(body), HttpStatus.OK) } @ApiOperation( @@ -136,7 +137,7 @@ class PetApiController(@Autowired(required = true) val service: PetApiService) { value = ["/pet/{petId}"], consumes = ["application/x-www-form-urlencoded"], method = [RequestMethod.POST]) - 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", defaultValue="null") @RequestParam(value="name", required=false) name: String ,@ApiParam(value = "Updated status of the pet", defaultValue="null") @RequestParam(value="status", required=false) status: String ): ResponseEntity { + fun updatePetWithForm(@ApiParam(value = "ID of pet that needs to be updated", required=true, defaultValue="null") @PathVariable("petId") petId: Long,@ApiParam(value = "Updated name of the pet", defaultValue="null") @RequestParam(value="name", required=false) name: String ,@ApiParam(value = "Updated status of the pet", defaultValue="null") @RequestParam(value="status", required=false) status: String ): ResponseEntity { return ResponseEntity(service.updatePetWithForm(petId, name, status), HttpStatus.OK) } @@ -153,7 +154,7 @@ class PetApiController(@Autowired(required = true) val service: PetApiService) { produces = ["application/json"], consumes = ["multipart/form-data"], method = [RequestMethod.POST]) - fun uploadFile(@ApiParam(value = "ID of pet to update", required=true) @PathVariable("petId") petId: Long,@ApiParam(value = "Additional data to pass to server", defaultValue="null") @RequestParam(value="additionalMetadata", required=false) additionalMetadata: String ,@ApiParam(value = "file detail") @Valid @RequestPart("file") file: MultipartFile): ResponseEntity { + fun uploadFile(@ApiParam(value = "ID of pet to update", required=true, defaultValue="null") @PathVariable("petId") petId: Long,@ApiParam(value = "Additional data to pass to server", defaultValue="null") @RequestParam(value="additionalMetadata", required=false) additionalMetadata: String ,@ApiParam(value = "file detail") @Valid @RequestPart("file") file: MultipartFile): ResponseEntity { return ResponseEntity(service.uploadFile(petId, additionalMetadata, file), HttpStatus.OK) } } diff --git a/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/api/PetApiService.kt b/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/api/PetApiService.kt index b31d96e91b73..db28a6b17fb0 100644 --- a/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/api/PetApiService.kt +++ b/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/api/PetApiService.kt @@ -1,13 +1,14 @@ package org.openapitools.api import org.openapitools.model.ModelApiResponse +import org.openapitools.model.OrgspringframeworkcoreioResource import org.openapitools.model.Pet interface PetApiService { - fun addPet(pet: Pet): Unit + fun addPet(body: Pet): Unit - fun deletePet(petId: Long,apiKey: String?): Unit + fun deletePet(petId: Long,apiKey: String): Unit fun findPetsByStatus(status: List): List @@ -15,7 +16,7 @@ interface PetApiService { fun getPetById(petId: Long): Pet - fun updatePet(pet: Pet): Unit + fun updatePet(body: Pet): Unit fun updatePetWithForm(petId: Long,name: String,status: String): Unit diff --git a/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/api/PetApiServiceImpl.kt b/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/api/PetApiServiceImpl.kt index 80b7d6e8fe1c..5b819bf9d369 100644 --- a/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/api/PetApiServiceImpl.kt +++ b/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/api/PetApiServiceImpl.kt @@ -1,17 +1,18 @@ package org.openapitools.api import org.openapitools.model.ModelApiResponse +import org.openapitools.model.OrgspringframeworkcoreioResource import org.openapitools.model.Pet import org.springframework.stereotype.Service @Service class PetApiServiceImpl : PetApiService { - override fun addPet(pet: Pet): Unit { + override fun addPet(body: Pet): Unit { TODO("Implement me") } - override fun deletePet(petId: Long,apiKey: String?): Unit { + override fun deletePet(petId: Long,apiKey: String): Unit { TODO("Implement me") } @@ -27,7 +28,7 @@ class PetApiServiceImpl : PetApiService { TODO("Implement me") } - override fun updatePet(pet: Pet): Unit { + override fun updatePet(body: Pet): Unit { TODO("Implement me") } diff --git a/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/api/StoreApi.kt b/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/api/StoreApi.kt index 01c64e66ccf6..4e0a88706c31 100644 --- a/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/api/StoreApi.kt +++ b/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/api/StoreApi.kt @@ -39,7 +39,7 @@ class StoreApiController(@Autowired(required = true) val service: StoreApiServic @RequestMapping( value = ["/store/order/{orderId}"], method = [RequestMethod.DELETE]) - fun deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted", required=true) @PathVariable("orderId") orderId: String): ResponseEntity { + fun deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted", required=true, defaultValue="null") @PathVariable("orderId") orderId: String): ResponseEntity { return ResponseEntity(service.deleteOrder(orderId), HttpStatus.OK) } @@ -71,7 +71,7 @@ class StoreApiController(@Autowired(required = true) val service: StoreApiServic value = ["/store/order/{orderId}"], produces = ["application/xml", "application/json"], method = [RequestMethod.GET]) - fun getOrderById(@Min(1L) @Max(5L) @ApiParam(value = "ID of pet that needs to be fetched", required=true) @PathVariable("orderId") orderId: Long): ResponseEntity { + fun getOrderById(@Min(1L) @Max(5L) @ApiParam(value = "ID of pet that needs to be fetched", required=true, defaultValue="null") @PathVariable("orderId") orderId: Long): ResponseEntity { return ResponseEntity(service.getOrderById(orderId), HttpStatus.OK) } @@ -86,7 +86,7 @@ class StoreApiController(@Autowired(required = true) val service: StoreApiServic value = ["/store/order"], produces = ["application/xml", "application/json"], method = [RequestMethod.POST]) - fun placeOrder(@ApiParam(value = "order placed for purchasing the pet" ,required=true ) @Valid @RequestBody order: Order): ResponseEntity { - return ResponseEntity(service.placeOrder(order), HttpStatus.OK) + fun placeOrder(@ApiParam(value = "order placed for purchasing the pet" ,required=true ) @Valid @RequestBody body: Order): ResponseEntity { + return ResponseEntity(service.placeOrder(body), HttpStatus.OK) } } diff --git a/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/api/StoreApiService.kt b/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/api/StoreApiService.kt index 7767fa87a8a5..cf479e2c8a71 100644 --- a/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/api/StoreApiService.kt +++ b/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/api/StoreApiService.kt @@ -10,5 +10,5 @@ interface StoreApiService { fun getOrderById(orderId: Long): Order - fun placeOrder(order: Order): Order + fun placeOrder(body: Order): Order } diff --git a/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/api/StoreApiServiceImpl.kt b/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/api/StoreApiServiceImpl.kt index 850853758fed..ec26e074ac6f 100644 --- a/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/api/StoreApiServiceImpl.kt +++ b/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/api/StoreApiServiceImpl.kt @@ -18,7 +18,7 @@ class StoreApiServiceImpl : StoreApiService { TODO("Implement me") } - override fun placeOrder(order: Order): Order { + override fun placeOrder(body: Order): Order { TODO("Implement me") } } diff --git a/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/api/UserApi.kt b/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/api/UserApi.kt index b68773524a2d..97d1151e7047 100644 --- a/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/api/UserApi.kt +++ b/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/api/UserApi.kt @@ -39,8 +39,8 @@ class UserApiController(@Autowired(required = true) val service: UserApiService) @RequestMapping( value = ["/user"], method = [RequestMethod.POST]) - fun createUser(@ApiParam(value = "Created user object" ,required=true ) @Valid @RequestBody user: User): ResponseEntity { - return ResponseEntity(service.createUser(user), HttpStatus.OK) + fun createUser(@ApiParam(value = "Created user object" ,required=true ) @Valid @RequestBody body: User): ResponseEntity { + return ResponseEntity(service.createUser(body), HttpStatus.OK) } @ApiOperation( @@ -52,8 +52,8 @@ class UserApiController(@Autowired(required = true) val service: UserApiService) @RequestMapping( value = ["/user/createWithArray"], method = [RequestMethod.POST]) - fun createUsersWithArrayInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody user: List): ResponseEntity { - return ResponseEntity(service.createUsersWithArrayInput(user), HttpStatus.OK) + fun createUsersWithArrayInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody body: List): ResponseEntity { + return ResponseEntity(service.createUsersWithArrayInput(body), HttpStatus.OK) } @ApiOperation( @@ -65,8 +65,8 @@ class UserApiController(@Autowired(required = true) val service: UserApiService) @RequestMapping( value = ["/user/createWithList"], method = [RequestMethod.POST]) - fun createUsersWithListInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody user: List): ResponseEntity { - return ResponseEntity(service.createUsersWithListInput(user), HttpStatus.OK) + fun createUsersWithListInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody body: List): ResponseEntity { + return ResponseEntity(service.createUsersWithListInput(body), HttpStatus.OK) } @ApiOperation( @@ -78,7 +78,7 @@ class UserApiController(@Autowired(required = true) val service: UserApiService) @RequestMapping( value = ["/user/{username}"], method = [RequestMethod.DELETE]) - fun deleteUser(@ApiParam(value = "The name that needs to be deleted", required=true) @PathVariable("username") username: String): ResponseEntity { + fun deleteUser(@ApiParam(value = "The name that needs to be deleted", required=true, defaultValue="null") @PathVariable("username") username: String): ResponseEntity { return ResponseEntity(service.deleteUser(username), HttpStatus.OK) } @@ -93,7 +93,7 @@ class UserApiController(@Autowired(required = true) val service: UserApiService) value = ["/user/{username}"], produces = ["application/xml", "application/json"], method = [RequestMethod.GET]) - fun getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing.", required=true) @PathVariable("username") username: String): ResponseEntity { + fun getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing.", required=true, defaultValue="null") @PathVariable("username") username: String): ResponseEntity { return ResponseEntity(service.getUserByName(username), HttpStatus.OK) } @@ -108,7 +108,7 @@ class UserApiController(@Autowired(required = true) val service: UserApiService) value = ["/user/login"], produces = ["application/xml", "application/json"], method = [RequestMethod.GET]) - fun loginUser(@NotNull @ApiParam(value = "The user name for login", required = true) @Valid @RequestParam(value = "username", required = true) username: String,@NotNull @ApiParam(value = "The password for login in clear text", required = true) @Valid @RequestParam(value = "password", required = true) password: String): ResponseEntity { + fun loginUser(@NotNull @ApiParam(value = "The user name for login", required = true, defaultValue = "null") @Valid @RequestParam(value = "username", required = true, defaultValue="null") username: String,@NotNull @ApiParam(value = "The password for login in clear text", required = true, defaultValue = "null") @Valid @RequestParam(value = "password", required = true, defaultValue="null") password: String): ResponseEntity { return ResponseEntity(service.loginUser(username, password), HttpStatus.OK) } @@ -134,7 +134,7 @@ class UserApiController(@Autowired(required = true) val service: UserApiService) @RequestMapping( value = ["/user/{username}"], method = [RequestMethod.PUT]) - fun updateUser(@ApiParam(value = "name that need to be deleted", required=true) @PathVariable("username") username: String,@ApiParam(value = "Updated user object" ,required=true ) @Valid @RequestBody user: User): ResponseEntity { - return ResponseEntity(service.updateUser(username, user), HttpStatus.OK) + fun updateUser(@ApiParam(value = "name that need to be deleted", required=true, defaultValue="null") @PathVariable("username") username: String,@ApiParam(value = "Updated user object" ,required=true ) @Valid @RequestBody body: User): ResponseEntity { + return ResponseEntity(service.updateUser(username, body), HttpStatus.OK) } } diff --git a/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/api/UserApiService.kt b/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/api/UserApiService.kt index b8a3d7ebae1b..bdf37d33dc5c 100644 --- a/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/api/UserApiService.kt +++ b/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/api/UserApiService.kt @@ -4,11 +4,11 @@ import org.openapitools.model.User interface UserApiService { - fun createUser(user: User): Unit + fun createUser(body: User): Unit - fun createUsersWithArrayInput(user: List): Unit + fun createUsersWithArrayInput(body: List): Unit - fun createUsersWithListInput(user: List): Unit + fun createUsersWithListInput(body: List): Unit fun deleteUser(username: String): Unit @@ -18,5 +18,5 @@ interface UserApiService { fun logoutUser(): Unit - fun updateUser(username: String,user: User): Unit + fun updateUser(username: String,body: User): Unit } diff --git a/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/api/UserApiServiceImpl.kt b/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/api/UserApiServiceImpl.kt index 62b365a6d823..cb579c2c16f2 100644 --- a/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/api/UserApiServiceImpl.kt +++ b/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/api/UserApiServiceImpl.kt @@ -6,15 +6,15 @@ import org.springframework.stereotype.Service @Service class UserApiServiceImpl : UserApiService { - override fun createUser(user: User): Unit { + override fun createUser(body: User): Unit { TODO("Implement me") } - override fun createUsersWithArrayInput(user: List): Unit { + override fun createUsersWithArrayInput(body: List): Unit { TODO("Implement me") } - override fun createUsersWithListInput(user: List): Unit { + override fun createUsersWithListInput(body: List): Unit { TODO("Implement me") } @@ -34,7 +34,7 @@ class UserApiServiceImpl : UserApiService { TODO("Implement me") } - override fun updateUser(username: String,user: User): Unit { + override fun updateUser(username: String,body: User): Unit { TODO("Implement me") } } diff --git a/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/model/Category.kt b/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/model/Category.kt index da259e87b8e5..c34cec48df16 100644 --- a/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/model/Category.kt +++ b/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/model/Category.kt @@ -13,10 +13,10 @@ import io.swagger.annotations.ApiModelProperty */ data class Category ( - @ApiModelProperty(value = "") + @ApiModelProperty(example = "null", value = "") @JsonProperty("id") val id: Long? = null, - @ApiModelProperty(value = "") + @ApiModelProperty(example = "null", value = "") @JsonProperty("name") val name: String? = null ) { diff --git a/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/model/ModelApiResponse.kt b/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/model/ModelApiResponse.kt index e933f2436a43..17697fdfe8d4 100644 --- a/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/model/ModelApiResponse.kt +++ b/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/model/ModelApiResponse.kt @@ -14,13 +14,13 @@ import io.swagger.annotations.ApiModelProperty */ data class ModelApiResponse ( - @ApiModelProperty(value = "") + @ApiModelProperty(example = "null", value = "") @JsonProperty("code") val code: Int? = null, - @ApiModelProperty(value = "") + @ApiModelProperty(example = "null", value = "") @JsonProperty("type") val type: String? = null, - @ApiModelProperty(value = "") + @ApiModelProperty(example = "null", value = "") @JsonProperty("message") val message: String? = null ) { diff --git a/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/model/Order.kt b/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/model/Order.kt index e1065f56bd32..be8e2f33fb37 100644 --- a/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/model/Order.kt +++ b/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/model/Order.kt @@ -18,22 +18,22 @@ import io.swagger.annotations.ApiModelProperty */ data class Order ( - @ApiModelProperty(value = "") + @ApiModelProperty(example = "null", value = "") @JsonProperty("id") val id: Long? = null, - @ApiModelProperty(value = "") + @ApiModelProperty(example = "null", value = "") @JsonProperty("petId") val petId: Long? = null, - @ApiModelProperty(value = "") + @ApiModelProperty(example = "null", value = "") @JsonProperty("quantity") val quantity: Int? = null, - @ApiModelProperty(value = "") + @ApiModelProperty(example = "null", value = "") @JsonProperty("shipDate") val shipDate: java.time.OffsetDateTime? = null, - @ApiModelProperty(value = "Order Status") + @ApiModelProperty(example = "null", value = "Order Status") @JsonProperty("status") val status: Order.Status? = null, - @ApiModelProperty(value = "") + @ApiModelProperty(example = "null", value = "") @JsonProperty("complete") val complete: Boolean? = null ) { diff --git a/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/model/Pet.kt b/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/model/Pet.kt index 967bd0846b6e..80af728b7e49 100644 --- a/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/model/Pet.kt +++ b/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/model/Pet.kt @@ -25,19 +25,19 @@ data class Pet ( @JsonProperty("name") val name: String, @get:NotNull - @ApiModelProperty(required = true, value = "") + @ApiModelProperty(example = "null", required = true, value = "") @JsonProperty("photoUrls") val photoUrls: List, - @ApiModelProperty(value = "") + @ApiModelProperty(example = "null", value = "") @JsonProperty("id") val id: Long? = null, - @ApiModelProperty(value = "") + @ApiModelProperty(example = "null", value = "") @JsonProperty("category") val category: Category? = null, - @ApiModelProperty(value = "") + @ApiModelProperty(example = "null", value = "") @JsonProperty("tags") val tags: List? = null, - @ApiModelProperty(value = "pet status in the store") + @ApiModelProperty(example = "null", value = "pet status in the store") @JsonProperty("status") val status: Pet.Status? = null ) { diff --git a/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/model/Tag.kt b/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/model/Tag.kt index e40833c55fd0..70c706d00a6e 100644 --- a/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/model/Tag.kt +++ b/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/model/Tag.kt @@ -13,10 +13,10 @@ import io.swagger.annotations.ApiModelProperty */ data class Tag ( - @ApiModelProperty(value = "") + @ApiModelProperty(example = "null", value = "") @JsonProperty("id") val id: Long? = null, - @ApiModelProperty(value = "") + @ApiModelProperty(example = "null", value = "") @JsonProperty("name") val name: String? = null ) { diff --git a/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/model/User.kt b/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/model/User.kt index b9cc2886ea09..4cfaf0988746 100644 --- a/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/model/User.kt +++ b/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/model/User.kt @@ -19,28 +19,28 @@ import io.swagger.annotations.ApiModelProperty */ data class User ( - @ApiModelProperty(value = "") + @ApiModelProperty(example = "null", value = "") @JsonProperty("id") val id: Long? = null, - @ApiModelProperty(value = "") + @ApiModelProperty(example = "null", value = "") @JsonProperty("username") val username: String? = null, - @ApiModelProperty(value = "") + @ApiModelProperty(example = "null", value = "") @JsonProperty("firstName") val firstName: String? = null, - @ApiModelProperty(value = "") + @ApiModelProperty(example = "null", value = "") @JsonProperty("lastName") val lastName: String? = null, - @ApiModelProperty(value = "") + @ApiModelProperty(example = "null", value = "") @JsonProperty("email") val email: String? = null, - @ApiModelProperty(value = "") + @ApiModelProperty(example = "null", value = "") @JsonProperty("password") val password: String? = null, - @ApiModelProperty(value = "") + @ApiModelProperty(example = "null", value = "") @JsonProperty("phone") val phone: String? = null, - @ApiModelProperty(value = "User Status") + @ApiModelProperty(example = "null", value = "User Status") @JsonProperty("userStatus") val userStatus: Int? = null ) { From d198be884e9f0b54118d2de9f91dfda1eda10cdc Mon Sep 17 00:00:00 2001 From: Sylvain Moindron Date: Wed, 20 Mar 2019 08:11:02 +0100 Subject: [PATCH 3/7] run ./bin/kotlin-springboot-petstore-server.sh after building the CLI --- .../src/main/kotlin/org/openapitools/api/PetApi.kt | 1 - .../src/main/kotlin/org/openapitools/api/PetApiService.kt | 1 - .../src/main/kotlin/org/openapitools/api/PetApiServiceImpl.kt | 1 - 3 files changed, 3 deletions(-) diff --git a/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/api/PetApi.kt b/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/api/PetApi.kt index 1892bd6342e7..3b23aa1d370e 100644 --- a/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/api/PetApi.kt +++ b/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/api/PetApi.kt @@ -1,7 +1,6 @@ package org.openapitools.api import org.openapitools.model.ModelApiResponse -import org.openapitools.model.OrgspringframeworkcoreioResource import org.openapitools.model.Pet import io.swagger.annotations.* import org.springframework.http.HttpStatus diff --git a/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/api/PetApiService.kt b/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/api/PetApiService.kt index db28a6b17fb0..484b99c2fc52 100644 --- a/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/api/PetApiService.kt +++ b/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/api/PetApiService.kt @@ -1,7 +1,6 @@ package org.openapitools.api import org.openapitools.model.ModelApiResponse -import org.openapitools.model.OrgspringframeworkcoreioResource import org.openapitools.model.Pet interface PetApiService { diff --git a/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/api/PetApiServiceImpl.kt b/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/api/PetApiServiceImpl.kt index 5b819bf9d369..f86feff4f5d0 100644 --- a/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/api/PetApiServiceImpl.kt +++ b/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/api/PetApiServiceImpl.kt @@ -1,7 +1,6 @@ package org.openapitools.api import org.openapitools.model.ModelApiResponse -import org.openapitools.model.OrgspringframeworkcoreioResource import org.openapitools.model.Pet import org.springframework.stereotype.Service From d3d100c11f93b0e0217cc017287a9af657f3f0d5 Mon Sep 17 00:00:00 2001 From: Sylvain Moindron Date: Fri, 22 Mar 2019 17:05:51 +0100 Subject: [PATCH 4/7] use MultipartFile for file in form and the specified type otherwise --- .../src/main/resources/kotlin-spring/service.mustache | 2 +- .../src/main/resources/kotlin-spring/serviceImpl.mustache | 3 +-- .../src/main/kotlin/org/openapitools/api/PetApiServiceImpl.kt | 1 - .../main/kotlin/org/openapitools/api/StoreApiServiceImpl.kt | 1 - .../src/main/kotlin/org/openapitools/api/UserApiServiceImpl.kt | 1 - 5 files changed, 2 insertions(+), 6 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/kotlin-spring/service.mustache b/modules/openapi-generator/src/main/resources/kotlin-spring/service.mustache index 32bb190ea6b4..0f28f49bcedd 100644 --- a/modules/openapi-generator/src/main/resources/kotlin-spring/service.mustache +++ b/modules/openapi-generator/src/main/resources/kotlin-spring/service.mustache @@ -7,7 +7,7 @@ package {{package}} interface {{classname}}Service { {{#operation}} - fun {{operationId}}({{#allParams}}{{paramName}}: {{^isFile}}{{>optionalDataType}}{{/isFile}}{{#isFile}}org.springframework.web.multipart.MultipartFile{{/isFile}}{{#hasMore}},{{/hasMore}}{{/allParams}}): {{>returnTypes}} + fun {{operationId}}({{#allParams}}{{paramName}}: {{#isFormParam}}{{#isFile}}org.springframework.web.multipart.MultipartFile{{/isFile}}{{^isFile}}{{{dataType}}}{{/isFile}}{{/isFormParam}}{{^isFormParam}}{{{dataType}}}{{/isFormParam}}{{#hasMore}},{{/hasMore}}{{/allParams}}): {{>returnTypes}} {{/operation}} } {{/operations}} diff --git a/modules/openapi-generator/src/main/resources/kotlin-spring/serviceImpl.mustache b/modules/openapi-generator/src/main/resources/kotlin-spring/serviceImpl.mustache index d3dcedb061e2..8b9fd6f2d4f2 100644 --- a/modules/openapi-generator/src/main/resources/kotlin-spring/serviceImpl.mustache +++ b/modules/openapi-generator/src/main/resources/kotlin-spring/serviceImpl.mustache @@ -3,13 +3,12 @@ package {{package}} {{#imports}}import {{import}} {{/imports}} import org.springframework.stereotype.Service - @Service {{#operations}} class {{classname}}ServiceImpl : {{classname}}Service { {{#operation}} - override fun {{operationId}}({{#allParams}}{{paramName}}: {{^isFile}}{{>optionalDataType}}{{/isFile}}{{#isFile}}org.springframework.web.multipart.MultipartFile{{/isFile}}{{#hasMore}},{{/hasMore}}{{/allParams}}): {{>returnTypes}} { + override fun {{operationId}}({{#allParams}}{{paramName}}: {{#isFormParam}}{{#isFile}}org.springframework.web.multipart.MultipartFile{{/isFile}}{{^isFile}}{{{dataType}}}{{/isFile}}{{/isFormParam}}{{^isFormParam}}{{{dataType}}}{{/isFormParam}}{{#hasMore}},{{/hasMore}}{{/allParams}}): {{>returnTypes}} { TODO("Implement me") } {{/operation}} diff --git a/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/api/PetApiServiceImpl.kt b/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/api/PetApiServiceImpl.kt index f86feff4f5d0..2bd32e4e7d49 100644 --- a/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/api/PetApiServiceImpl.kt +++ b/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/api/PetApiServiceImpl.kt @@ -3,7 +3,6 @@ package org.openapitools.api import org.openapitools.model.ModelApiResponse import org.openapitools.model.Pet import org.springframework.stereotype.Service - @Service class PetApiServiceImpl : PetApiService { diff --git a/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/api/StoreApiServiceImpl.kt b/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/api/StoreApiServiceImpl.kt index ec26e074ac6f..f38e0eca525e 100644 --- a/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/api/StoreApiServiceImpl.kt +++ b/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/api/StoreApiServiceImpl.kt @@ -2,7 +2,6 @@ package org.openapitools.api import org.openapitools.model.Order import org.springframework.stereotype.Service - @Service class StoreApiServiceImpl : StoreApiService { diff --git a/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/api/UserApiServiceImpl.kt b/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/api/UserApiServiceImpl.kt index cb579c2c16f2..da6787b8838d 100644 --- a/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/api/UserApiServiceImpl.kt +++ b/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/api/UserApiServiceImpl.kt @@ -2,7 +2,6 @@ package org.openapitools.api import org.openapitools.model.User import org.springframework.stereotype.Service - @Service class UserApiServiceImpl : UserApiService { From 69a2359e2012ad3e50eacea418b5f0edcc61179a Mon Sep 17 00:00:00 2001 From: Sylvain Moindron Date: Fri, 22 Mar 2019 19:19:47 +0100 Subject: [PATCH 5/7] remplace tab with space --- .../languages/KotlinSpringServerCodegen.java | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/KotlinSpringServerCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/KotlinSpringServerCodegen.java index 61c6fd996193..8536e099ca4a 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/KotlinSpringServerCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/KotlinSpringServerCodegen.java @@ -567,21 +567,21 @@ public CodegenModel fromModel(String name, Schema schema) { return m; } - /** - * Output the proper model name (capitalized). - * In case the name belongs to the TypeSystem it won't be renamed. - * - * @param name the name of the model - * @return capitalized model name - */ - @Override - public String toModelName(final String name) { - // Allow for explicitly configured spring.* - if (name.startsWith("org.springframework.") ) { - return name; - } - return super.toModelName(name); - } + /** + * Output the proper model name (capitalized). + * In case the name belongs to the TypeSystem it won't be renamed. + * + * @param name the name of the model + * @return capitalized model name + */ + @Override + public String toModelName(final String name) { + // Allow for explicitly configured spring.* + if (name.startsWith("org.springframework.") ) { + return name; + } + return super.toModelName(name); + } /** * Check the type to see if it needs import the library/module/package From 7dab7e87f53a40eb4380a027c21e0882122551ca Mon Sep 17 00:00:00 2001 From: Sylvain Moindron Date: Mon, 25 Mar 2019 10:18:18 +0100 Subject: [PATCH 6/7] [kotlin-springboot] replace all instance of MultipartFile by Resource --- .../main/resources/kotlin-spring/api.mustache | 1 - .../kotlin-spring/formParams.mustache | 2 +- .../resources/kotlin-spring/service.mustache | 2 +- .../kotlin-spring/serviceImpl.mustache | 2 +- .../kotlin/org/openapitools/api/PetApi.kt | 30 +++++++++++++------ .../org/openapitools/api/PetApiService.kt | 2 +- .../org/openapitools/api/PetApiServiceImpl.kt | 2 +- .../kotlin/org/openapitools/api/StoreApi.kt | 10 ++++--- .../kotlin/org/openapitools/api/UserApi.kt | 24 ++++++++++----- 9 files changed, 48 insertions(+), 27 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/kotlin-spring/api.mustache b/modules/openapi-generator/src/main/resources/kotlin-spring/api.mustache index d8e69eb72f63..65f1f78b0659 100644 --- a/modules/openapi-generator/src/main/resources/kotlin-spring/api.mustache +++ b/modules/openapi-generator/src/main/resources/kotlin-spring/api.mustache @@ -20,7 +20,6 @@ import org.springframework.web.bind.annotation.RequestMapping import org.springframework.validation.annotation.Validated {{/useBeanValidation}} import org.springframework.web.context.request.NativeWebRequest -import org.springframework.web.multipart.MultipartFile import org.springframework.beans.factory.annotation.Autowired {{#useBeanValidation}} diff --git a/modules/openapi-generator/src/main/resources/kotlin-spring/formParams.mustache b/modules/openapi-generator/src/main/resources/kotlin-spring/formParams.mustache index f7b992616a21..f66ddb631ee1 100644 --- a/modules/openapi-generator/src/main/resources/kotlin-spring/formParams.mustache +++ b/modules/openapi-generator/src/main/resources/kotlin-spring/formParams.mustache @@ -1 +1 @@ -{{#isFormParam}}{{^isFile}}{{#swaggerAnnotations}}@ApiParam(value = "{{{description}}}"{{#required}}, required=true{{/required}}{{#allowableValues}}, allowableValues="{{#values}}{{{.}}}{{^-last}}, {{/-last}}{{#-last}}{{/-last}}{{/values}}"{{/allowableValues}}{{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{/defaultValue}}){{/swaggerAnnotations}} @RequestParam(value="{{baseName}}"{{#required}}, required=true{{/required}}{{^required}}, required=false{{/required}}) {{paramName}}: {{>optionalDataType}} {{/isFile}}{{#isFile}}{{#swaggerAnnotations}}@ApiParam(value = "file detail"){{/swaggerAnnotations}} {{#useBeanValidation}}@Valid{{/useBeanValidation}} @RequestPart("file") {{baseName}}: MultipartFile{{/isFile}}{{/isFormParam}} \ No newline at end of file +{{#isFormParam}}{{^isFile}}{{#swaggerAnnotations}}@ApiParam(value = "{{{description}}}"{{#required}}, required=true{{/required}}{{#allowableValues}}, allowableValues="{{#values}}{{{.}}}{{^-last}}, {{/-last}}{{#-last}}{{/-last}}{{/values}}"{{/allowableValues}}{{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{/defaultValue}}){{/swaggerAnnotations}} @RequestParam(value="{{baseName}}"{{#required}}, required=true{{/required}}{{^required}}, required=false{{/required}}) {{paramName}}: {{>optionalDataType}} {{/isFile}}{{#isFile}}{{#swaggerAnnotations}}@ApiParam(value = "file detail"){{/swaggerAnnotations}} {{#useBeanValidation}}@Valid{{/useBeanValidation}} @RequestPart("file") {{baseName}}: {{>optionalDataType}}{{/isFile}}{{/isFormParam}} diff --git a/modules/openapi-generator/src/main/resources/kotlin-spring/service.mustache b/modules/openapi-generator/src/main/resources/kotlin-spring/service.mustache index 0f28f49bcedd..37892a1f5347 100644 --- a/modules/openapi-generator/src/main/resources/kotlin-spring/service.mustache +++ b/modules/openapi-generator/src/main/resources/kotlin-spring/service.mustache @@ -7,7 +7,7 @@ package {{package}} interface {{classname}}Service { {{#operation}} - fun {{operationId}}({{#allParams}}{{paramName}}: {{#isFormParam}}{{#isFile}}org.springframework.web.multipart.MultipartFile{{/isFile}}{{^isFile}}{{{dataType}}}{{/isFile}}{{/isFormParam}}{{^isFormParam}}{{{dataType}}}{{/isFormParam}}{{#hasMore}},{{/hasMore}}{{/allParams}}): {{>returnTypes}} + fun {{operationId}}({{#allParams}}{{paramName}}: {{{dataType}}}{{#hasMore}},{{/hasMore}}{{/allParams}}): {{>returnTypes}} {{/operation}} } {{/operations}} diff --git a/modules/openapi-generator/src/main/resources/kotlin-spring/serviceImpl.mustache b/modules/openapi-generator/src/main/resources/kotlin-spring/serviceImpl.mustache index 8b9fd6f2d4f2..134600ecfc09 100644 --- a/modules/openapi-generator/src/main/resources/kotlin-spring/serviceImpl.mustache +++ b/modules/openapi-generator/src/main/resources/kotlin-spring/serviceImpl.mustache @@ -8,7 +8,7 @@ import org.springframework.stereotype.Service class {{classname}}ServiceImpl : {{classname}}Service { {{#operation}} - override fun {{operationId}}({{#allParams}}{{paramName}}: {{#isFormParam}}{{#isFile}}org.springframework.web.multipart.MultipartFile{{/isFile}}{{^isFile}}{{{dataType}}}{{/isFile}}{{/isFormParam}}{{^isFormParam}}{{{dataType}}}{{/isFormParam}}{{#hasMore}},{{/hasMore}}{{/allParams}}): {{>returnTypes}} { + override fun {{operationId}}({{#allParams}}{{paramName}}: {{{dataType}}}{{#hasMore}},{{/hasMore}}{{/allParams}}): {{>returnTypes}} { TODO("Implement me") } {{/operation}} diff --git a/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/api/PetApi.kt b/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/api/PetApi.kt index 3b23aa1d370e..4ef2a482b4df 100644 --- a/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/api/PetApi.kt +++ b/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/api/PetApi.kt @@ -16,7 +16,6 @@ import org.springframework.web.bind.annotation.RequestMethod import org.springframework.web.bind.annotation.RequestMapping import org.springframework.validation.annotation.Validated import org.springframework.web.context.request.NativeWebRequest -import org.springframework.web.multipart.MultipartFile import org.springframework.beans.factory.annotation.Autowired import javax.validation.Valid @@ -42,7 +41,8 @@ class PetApiController(@Autowired(required = true) val service: PetApiService) { value = ["/pet"], consumes = ["application/json", "application/xml"], method = [RequestMethod.POST]) - fun addPet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody body: Pet): ResponseEntity { + fun addPet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody body: Pet +): ResponseEntity { return ResponseEntity(service.addPet(body), HttpStatus.OK) } @@ -56,7 +56,9 @@ class PetApiController(@Autowired(required = true) val service: PetApiService) { @RequestMapping( value = ["/pet/{petId}"], method = [RequestMethod.DELETE]) - fun deletePet(@ApiParam(value = "Pet id to delete", required=true, defaultValue="null") @PathVariable("petId") petId: Long,@ApiParam(value = "" , defaultValue="null") @RequestHeader(value="api_key", required=false) apiKey: String): ResponseEntity { + fun deletePet(@ApiParam(value = "Pet id to delete", required=true, defaultValue="null") @PathVariable("petId") petId: Long +,@ApiParam(value = "" , defaultValue="null") @RequestHeader(value="api_key", required=false) apiKey: String +): ResponseEntity { return ResponseEntity(service.deletePet(petId, apiKey), HttpStatus.OK) } @@ -73,7 +75,8 @@ 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", defaultValue = "null") @Valid @RequestParam(value = "status", required = true, defaultValue="null") status: List): ResponseEntity> { + fun findPetsByStatus(@NotNull @ApiParam(value = "Status values that need to be considered for filter", required = true, allowableValues = "available, pending, sold", defaultValue = "null") @Valid @RequestParam(value = "status", required = true, defaultValue="null") status: List +): ResponseEntity> { return ResponseEntity(service.findPetsByStatus(status), HttpStatus.OK) } @@ -90,7 +93,8 @@ 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, defaultValue = "null") @Valid @RequestParam(value = "tags", required = true, defaultValue="null") tags: List): ResponseEntity> { + fun findPetsByTags(@NotNull @ApiParam(value = "Tags to filter by", required = true, defaultValue = "null") @Valid @RequestParam(value = "tags", required = true, defaultValue="null") tags: List +): ResponseEntity> { return ResponseEntity(service.findPetsByTags(tags), HttpStatus.OK) } @@ -106,7 +110,8 @@ class PetApiController(@Autowired(required = true) val service: PetApiService) { value = ["/pet/{petId}"], produces = ["application/xml", "application/json"], method = [RequestMethod.GET]) - fun getPetById(@ApiParam(value = "ID of pet to return", required=true, defaultValue="null") @PathVariable("petId") petId: Long): ResponseEntity { + fun getPetById(@ApiParam(value = "ID of pet to return", required=true, defaultValue="null") @PathVariable("petId") petId: Long +): ResponseEntity { return ResponseEntity(service.getPetById(petId), HttpStatus.OK) } @@ -121,7 +126,8 @@ class PetApiController(@Autowired(required = true) val service: PetApiService) { value = ["/pet"], consumes = ["application/json", "application/xml"], method = [RequestMethod.PUT]) - fun updatePet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody body: Pet): ResponseEntity { + fun updatePet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody body: Pet +): ResponseEntity { return ResponseEntity(service.updatePet(body), HttpStatus.OK) } @@ -136,7 +142,10 @@ class PetApiController(@Autowired(required = true) val service: PetApiService) { value = ["/pet/{petId}"], consumes = ["application/x-www-form-urlencoded"], method = [RequestMethod.POST]) - fun updatePetWithForm(@ApiParam(value = "ID of pet that needs to be updated", required=true, defaultValue="null") @PathVariable("petId") petId: Long,@ApiParam(value = "Updated name of the pet", defaultValue="null") @RequestParam(value="name", required=false) name: String ,@ApiParam(value = "Updated status of the pet", defaultValue="null") @RequestParam(value="status", required=false) status: String ): ResponseEntity { + fun updatePetWithForm(@ApiParam(value = "ID of pet that needs to be updated", required=true, defaultValue="null") @PathVariable("petId") petId: Long +,@ApiParam(value = "Updated name of the pet", defaultValue="null") @RequestParam(value="name", required=false) name: String +,@ApiParam(value = "Updated status of the pet", defaultValue="null") @RequestParam(value="status", required=false) status: String +): ResponseEntity { return ResponseEntity(service.updatePetWithForm(petId, name, status), HttpStatus.OK) } @@ -153,7 +162,10 @@ class PetApiController(@Autowired(required = true) val service: PetApiService) { produces = ["application/json"], consumes = ["multipart/form-data"], method = [RequestMethod.POST]) - fun uploadFile(@ApiParam(value = "ID of pet to update", required=true, defaultValue="null") @PathVariable("petId") petId: Long,@ApiParam(value = "Additional data to pass to server", defaultValue="null") @RequestParam(value="additionalMetadata", required=false) additionalMetadata: String ,@ApiParam(value = "file detail") @Valid @RequestPart("file") file: MultipartFile): ResponseEntity { + fun uploadFile(@ApiParam(value = "ID of pet to update", required=true, defaultValue="null") @PathVariable("petId") petId: Long +,@ApiParam(value = "Additional data to pass to server", defaultValue="null") @RequestParam(value="additionalMetadata", required=false) additionalMetadata: String +,@ApiParam(value = "file detail") @Valid @RequestPart("file") file: org.springframework.core.io.Resource +): ResponseEntity { return ResponseEntity(service.uploadFile(petId, additionalMetadata, file), HttpStatus.OK) } } diff --git a/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/api/PetApiService.kt b/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/api/PetApiService.kt index 484b99c2fc52..5218a25b638a 100644 --- a/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/api/PetApiService.kt +++ b/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/api/PetApiService.kt @@ -19,5 +19,5 @@ interface PetApiService { fun updatePetWithForm(petId: Long,name: String,status: String): Unit - fun uploadFile(petId: Long,additionalMetadata: String,file: org.springframework.web.multipart.MultipartFile): ModelApiResponse + fun uploadFile(petId: Long,additionalMetadata: String,file: org.springframework.core.io.Resource): ModelApiResponse } diff --git a/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/api/PetApiServiceImpl.kt b/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/api/PetApiServiceImpl.kt index 2bd32e4e7d49..8de49b91daa5 100644 --- a/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/api/PetApiServiceImpl.kt +++ b/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/api/PetApiServiceImpl.kt @@ -34,7 +34,7 @@ class PetApiServiceImpl : PetApiService { TODO("Implement me") } - override fun uploadFile(petId: Long,additionalMetadata: String,file: org.springframework.web.multipart.MultipartFile): ModelApiResponse { + override fun uploadFile(petId: Long,additionalMetadata: String,file: org.springframework.core.io.Resource): ModelApiResponse { TODO("Implement me") } } diff --git a/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/api/StoreApi.kt b/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/api/StoreApi.kt index 4e0a88706c31..b329db23791d 100644 --- a/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/api/StoreApi.kt +++ b/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/api/StoreApi.kt @@ -15,7 +15,6 @@ import org.springframework.web.bind.annotation.RequestMethod import org.springframework.web.bind.annotation.RequestMapping import org.springframework.validation.annotation.Validated import org.springframework.web.context.request.NativeWebRequest -import org.springframework.web.multipart.MultipartFile import org.springframework.beans.factory.annotation.Autowired import javax.validation.Valid @@ -39,7 +38,8 @@ class StoreApiController(@Autowired(required = true) val service: StoreApiServic @RequestMapping( value = ["/store/order/{orderId}"], method = [RequestMethod.DELETE]) - fun deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted", required=true, defaultValue="null") @PathVariable("orderId") orderId: String): ResponseEntity { + fun deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted", required=true, defaultValue="null") @PathVariable("orderId") orderId: String +): ResponseEntity { return ResponseEntity(service.deleteOrder(orderId), HttpStatus.OK) } @@ -71,7 +71,8 @@ class StoreApiController(@Autowired(required = true) val service: StoreApiServic value = ["/store/order/{orderId}"], produces = ["application/xml", "application/json"], method = [RequestMethod.GET]) - fun getOrderById(@Min(1L) @Max(5L) @ApiParam(value = "ID of pet that needs to be fetched", required=true, defaultValue="null") @PathVariable("orderId") orderId: Long): ResponseEntity { + fun getOrderById(@Min(1L) @Max(5L) @ApiParam(value = "ID of pet that needs to be fetched", required=true, defaultValue="null") @PathVariable("orderId") orderId: Long +): ResponseEntity { return ResponseEntity(service.getOrderById(orderId), HttpStatus.OK) } @@ -86,7 +87,8 @@ class StoreApiController(@Autowired(required = true) val service: StoreApiServic value = ["/store/order"], produces = ["application/xml", "application/json"], method = [RequestMethod.POST]) - fun placeOrder(@ApiParam(value = "order placed for purchasing the pet" ,required=true ) @Valid @RequestBody body: Order): ResponseEntity { + fun placeOrder(@ApiParam(value = "order placed for purchasing the pet" ,required=true ) @Valid @RequestBody body: Order +): ResponseEntity { return ResponseEntity(service.placeOrder(body), HttpStatus.OK) } } diff --git a/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/api/UserApi.kt b/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/api/UserApi.kt index 97d1151e7047..25203efd24e3 100644 --- a/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/api/UserApi.kt +++ b/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/api/UserApi.kt @@ -15,7 +15,6 @@ import org.springframework.web.bind.annotation.RequestMethod import org.springframework.web.bind.annotation.RequestMapping import org.springframework.validation.annotation.Validated import org.springframework.web.context.request.NativeWebRequest -import org.springframework.web.multipart.MultipartFile import org.springframework.beans.factory.annotation.Autowired import javax.validation.Valid @@ -39,7 +38,8 @@ class UserApiController(@Autowired(required = true) val service: UserApiService) @RequestMapping( value = ["/user"], method = [RequestMethod.POST]) - fun createUser(@ApiParam(value = "Created user object" ,required=true ) @Valid @RequestBody body: User): ResponseEntity { + fun createUser(@ApiParam(value = "Created user object" ,required=true ) @Valid @RequestBody body: User +): ResponseEntity { return ResponseEntity(service.createUser(body), HttpStatus.OK) } @@ -52,7 +52,8 @@ class UserApiController(@Autowired(required = true) val service: UserApiService) @RequestMapping( value = ["/user/createWithArray"], method = [RequestMethod.POST]) - fun createUsersWithArrayInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody body: List): ResponseEntity { + fun createUsersWithArrayInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody body: List +): ResponseEntity { return ResponseEntity(service.createUsersWithArrayInput(body), HttpStatus.OK) } @@ -65,7 +66,8 @@ class UserApiController(@Autowired(required = true) val service: UserApiService) @RequestMapping( value = ["/user/createWithList"], method = [RequestMethod.POST]) - fun createUsersWithListInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody body: List): ResponseEntity { + fun createUsersWithListInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody body: List +): ResponseEntity { return ResponseEntity(service.createUsersWithListInput(body), HttpStatus.OK) } @@ -78,7 +80,8 @@ class UserApiController(@Autowired(required = true) val service: UserApiService) @RequestMapping( value = ["/user/{username}"], method = [RequestMethod.DELETE]) - fun deleteUser(@ApiParam(value = "The name that needs to be deleted", required=true, defaultValue="null") @PathVariable("username") username: String): ResponseEntity { + fun deleteUser(@ApiParam(value = "The name that needs to be deleted", required=true, defaultValue="null") @PathVariable("username") username: String +): ResponseEntity { return ResponseEntity(service.deleteUser(username), HttpStatus.OK) } @@ -93,7 +96,8 @@ class UserApiController(@Autowired(required = true) val service: UserApiService) value = ["/user/{username}"], produces = ["application/xml", "application/json"], method = [RequestMethod.GET]) - fun getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing.", required=true, defaultValue="null") @PathVariable("username") username: String): ResponseEntity { + fun getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing.", required=true, defaultValue="null") @PathVariable("username") username: String +): ResponseEntity { return ResponseEntity(service.getUserByName(username), HttpStatus.OK) } @@ -108,7 +112,9 @@ class UserApiController(@Autowired(required = true) val service: UserApiService) value = ["/user/login"], produces = ["application/xml", "application/json"], method = [RequestMethod.GET]) - fun loginUser(@NotNull @ApiParam(value = "The user name for login", required = true, defaultValue = "null") @Valid @RequestParam(value = "username", required = true, defaultValue="null") username: String,@NotNull @ApiParam(value = "The password for login in clear text", required = true, defaultValue = "null") @Valid @RequestParam(value = "password", required = true, defaultValue="null") password: String): ResponseEntity { + fun loginUser(@NotNull @ApiParam(value = "The user name for login", required = true, defaultValue = "null") @Valid @RequestParam(value = "username", required = true, defaultValue="null") username: String +,@NotNull @ApiParam(value = "The password for login in clear text", required = true, defaultValue = "null") @Valid @RequestParam(value = "password", required = true, defaultValue="null") password: String +): ResponseEntity { return ResponseEntity(service.loginUser(username, password), HttpStatus.OK) } @@ -134,7 +140,9 @@ class UserApiController(@Autowired(required = true) val service: UserApiService) @RequestMapping( value = ["/user/{username}"], method = [RequestMethod.PUT]) - fun updateUser(@ApiParam(value = "name that need to be deleted", required=true, defaultValue="null") @PathVariable("username") username: String,@ApiParam(value = "Updated user object" ,required=true ) @Valid @RequestBody body: User): ResponseEntity { + fun updateUser(@ApiParam(value = "name that need to be deleted", required=true, defaultValue="null") @PathVariable("username") username: String +,@ApiParam(value = "Updated user object" ,required=true ) @Valid @RequestBody body: User +): ResponseEntity { return ResponseEntity(service.updateUser(username, body), HttpStatus.OK) } } From b282f18aca864a3dc18d90785fc22ff7ec9a3786 Mon Sep 17 00:00:00 2001 From: Sylvain Moindron Date: Mon, 25 Mar 2019 15:48:16 +0100 Subject: [PATCH 7/7] run ./bin/kotlin-springboot-petstore-server.sh --- .../src/main/kotlin/org/openapitools/api/PetApi.kt | 13 ++++++------- .../main/kotlin/org/openapitools/api/StoreApi.kt | 7 +++---- .../src/main/kotlin/org/openapitools/api/UserApi.kt | 5 ++--- 3 files changed, 11 insertions(+), 14 deletions(-) diff --git a/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/api/PetApi.kt b/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/api/PetApi.kt index 3b23aa1d370e..39c296968ea4 100644 --- a/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/api/PetApi.kt +++ b/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/api/PetApi.kt @@ -16,7 +16,6 @@ import org.springframework.web.bind.annotation.RequestMethod import org.springframework.web.bind.annotation.RequestMapping import org.springframework.validation.annotation.Validated import org.springframework.web.context.request.NativeWebRequest -import org.springframework.web.multipart.MultipartFile import org.springframework.beans.factory.annotation.Autowired import javax.validation.Valid @@ -71,7 +70,7 @@ class PetApiController(@Autowired(required = true) val service: PetApiService) { value = [ApiResponse(code = 200, message = "successful operation", response = Pet::class, responseContainer = "List"),ApiResponse(code = 400, message = "Invalid status value")]) @RequestMapping( value = ["/pet/findByStatus"], - produces = ["application/xml", "application/json"], + 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", defaultValue = "null") @Valid @RequestParam(value = "status", required = true, defaultValue="null") status: List): ResponseEntity> { return ResponseEntity(service.findPetsByStatus(status), HttpStatus.OK) @@ -88,7 +87,7 @@ class PetApiController(@Autowired(required = true) val service: PetApiService) { value = [ApiResponse(code = 200, message = "successful operation", response = Pet::class, responseContainer = "List"),ApiResponse(code = 400, message = "Invalid tag value")]) @RequestMapping( value = ["/pet/findByTags"], - produces = ["application/xml", "application/json"], + produces = ["application/xml", "application/json"], method = [RequestMethod.GET]) fun findPetsByTags(@NotNull @ApiParam(value = "Tags to filter by", required = true, defaultValue = "null") @Valid @RequestParam(value = "tags", required = true, defaultValue="null") tags: List): ResponseEntity> { return ResponseEntity(service.findPetsByTags(tags), HttpStatus.OK) @@ -104,7 +103,7 @@ class PetApiController(@Autowired(required = true) val service: PetApiService) { value = [ApiResponse(code = 200, message = "successful operation", response = Pet::class),ApiResponse(code = 400, message = "Invalid ID supplied"),ApiResponse(code = 404, message = "Pet not found")]) @RequestMapping( value = ["/pet/{petId}"], - produces = ["application/xml", "application/json"], + produces = ["application/xml", "application/json"], method = [RequestMethod.GET]) fun getPetById(@ApiParam(value = "ID of pet to return", required=true, defaultValue="null") @PathVariable("petId") petId: Long): ResponseEntity { return ResponseEntity(service.getPetById(petId), HttpStatus.OK) @@ -136,7 +135,7 @@ class PetApiController(@Autowired(required = true) val service: PetApiService) { value = ["/pet/{petId}"], consumes = ["application/x-www-form-urlencoded"], method = [RequestMethod.POST]) - fun updatePetWithForm(@ApiParam(value = "ID of pet that needs to be updated", required=true, defaultValue="null") @PathVariable("petId") petId: Long,@ApiParam(value = "Updated name of the pet", defaultValue="null") @RequestParam(value="name", required=false) name: String ,@ApiParam(value = "Updated status of the pet", defaultValue="null") @RequestParam(value="status", required=false) status: String ): ResponseEntity { + fun updatePetWithForm(@ApiParam(value = "ID of pet that needs to be updated", required=true, defaultValue="null") @PathVariable("petId") petId: Long,@ApiParam(value = "Updated name of the pet", defaultValue="null") @RequestParam(value="name", required=false) name: String,@ApiParam(value = "Updated status of the pet", defaultValue="null") @RequestParam(value="status", required=false) status: String): ResponseEntity { return ResponseEntity(service.updatePetWithForm(petId, name, status), HttpStatus.OK) } @@ -150,10 +149,10 @@ class PetApiController(@Autowired(required = true) val service: PetApiService) { value = [ApiResponse(code = 200, message = "successful operation", response = ModelApiResponse::class)]) @RequestMapping( value = ["/pet/{petId}/uploadImage"], - produces = ["application/json"], + produces = ["application/json"], consumes = ["multipart/form-data"], method = [RequestMethod.POST]) - fun uploadFile(@ApiParam(value = "ID of pet to update", required=true, defaultValue="null") @PathVariable("petId") petId: Long,@ApiParam(value = "Additional data to pass to server", defaultValue="null") @RequestParam(value="additionalMetadata", required=false) additionalMetadata: String ,@ApiParam(value = "file detail") @Valid @RequestPart("file") file: MultipartFile): ResponseEntity { + fun uploadFile(@ApiParam(value = "ID of pet to update", required=true, defaultValue="null") @PathVariable("petId") petId: Long,@ApiParam(value = "Additional data to pass to server", defaultValue="null") @RequestParam(value="additionalMetadata", required=false) additionalMetadata: String,@ApiParam(value = "file detail") @Valid @RequestPart("file") file: org.springframework.core.io.Resource): ResponseEntity { return ResponseEntity(service.uploadFile(petId, additionalMetadata, file), HttpStatus.OK) } } diff --git a/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/api/StoreApi.kt b/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/api/StoreApi.kt index 4e0a88706c31..c25e545a831f 100644 --- a/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/api/StoreApi.kt +++ b/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/api/StoreApi.kt @@ -15,7 +15,6 @@ import org.springframework.web.bind.annotation.RequestMethod import org.springframework.web.bind.annotation.RequestMapping import org.springframework.validation.annotation.Validated import org.springframework.web.context.request.NativeWebRequest -import org.springframework.web.multipart.MultipartFile import org.springframework.beans.factory.annotation.Autowired import javax.validation.Valid @@ -54,7 +53,7 @@ class StoreApiController(@Autowired(required = true) val service: StoreApiServic value = [ApiResponse(code = 200, message = "successful operation", response = Map::class, responseContainer = "Map")]) @RequestMapping( value = ["/store/inventory"], - produces = ["application/json"], + produces = ["application/json"], method = [RequestMethod.GET]) fun getInventory(): ResponseEntity> { return ResponseEntity(service.getInventory(), HttpStatus.OK) @@ -69,7 +68,7 @@ class StoreApiController(@Autowired(required = true) val service: StoreApiServic value = [ApiResponse(code = 200, message = "successful operation", response = Order::class),ApiResponse(code = 400, message = "Invalid ID supplied"),ApiResponse(code = 404, message = "Order not found")]) @RequestMapping( value = ["/store/order/{orderId}"], - produces = ["application/xml", "application/json"], + produces = ["application/xml", "application/json"], method = [RequestMethod.GET]) fun getOrderById(@Min(1L) @Max(5L) @ApiParam(value = "ID of pet that needs to be fetched", required=true, defaultValue="null") @PathVariable("orderId") orderId: Long): ResponseEntity { return ResponseEntity(service.getOrderById(orderId), HttpStatus.OK) @@ -84,7 +83,7 @@ class StoreApiController(@Autowired(required = true) val service: StoreApiServic value = [ApiResponse(code = 200, message = "successful operation", response = Order::class),ApiResponse(code = 400, message = "Invalid Order")]) @RequestMapping( value = ["/store/order"], - produces = ["application/xml", "application/json"], + produces = ["application/xml", "application/json"], method = [RequestMethod.POST]) fun placeOrder(@ApiParam(value = "order placed for purchasing the pet" ,required=true ) @Valid @RequestBody body: Order): ResponseEntity { return ResponseEntity(service.placeOrder(body), HttpStatus.OK) diff --git a/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/api/UserApi.kt b/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/api/UserApi.kt index 97d1151e7047..422d6649d897 100644 --- a/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/api/UserApi.kt +++ b/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/api/UserApi.kt @@ -15,7 +15,6 @@ import org.springframework.web.bind.annotation.RequestMethod import org.springframework.web.bind.annotation.RequestMapping import org.springframework.validation.annotation.Validated import org.springframework.web.context.request.NativeWebRequest -import org.springframework.web.multipart.MultipartFile import org.springframework.beans.factory.annotation.Autowired import javax.validation.Valid @@ -91,7 +90,7 @@ class UserApiController(@Autowired(required = true) val service: UserApiService) value = [ApiResponse(code = 200, message = "successful operation", response = User::class),ApiResponse(code = 400, message = "Invalid username supplied"),ApiResponse(code = 404, message = "User not found")]) @RequestMapping( value = ["/user/{username}"], - produces = ["application/xml", "application/json"], + produces = ["application/xml", "application/json"], method = [RequestMethod.GET]) fun getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing.", required=true, defaultValue="null") @PathVariable("username") username: String): ResponseEntity { return ResponseEntity(service.getUserByName(username), HttpStatus.OK) @@ -106,7 +105,7 @@ class UserApiController(@Autowired(required = true) val service: UserApiService) value = [ApiResponse(code = 200, message = "successful operation", response = String::class),ApiResponse(code = 400, message = "Invalid username/password supplied")]) @RequestMapping( value = ["/user/login"], - produces = ["application/xml", "application/json"], + produces = ["application/xml", "application/json"], method = [RequestMethod.GET]) fun loginUser(@NotNull @ApiParam(value = "The user name for login", required = true, defaultValue = "null") @Valid @RequestParam(value = "username", required = true, defaultValue="null") username: String,@NotNull @ApiParam(value = "The password for login in clear text", required = true, defaultValue = "null") @Valid @RequestParam(value = "password", required = true, defaultValue="null") password: String): ResponseEntity { return ResponseEntity(service.loginUser(username, password), HttpStatus.OK)