diff --git a/bin/configs/kotlin-spring-boot-delegate.yaml b/bin/configs/kotlin-spring-boot-delegate.yaml index 3e70591b81b..38fdee37dc7 100644 --- a/bin/configs/kotlin-spring-boot-delegate.yaml +++ b/bin/configs/kotlin-spring-boot-delegate.yaml @@ -8,5 +8,6 @@ additionalProperties: annotationLibrary: swagger2 useSwaggerUI: "true" delegatePattern: "true" + appendRequestToHandler: "true" beanValidations: "true" requestMappingMode: none 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 3111c2a3bc4..5fe9488ad28 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 @@ -875,7 +875,7 @@ public class KotlinSpringServerCodegen extends AbstractKotlinCodegen final List allParams = operation.allParams; if (allParams != null) { if (this.isAppendRequestToHandler()) { - allParams.add(new RequestCodegenParameter(true)); + allParams.add(new RequestCodegenParameter()); } allParams.forEach(param -> // This is necessary in case 'modelMutable' is enabled, @@ -972,7 +972,16 @@ public class KotlinSpringServerCodegen extends AbstractKotlinCodegen @Data @EqualsAndHashCode(callSuper = true) static class RequestCodegenParameter extends CodegenParameter { - boolean isRequestObject; + + boolean isRequestObject = true; + + public RequestCodegenParameter() { + this.isOptional = false; + this.required = true; + this.paramName = "serverHttpRequest"; + this.dataType = "ServerHttpRequest"; + } + } public RequestMappingMode getRequestMappingMode() { diff --git a/modules/openapi-generator/src/main/resources/kotlin-spring/apiDelegate.mustache b/modules/openapi-generator/src/main/resources/kotlin-spring/apiDelegate.mustache index b1203ff381b..9dba52c9bf3 100644 --- a/modules/openapi-generator/src/main/resources/kotlin-spring/apiDelegate.mustache +++ b/modules/openapi-generator/src/main/resources/kotlin-spring/apiDelegate.mustache @@ -7,6 +7,9 @@ import org.springframework.http.MediaType import org.springframework.http.ResponseEntity import org.springframework.web.context.request.NativeWebRequest import org.springframework.core.io.Resource +{{#appendRequestToHandler}} +import org.springframework.http.server.reactive.ServerHttpRequest +{{/appendRequestToHandler}} {{#reactive}} import kotlinx.coroutines.flow.Flow {{/reactive}} diff --git a/samples/server/petstore/kotlin-springboot-delegate/src/main/kotlin/org/openapitools/api/PetApi.kt b/samples/server/petstore/kotlin-springboot-delegate/src/main/kotlin/org/openapitools/api/PetApi.kt index f93350173eb..5479b06dcb3 100644 --- a/samples/server/petstore/kotlin-springboot-delegate/src/main/kotlin/org/openapitools/api/PetApi.kt +++ b/samples/server/petstore/kotlin-springboot-delegate/src/main/kotlin/org/openapitools/api/PetApi.kt @@ -15,6 +15,7 @@ import io.swagger.v3.oas.annotations.security.* import org.springframework.http.HttpStatus import org.springframework.http.MediaType import org.springframework.http.ResponseEntity +import org.springframework.http.server.reactive.ServerHttpRequest import org.springframework.web.bind.annotation.* import org.springframework.validation.annotation.Validated @@ -57,8 +58,8 @@ interface PetApi { produces = ["application/xml", "application/json"], consumes = ["application/json", "application/xml"] ) - fun addPet(@Parameter(description = "Pet object that needs to be added to the store", required = true) @Valid @RequestBody pet: Pet): ResponseEntity { - return getDelegate().addPet(pet) + fun addPet(@Parameter(description = "Pet object that needs to be added to the store", required = true) @Valid @RequestBody pet: Pet,serverHttpRequest: ServerHttpRequest): ResponseEntity { + return getDelegate().addPet(pet, serverHttpRequest) } @Operation( @@ -75,8 +76,8 @@ interface PetApi { method = [RequestMethod.DELETE], value = ["/pet/{petId}"] ) - fun deletePet(@Parameter(description = "Pet id to delete", required = true) @PathVariable("petId") petId: kotlin.Long,@Parameter(description = "", `in` = ParameterIn.HEADER) @RequestHeader(value = "api_key", required = false) apiKey: kotlin.String?): ResponseEntity { - return getDelegate().deletePet(petId, apiKey) + fun deletePet(@Parameter(description = "Pet id to delete", required = true) @PathVariable("petId") petId: kotlin.Long,@Parameter(description = "", `in` = ParameterIn.HEADER) @RequestHeader(value = "api_key", required = false) apiKey: kotlin.String?,serverHttpRequest: ServerHttpRequest): ResponseEntity { + return getDelegate().deletePet(petId, apiKey, serverHttpRequest) } @Operation( @@ -95,8 +96,8 @@ interface PetApi { value = ["/pet/findByStatus"], produces = ["application/xml", "application/json"] ) - 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): ResponseEntity> { - return getDelegate().findPetsByStatus(status) + 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,serverHttpRequest: ServerHttpRequest): ResponseEntity> { + return getDelegate().findPetsByStatus(status, serverHttpRequest) } @Operation( @@ -115,8 +116,8 @@ interface PetApi { value = ["/pet/findByTags"], produces = ["application/xml", "application/json"] ) - fun findPetsByTags(@NotNull @Parameter(description = "Tags to filter by", required = true) @Valid @RequestParam(value = "tags", required = true) tags: kotlin.collections.List): ResponseEntity> { - return getDelegate().findPetsByTags(tags) + fun findPetsByTags(@NotNull @Parameter(description = "Tags to filter by", required = true) @Valid @RequestParam(value = "tags", required = true) tags: kotlin.collections.List,serverHttpRequest: ServerHttpRequest): ResponseEntity> { + return getDelegate().findPetsByTags(tags, serverHttpRequest) } @Operation( @@ -136,8 +137,8 @@ interface PetApi { value = ["/pet/{petId}"], produces = ["application/xml", "application/json"] ) - fun getPetById(@Parameter(description = "ID of pet to return", required = true) @PathVariable("petId") petId: kotlin.Long): ResponseEntity { - return getDelegate().getPetById(petId) + fun getPetById(@Parameter(description = "ID of pet to return", required = true) @PathVariable("petId") petId: kotlin.Long,serverHttpRequest: ServerHttpRequest): ResponseEntity { + return getDelegate().getPetById(petId, serverHttpRequest) } @Operation( @@ -159,8 +160,8 @@ interface PetApi { produces = ["application/xml", "application/json"], consumes = ["application/json", "application/xml"] ) - fun updatePet(@Parameter(description = "Pet object that needs to be added to the store", required = true) @Valid @RequestBody pet: Pet): ResponseEntity { - return getDelegate().updatePet(pet) + fun updatePet(@Parameter(description = "Pet object that needs to be added to the store", required = true) @Valid @RequestBody pet: Pet,serverHttpRequest: ServerHttpRequest): ResponseEntity { + return getDelegate().updatePet(pet, serverHttpRequest) } @Operation( @@ -178,8 +179,8 @@ interface PetApi { value = ["/pet/{petId}"], consumes = ["application/x-www-form-urlencoded"] ) - fun updatePetWithForm(@Parameter(description = "ID of pet that needs to be updated", required = true) @PathVariable("petId") petId: kotlin.Long,@Parameter(description = "Updated name of the pet") @RequestParam(value = "name", required = false) name: kotlin.String? ,@Parameter(description = "Updated status of the pet") @RequestParam(value = "status", required = false) status: kotlin.String? ): ResponseEntity { - return getDelegate().updatePetWithForm(petId, name, status) + fun updatePetWithForm(@Parameter(description = "ID of pet that needs to be updated", required = true) @PathVariable("petId") petId: kotlin.Long,@Parameter(description = "Updated name of the pet") @RequestParam(value = "name", required = false) name: kotlin.String? ,@Parameter(description = "Updated status of the pet") @RequestParam(value = "status", required = false) status: kotlin.String? ,serverHttpRequest: ServerHttpRequest): ResponseEntity { + return getDelegate().updatePetWithForm(petId, name, status, serverHttpRequest) } @Operation( @@ -198,7 +199,7 @@ interface PetApi { produces = ["application/json"], consumes = ["multipart/form-data"] ) - fun uploadFile(@Parameter(description = "ID of pet to update", required = true) @PathVariable("petId") petId: kotlin.Long,@Parameter(description = "Additional data to pass to server") @RequestParam(value = "additionalMetadata", required = false) additionalMetadata: kotlin.String? ,@Parameter(description = "file to upload") @Valid @RequestPart("file", required = false) file: org.springframework.core.io.Resource?): ResponseEntity { - return getDelegate().uploadFile(petId, additionalMetadata, file) + fun uploadFile(@Parameter(description = "ID of pet to update", required = true) @PathVariable("petId") petId: kotlin.Long,@Parameter(description = "Additional data to pass to server") @RequestParam(value = "additionalMetadata", required = false) additionalMetadata: kotlin.String? ,@Parameter(description = "file to upload") @Valid @RequestPart("file", required = false) file: org.springframework.core.io.Resource?,serverHttpRequest: ServerHttpRequest): ResponseEntity { + return getDelegate().uploadFile(petId, additionalMetadata, file, serverHttpRequest) } } diff --git a/samples/server/petstore/kotlin-springboot-delegate/src/main/kotlin/org/openapitools/api/PetApiDelegate.kt b/samples/server/petstore/kotlin-springboot-delegate/src/main/kotlin/org/openapitools/api/PetApiDelegate.kt index 25381eb447f..b147b13bcdc 100644 --- a/samples/server/petstore/kotlin-springboot-delegate/src/main/kotlin/org/openapitools/api/PetApiDelegate.kt +++ b/samples/server/petstore/kotlin-springboot-delegate/src/main/kotlin/org/openapitools/api/PetApiDelegate.kt @@ -7,6 +7,7 @@ import org.springframework.http.MediaType import org.springframework.http.ResponseEntity import org.springframework.web.context.request.NativeWebRequest import org.springframework.core.io.Resource +import org.springframework.http.server.reactive.ServerHttpRequest import java.util.Optional @@ -22,7 +23,8 @@ interface PetApiDelegate { /** * @see PetApi#addPet */ - fun addPet(pet: Pet): ResponseEntity { + fun addPet(pet: Pet, + serverHttpRequest: ServerHttpRequest): ResponseEntity { getRequest().ifPresent { request -> for (mediaType in MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { @@ -44,7 +46,8 @@ interface PetApiDelegate { * @see PetApi#deletePet */ fun deletePet(petId: kotlin.Long, - apiKey: kotlin.String?): ResponseEntity { + apiKey: kotlin.String?, + serverHttpRequest: ServerHttpRequest): ResponseEntity { return ResponseEntity(HttpStatus.NOT_IMPLEMENTED) } @@ -53,7 +56,8 @@ interface PetApiDelegate { /** * @see PetApi#findPetsByStatus */ - fun findPetsByStatus(status: kotlin.collections.List): ResponseEntity> { + fun findPetsByStatus(status: kotlin.collections.List, + serverHttpRequest: ServerHttpRequest): ResponseEntity> { getRequest().ifPresent { request -> for (mediaType in MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { @@ -74,7 +78,8 @@ interface PetApiDelegate { /** * @see PetApi#findPetsByTags */ - fun findPetsByTags(tags: kotlin.collections.List): ResponseEntity> { + fun findPetsByTags(tags: kotlin.collections.List, + serverHttpRequest: ServerHttpRequest): ResponseEntity> { getRequest().ifPresent { request -> for (mediaType in MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { @@ -95,7 +100,8 @@ interface PetApiDelegate { /** * @see PetApi#getPetById */ - fun getPetById(petId: kotlin.Long): ResponseEntity { + fun getPetById(petId: kotlin.Long, + serverHttpRequest: ServerHttpRequest): ResponseEntity { getRequest().ifPresent { request -> for (mediaType in MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { @@ -116,7 +122,8 @@ interface PetApiDelegate { /** * @see PetApi#updatePet */ - fun updatePet(pet: Pet): ResponseEntity { + fun updatePet(pet: Pet, + serverHttpRequest: ServerHttpRequest): ResponseEntity { getRequest().ifPresent { request -> for (mediaType in MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { @@ -139,7 +146,8 @@ interface PetApiDelegate { */ fun updatePetWithForm(petId: kotlin.Long, name: kotlin.String?, - status: kotlin.String?): ResponseEntity { + status: kotlin.String?, + serverHttpRequest: ServerHttpRequest): ResponseEntity { return ResponseEntity(HttpStatus.NOT_IMPLEMENTED) } @@ -150,7 +158,8 @@ interface PetApiDelegate { */ fun uploadFile(petId: kotlin.Long, additionalMetadata: kotlin.String?, - file: Resource?): ResponseEntity { + file: Resource?, + serverHttpRequest: ServerHttpRequest): ResponseEntity { getRequest().ifPresent { request -> for (mediaType in MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { diff --git a/samples/server/petstore/kotlin-springboot-delegate/src/main/kotlin/org/openapitools/api/StoreApi.kt b/samples/server/petstore/kotlin-springboot-delegate/src/main/kotlin/org/openapitools/api/StoreApi.kt index 307de99db93..21ad6956d87 100644 --- a/samples/server/petstore/kotlin-springboot-delegate/src/main/kotlin/org/openapitools/api/StoreApi.kt +++ b/samples/server/petstore/kotlin-springboot-delegate/src/main/kotlin/org/openapitools/api/StoreApi.kt @@ -14,6 +14,7 @@ import io.swagger.v3.oas.annotations.security.* import org.springframework.http.HttpStatus import org.springframework.http.MediaType import org.springframework.http.ResponseEntity +import org.springframework.http.server.reactive.ServerHttpRequest import org.springframework.web.bind.annotation.* import org.springframework.validation.annotation.Validated @@ -53,8 +54,8 @@ interface StoreApi { method = [RequestMethod.DELETE], value = ["/store/order/{orderId}"] ) - fun deleteOrder(@Parameter(description = "ID of the order that needs to be deleted", required = true) @PathVariable("orderId") orderId: kotlin.String): ResponseEntity { - return getDelegate().deleteOrder(orderId) + fun deleteOrder(@Parameter(description = "ID of the order that needs to be deleted", required = true) @PathVariable("orderId") orderId: kotlin.String,serverHttpRequest: ServerHttpRequest): ResponseEntity { + return getDelegate().deleteOrder(orderId, serverHttpRequest) } @Operation( @@ -72,8 +73,8 @@ interface StoreApi { value = ["/store/inventory"], produces = ["application/json"] ) - fun getInventory(): ResponseEntity> { - return getDelegate().getInventory() + fun getInventory(serverHttpRequest: ServerHttpRequest): ResponseEntity> { + return getDelegate().getInventory(serverHttpRequest) } @Operation( @@ -92,8 +93,8 @@ interface StoreApi { value = ["/store/order/{orderId}"], produces = ["application/xml", "application/json"] ) - fun getOrderById(@Min(1L) @Max(5L) @Parameter(description = "ID of pet that needs to be fetched", required = true) @PathVariable("orderId") orderId: kotlin.Long): ResponseEntity { - return getDelegate().getOrderById(orderId) + fun getOrderById(@Min(1L) @Max(5L) @Parameter(description = "ID of pet that needs to be fetched", required = true) @PathVariable("orderId") orderId: kotlin.Long,serverHttpRequest: ServerHttpRequest): ResponseEntity { + return getDelegate().getOrderById(orderId, serverHttpRequest) } @Operation( @@ -112,7 +113,7 @@ interface StoreApi { produces = ["application/xml", "application/json"], consumes = ["application/json"] ) - fun placeOrder(@Parameter(description = "order placed for purchasing the pet", required = true) @Valid @RequestBody order: Order): ResponseEntity { - return getDelegate().placeOrder(order) + fun placeOrder(@Parameter(description = "order placed for purchasing the pet", required = true) @Valid @RequestBody order: Order,serverHttpRequest: ServerHttpRequest): ResponseEntity { + return getDelegate().placeOrder(order, serverHttpRequest) } } diff --git a/samples/server/petstore/kotlin-springboot-delegate/src/main/kotlin/org/openapitools/api/StoreApiDelegate.kt b/samples/server/petstore/kotlin-springboot-delegate/src/main/kotlin/org/openapitools/api/StoreApiDelegate.kt index 26ae5451b6b..9d3283b9eeb 100644 --- a/samples/server/petstore/kotlin-springboot-delegate/src/main/kotlin/org/openapitools/api/StoreApiDelegate.kt +++ b/samples/server/petstore/kotlin-springboot-delegate/src/main/kotlin/org/openapitools/api/StoreApiDelegate.kt @@ -6,6 +6,7 @@ import org.springframework.http.MediaType import org.springframework.http.ResponseEntity import org.springframework.web.context.request.NativeWebRequest import org.springframework.core.io.Resource +import org.springframework.http.server.reactive.ServerHttpRequest import java.util.Optional @@ -21,7 +22,8 @@ interface StoreApiDelegate { /** * @see StoreApi#deleteOrder */ - fun deleteOrder(orderId: kotlin.String): ResponseEntity { + fun deleteOrder(orderId: kotlin.String, + serverHttpRequest: ServerHttpRequest): ResponseEntity { return ResponseEntity(HttpStatus.NOT_IMPLEMENTED) } @@ -30,7 +32,7 @@ interface StoreApiDelegate { /** * @see StoreApi#getInventory */ - fun getInventory(): ResponseEntity> { + fun getInventory(serverHttpRequest: ServerHttpRequest): ResponseEntity> { return ResponseEntity(HttpStatus.NOT_IMPLEMENTED) } @@ -39,7 +41,8 @@ interface StoreApiDelegate { /** * @see StoreApi#getOrderById */ - fun getOrderById(orderId: kotlin.Long): ResponseEntity { + fun getOrderById(orderId: kotlin.Long, + serverHttpRequest: ServerHttpRequest): ResponseEntity { getRequest().ifPresent { request -> for (mediaType in MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { @@ -60,7 +63,8 @@ interface StoreApiDelegate { /** * @see StoreApi#placeOrder */ - fun placeOrder(order: Order): ResponseEntity { + fun placeOrder(order: Order, + serverHttpRequest: ServerHttpRequest): ResponseEntity { getRequest().ifPresent { request -> for (mediaType in MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { diff --git a/samples/server/petstore/kotlin-springboot-delegate/src/main/kotlin/org/openapitools/api/UserApi.kt b/samples/server/petstore/kotlin-springboot-delegate/src/main/kotlin/org/openapitools/api/UserApi.kt index bfd9e9cac5b..15715a17ecf 100644 --- a/samples/server/petstore/kotlin-springboot-delegate/src/main/kotlin/org/openapitools/api/UserApi.kt +++ b/samples/server/petstore/kotlin-springboot-delegate/src/main/kotlin/org/openapitools/api/UserApi.kt @@ -14,6 +14,7 @@ import io.swagger.v3.oas.annotations.security.* import org.springframework.http.HttpStatus import org.springframework.http.MediaType import org.springframework.http.ResponseEntity +import org.springframework.http.server.reactive.ServerHttpRequest import org.springframework.web.bind.annotation.* import org.springframework.validation.annotation.Validated @@ -54,8 +55,8 @@ interface UserApi { value = ["/user"], consumes = ["application/json"] ) - fun createUser(@Parameter(description = "Created user object", required = true) @Valid @RequestBody user: User): ResponseEntity { - return getDelegate().createUser(user) + fun createUser(@Parameter(description = "Created user object", required = true) @Valid @RequestBody user: User,serverHttpRequest: ServerHttpRequest): ResponseEntity { + return getDelegate().createUser(user, serverHttpRequest) } @Operation( @@ -73,8 +74,8 @@ interface UserApi { value = ["/user/createWithArray"], consumes = ["application/json"] ) - fun createUsersWithArrayInput(@Parameter(description = "List of user object", required = true) @Valid @RequestBody user: kotlin.collections.List): ResponseEntity { - return getDelegate().createUsersWithArrayInput(user) + fun createUsersWithArrayInput(@Parameter(description = "List of user object", required = true) @Valid @RequestBody user: kotlin.collections.List,serverHttpRequest: ServerHttpRequest): ResponseEntity { + return getDelegate().createUsersWithArrayInput(user, serverHttpRequest) } @Operation( @@ -92,8 +93,8 @@ interface UserApi { value = ["/user/createWithList"], consumes = ["application/json"] ) - fun createUsersWithListInput(@Parameter(description = "List of user object", required = true) @Valid @RequestBody user: kotlin.collections.List): ResponseEntity { - return getDelegate().createUsersWithListInput(user) + fun createUsersWithListInput(@Parameter(description = "List of user object", required = true) @Valid @RequestBody user: kotlin.collections.List,serverHttpRequest: ServerHttpRequest): ResponseEntity { + return getDelegate().createUsersWithListInput(user, serverHttpRequest) } @Operation( @@ -111,8 +112,8 @@ interface UserApi { method = [RequestMethod.DELETE], value = ["/user/{username}"] ) - fun deleteUser(@Parameter(description = "The name that needs to be deleted", required = true) @PathVariable("username") username: kotlin.String): ResponseEntity { - return getDelegate().deleteUser(username) + fun deleteUser(@Parameter(description = "The name that needs to be deleted", required = true) @PathVariable("username") username: kotlin.String,serverHttpRequest: ServerHttpRequest): ResponseEntity { + return getDelegate().deleteUser(username, serverHttpRequest) } @Operation( @@ -131,8 +132,8 @@ interface UserApi { value = ["/user/{username}"], produces = ["application/xml", "application/json"] ) - fun getUserByName(@Parameter(description = "The name that needs to be fetched. Use user1 for testing.", required = true) @PathVariable("username") username: kotlin.String): ResponseEntity { - return getDelegate().getUserByName(username) + fun getUserByName(@Parameter(description = "The name that needs to be fetched. Use user1 for testing.", required = true) @PathVariable("username") username: kotlin.String,serverHttpRequest: ServerHttpRequest): ResponseEntity { + return getDelegate().getUserByName(username, serverHttpRequest) } @Operation( @@ -150,8 +151,8 @@ interface UserApi { value = ["/user/login"], produces = ["application/xml", "application/json"] ) - 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 { - return getDelegate().loginUser(username, password) + 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,serverHttpRequest: ServerHttpRequest): ResponseEntity { + return getDelegate().loginUser(username, password, serverHttpRequest) } @Operation( @@ -168,8 +169,8 @@ interface UserApi { method = [RequestMethod.GET], value = ["/user/logout"] ) - fun logoutUser(): ResponseEntity { - return getDelegate().logoutUser() + fun logoutUser(serverHttpRequest: ServerHttpRequest): ResponseEntity { + return getDelegate().logoutUser(serverHttpRequest) } @Operation( @@ -188,7 +189,7 @@ interface UserApi { value = ["/user/{username}"], consumes = ["application/json"] ) - 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 { - return getDelegate().updateUser(username, user) + 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,serverHttpRequest: ServerHttpRequest): ResponseEntity { + return getDelegate().updateUser(username, user, serverHttpRequest) } } diff --git a/samples/server/petstore/kotlin-springboot-delegate/src/main/kotlin/org/openapitools/api/UserApiDelegate.kt b/samples/server/petstore/kotlin-springboot-delegate/src/main/kotlin/org/openapitools/api/UserApiDelegate.kt index 94f261b5ed0..9d192c57371 100644 --- a/samples/server/petstore/kotlin-springboot-delegate/src/main/kotlin/org/openapitools/api/UserApiDelegate.kt +++ b/samples/server/petstore/kotlin-springboot-delegate/src/main/kotlin/org/openapitools/api/UserApiDelegate.kt @@ -6,6 +6,7 @@ import org.springframework.http.MediaType import org.springframework.http.ResponseEntity import org.springframework.web.context.request.NativeWebRequest import org.springframework.core.io.Resource +import org.springframework.http.server.reactive.ServerHttpRequest import java.util.Optional @@ -21,7 +22,8 @@ interface UserApiDelegate { /** * @see UserApi#createUser */ - fun createUser(user: User): ResponseEntity { + fun createUser(user: User, + serverHttpRequest: ServerHttpRequest): ResponseEntity { return ResponseEntity(HttpStatus.NOT_IMPLEMENTED) } @@ -30,7 +32,8 @@ interface UserApiDelegate { /** * @see UserApi#createUsersWithArrayInput */ - fun createUsersWithArrayInput(user: kotlin.collections.List): ResponseEntity { + fun createUsersWithArrayInput(user: kotlin.collections.List, + serverHttpRequest: ServerHttpRequest): ResponseEntity { return ResponseEntity(HttpStatus.NOT_IMPLEMENTED) } @@ -39,7 +42,8 @@ interface UserApiDelegate { /** * @see UserApi#createUsersWithListInput */ - fun createUsersWithListInput(user: kotlin.collections.List): ResponseEntity { + fun createUsersWithListInput(user: kotlin.collections.List, + serverHttpRequest: ServerHttpRequest): ResponseEntity { return ResponseEntity(HttpStatus.NOT_IMPLEMENTED) } @@ -48,7 +52,8 @@ interface UserApiDelegate { /** * @see UserApi#deleteUser */ - fun deleteUser(username: kotlin.String): ResponseEntity { + fun deleteUser(username: kotlin.String, + serverHttpRequest: ServerHttpRequest): ResponseEntity { return ResponseEntity(HttpStatus.NOT_IMPLEMENTED) } @@ -57,7 +62,8 @@ interface UserApiDelegate { /** * @see UserApi#getUserByName */ - fun getUserByName(username: kotlin.String): ResponseEntity { + fun getUserByName(username: kotlin.String, + serverHttpRequest: ServerHttpRequest): ResponseEntity { getRequest().ifPresent { request -> for (mediaType in MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { @@ -79,7 +85,8 @@ interface UserApiDelegate { * @see UserApi#loginUser */ fun loginUser(username: kotlin.String, - password: kotlin.String): ResponseEntity { + password: kotlin.String, + serverHttpRequest: ServerHttpRequest): ResponseEntity { return ResponseEntity(HttpStatus.NOT_IMPLEMENTED) } @@ -88,7 +95,7 @@ interface UserApiDelegate { /** * @see UserApi#logoutUser */ - fun logoutUser(): ResponseEntity { + fun logoutUser(serverHttpRequest: ServerHttpRequest): ResponseEntity { return ResponseEntity(HttpStatus.NOT_IMPLEMENTED) } @@ -98,7 +105,8 @@ interface UserApiDelegate { * @see UserApi#updateUser */ fun updateUser(username: kotlin.String, - user: User): ResponseEntity { + user: User, + serverHttpRequest: ServerHttpRequest): ResponseEntity { return ResponseEntity(HttpStatus.NOT_IMPLEMENTED) }