diff --git a/.github/workflows/samples-kotlin-server-jdk17.yaml b/.github/workflows/samples-kotlin-server-jdk17.yaml
index 6d45bcdf419e..065f05f5818f 100644
--- a/.github/workflows/samples-kotlin-server-jdk17.yaml
+++ b/.github/workflows/samples-kotlin-server-jdk17.yaml
@@ -30,7 +30,6 @@ jobs:
# server
- samples/server/petstore/kotlin-springboot-3
- samples/server/petstore/kotlin-springboot-delegate-nodefaults
- - samples/server/petstore/kotlin-springboot-request
- samples/server/petstore/kotlin-springboot-request-cookie
- samples/server/petstore/kotlin-server/javalin
- samples/server/petstore/kotlin-server/javalin-6
diff --git a/bin/configs/kotlin-spring-boot-request.yaml b/bin/configs/kotlin-spring-boot-request.yaml
deleted file mode 100644
index 45cd1f00334b..000000000000
--- a/bin/configs/kotlin-spring-boot-request.yaml
+++ /dev/null
@@ -1,9 +0,0 @@
-generatorName: kotlin-spring
-outputDir: samples/server/petstore/kotlin-springboot-request
-library: spring-boot
-inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore.yaml
-templateDir: modules/openapi-generator/src/main/resources/kotlin-spring
-additionalProperties:
- appendRequestToHandler: true
- interfaceOnly: true
- useSpringBoot3: true
diff --git a/docs/generators/kotlin-spring.md b/docs/generators/kotlin-spring.md
index b40ecbbc5f0c..5aa6a24c2f6a 100644
--- a/docs/generators/kotlin-spring.md
+++ b/docs/generators/kotlin-spring.md
@@ -22,7 +22,6 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|annotationLibrary|Select the complementary documentation annotation library.|
- **none**
- Do not annotate Model and Api with complementary annotations.
- **swagger1**
- Annotate Model and Api using the Swagger Annotations 1.x library.
- **swagger2**
- Annotate Model and Api using the Swagger Annotations 2.x library.
|swagger2|
|apiPackage|api package for generated code| |org.openapitools.api|
|apiSuffix|suffix for api classes| |Api|
-|appendRequestToHandler|Append ServerHttpRequest to handler method for getting request stuff| |false|
|artifactId|Generated artifact id (name of jar).| |openapi-spring|
|artifactVersion|Generated artifact's package version.| |1.0.0|
|basePackage|base package (invokerPackage) for generated code| |org.openapitools|
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 6c8d0fdf94ac..05e56b0facf2 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
@@ -105,7 +105,6 @@ public class KotlinSpringServerCodegen extends AbstractKotlinCodegen
public static final String BEAN_QUALIFIERS = "beanQualifiers";
public static final String USE_SPRING_BOOT3 = "useSpringBoot3";
- public static final String APPEND_REQUEST_TO_HANDLER = "appendRequestToHandler";
public static final String REQUEST_MAPPING_OPTION = "requestMappingMode";
public static final String USE_REQUEST_MAPPING_ON_CONTROLLER = "useRequestMappingOnController";
public static final String USE_REQUEST_MAPPING_ON_INTERFACE = "useRequestMappingOnInterface";
@@ -236,7 +235,6 @@ public KotlinSpringServerCodegen() {
"@RestController annotations. May be used to prevent bean names clash if multiple generated libraries" +
" (contexts) added to single project.", beanQualifiers);
addSwitch(USE_SPRING_BOOT3, "Generate code and provide dependencies for use with Spring Boot 3.x. (Use jakarta instead of javax in imports). Enabling this option will also enable `useJakartaEe`.", useSpringBoot3);
- addSwitch(APPEND_REQUEST_TO_HANDLER, "Append ServerHttpRequest to handler method for getting request stuff", false);
supportedLibraries.put(SPRING_BOOT, "Spring-boot Server application.");
supportedLibraries.put(SPRING_CLOUD_LIBRARY,
"Spring-Cloud-Feign client with Spring-Boot auto-configured settings.");
@@ -356,10 +354,6 @@ public boolean getUseBeanValidation() {
return this.useBeanValidation;
}
- public boolean isAppendRequestToHandler() {
- return Boolean.parseBoolean(additionalProperties.getOrDefault(APPEND_REQUEST_TO_HANDLER, false).toString());
- }
-
@Override
public void setUseBeanValidation(boolean useBeanValidation) {
this.useBeanValidation = useBeanValidation;
@@ -889,9 +883,6 @@ public void setReturnContainer(final String returnContainer) {
final List allParams = operation.allParams;
if (allParams != null) {
- if (this.isAppendRequestToHandler()) {
- allParams.add(new RequestCodegenParameter());
- }
allParams.forEach(param ->
// This is necessary in case 'modelMutable' is enabled,
// to prevent Spring Request handlers from being generated with
@@ -983,22 +974,6 @@ protected boolean needToImport(String type) {
return !type.startsWith("org.springframework.") && super.needToImport(type);
}
- @AllArgsConstructor
- @Data
- @EqualsAndHashCode(callSuper = true)
- static class RequestCodegenParameter extends CodegenParameter {
-
- boolean isRequestObject = true;
-
- public RequestCodegenParameter() {
- this.isOptional = false;
- this.required = true;
- this.paramName = "serverHttpRequest";
- this.dataType = "ServerHttpRequest";
- }
-
- }
-
public RequestMappingMode getRequestMappingMode() {
return requestMappingMode;
}
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 0a0ccabc42f4..6220601fe64a 100644
--- a/modules/openapi-generator/src/main/resources/kotlin-spring/api.mustache
+++ b/modules/openapi-generator/src/main/resources/kotlin-spring/api.mustache
@@ -29,9 +29,6 @@ import org.springframework.validation.annotation.Validated
import org.springframework.web.context.request.NativeWebRequest
import org.springframework.beans.factory.annotation.Autowired
-{{#appendRequestToHandler}}
-import org.springframework.http.server.reactive.ServerHttpRequest
-{{/appendRequestToHandler}}
{{#useBeanValidation}}
import {{javaxPackage}}.validation.Valid
import {{javaxPackage}}.validation.constraints.DecimalMax
@@ -92,7 +89,7 @@ class {{classname}}Controller({{#serviceInterface}}@Autowired(required = true) v
produces = [{{#produces}}"{{{mediaType}}}"{{^-last}}, {{/-last}}{{/produces}}]{{/hasProduces}}{{#hasConsumes}},
consumes = [{{#consumes}}"{{{mediaType}}}"{{^-last}}, {{/-last}}{{/consumes}}]{{/hasConsumes}}{{/singleContentTypes}}
)
- {{#reactive}}{{^isArray}}suspend {{/isArray}}{{/reactive}}fun {{operationId}}({{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>cookieParams}}{{>bodyParams}}{{>formParams}}{{>requesObject}}{{^-last}},{{/-last}}{{/allParams}}): ResponseEntity<{{>returnTypes}}> {
+ {{#reactive}}{{^isArray}}suspend {{/isArray}}{{/reactive}}fun {{operationId}}({{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>cookieParams}}{{>bodyParams}}{{>formParams}}{{^-last}},{{/-last}}{{/allParams}}): ResponseEntity<{{>returnTypes}}> {
return {{>returnValue}}
}
{{/operation}}
diff --git a/modules/openapi-generator/src/main/resources/kotlin-spring/apiInterface.mustache b/modules/openapi-generator/src/main/resources/kotlin-spring/apiInterface.mustache
index 6f92da7db7f4..0fc6145c091a 100644
--- a/modules/openapi-generator/src/main/resources/kotlin-spring/apiInterface.mustache
+++ b/modules/openapi-generator/src/main/resources/kotlin-spring/apiInterface.mustache
@@ -26,9 +26,6 @@ import io.swagger.annotations.AuthorizationScope
import org.springframework.http.HttpStatus
import org.springframework.http.MediaType
import org.springframework.http.ResponseEntity
-{{#appendRequestToHandler}}
-import org.springframework.http.server.reactive.ServerHttpRequest
-{{/appendRequestToHandler}}
import org.springframework.web.bind.annotation.*
{{#useBeanValidation}}
@@ -103,7 +100,7 @@ interface {{classname}} {
produces = [{{#produces}}"{{{mediaType}}}"{{^-last}}, {{/-last}}{{/produces}}]{{/hasProduces}}{{#hasConsumes}},
consumes = [{{#consumes}}"{{{mediaType}}}"{{^-last}}, {{/-last}}{{/consumes}}]{{/hasConsumes}}{{/singleContentTypes}}
)
- {{#reactive}}{{^isArray}}suspend {{/isArray}}{{/reactive}}fun {{operationId}}({{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>cookieParams}}{{>bodyParams}}{{>formParams}}{{>requesObject}}{{^-last}},{{/-last}}{{/allParams}}): ResponseEntity<{{>returnTypes}}>{{^skipDefaultApiInterface}} {
+ {{#reactive}}{{^isArray}}suspend {{/isArray}}{{/reactive}}fun {{operationId}}({{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>cookieParams}}{{>bodyParams}}{{>formParams}}{{^-last}},{{/-last}}{{/allParams}}): ResponseEntity<{{>returnTypes}}>{{^skipDefaultApiInterface}} {
{{^isDelegate}}
return {{>returnValue}}
{{/isDelegate}}
diff --git a/modules/openapi-generator/src/main/resources/kotlin-spring/requesObject.mustache b/modules/openapi-generator/src/main/resources/kotlin-spring/requesObject.mustache
deleted file mode 100644
index 86737ff049a1..000000000000
--- a/modules/openapi-generator/src/main/resources/kotlin-spring/requesObject.mustache
+++ /dev/null
@@ -1 +0,0 @@
-{{#isRequestObject}}serverHttpRequest: ServerHttpRequest{{/isRequestObject}}
\ No newline at end of file
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 ec0f91792ce7..215a58a4b27b 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,7 +15,6 @@ 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
@@ -58,8 +57,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,serverHttpRequest: ServerHttpRequest): ResponseEntity {
- return getDelegate().addPet(pet, serverHttpRequest)
+ 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)
}
@Operation(
@@ -76,8 +75,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?,serverHttpRequest: ServerHttpRequest): ResponseEntity {
- return getDelegate().deletePet(petId, apiKey, serverHttpRequest)
+ 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)
}
@Operation(
@@ -96,8 +95,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,serverHttpRequest: ServerHttpRequest): ResponseEntity> {
- return getDelegate().findPetsByStatus(status, serverHttpRequest)
+ 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)
}
@Operation(
@@ -116,8 +115,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,serverHttpRequest: ServerHttpRequest): ResponseEntity> {
- return getDelegate().findPetsByTags(tags, serverHttpRequest)
+ 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)
}
@Operation(
@@ -137,8 +136,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,serverHttpRequest: ServerHttpRequest): ResponseEntity {
- return getDelegate().getPetById(petId, serverHttpRequest)
+ fun getPetById(@Parameter(description = "ID of pet to return", required = true) @PathVariable("petId") petId: kotlin.Long): ResponseEntity {
+ return getDelegate().getPetById(petId)
}
@Operation(
@@ -160,8 +159,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,serverHttpRequest: ServerHttpRequest): ResponseEntity {
- return getDelegate().updatePet(pet, serverHttpRequest)
+ 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)
}
@Operation(
@@ -179,8 +178,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? ,serverHttpRequest: ServerHttpRequest): ResponseEntity {
- return getDelegate().updatePetWithForm(petId, name, status, serverHttpRequest)
+ 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)
}
@Operation(
@@ -199,7 +198,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?,serverHttpRequest: ServerHttpRequest): ResponseEntity {
- return getDelegate().uploadFile(petId, additionalMetadata, file, serverHttpRequest)
+ 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)
}
}
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 02833c01311e..417b9ae3b201 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
@@ -23,8 +23,7 @@ interface PetApiDelegate {
/**
* @see PetApi#addPet
*/
- fun addPet(pet: Pet,
- serverHttpRequest: ServerHttpRequest): ResponseEntity {
+ fun addPet(pet: Pet): ResponseEntity {
getRequest().ifPresent { request ->
for (mediaType in MediaType.parseMediaTypes(request.getHeader("Accept"))) {
if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) {
@@ -46,8 +45,7 @@ interface PetApiDelegate {
* @see PetApi#deletePet
*/
fun deletePet(petId: kotlin.Long,
- apiKey: kotlin.String?,
- serverHttpRequest: ServerHttpRequest): ResponseEntity {
+ apiKey: kotlin.String?): ResponseEntity {
return ResponseEntity(HttpStatus.NOT_IMPLEMENTED)
}
@@ -56,8 +54,7 @@ interface PetApiDelegate {
/**
* @see PetApi#findPetsByStatus
*/
- fun findPetsByStatus(status: kotlin.collections.List,
- serverHttpRequest: ServerHttpRequest): ResponseEntity> {
+ fun findPetsByStatus(status: kotlin.collections.List): ResponseEntity> {
getRequest().ifPresent { request ->
for (mediaType in MediaType.parseMediaTypes(request.getHeader("Accept"))) {
if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) {
@@ -78,8 +75,7 @@ interface PetApiDelegate {
/**
* @see PetApi#findPetsByTags
*/
- fun findPetsByTags(tags: kotlin.collections.List,
- serverHttpRequest: ServerHttpRequest): ResponseEntity> {
+ fun findPetsByTags(tags: kotlin.collections.List): ResponseEntity> {
getRequest().ifPresent { request ->
for (mediaType in MediaType.parseMediaTypes(request.getHeader("Accept"))) {
if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) {
@@ -100,8 +96,7 @@ interface PetApiDelegate {
/**
* @see PetApi#getPetById
*/
- fun getPetById(petId: kotlin.Long,
- serverHttpRequest: ServerHttpRequest): ResponseEntity {
+ fun getPetById(petId: kotlin.Long): ResponseEntity {
getRequest().ifPresent { request ->
for (mediaType in MediaType.parseMediaTypes(request.getHeader("Accept"))) {
if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) {
@@ -122,8 +117,7 @@ interface PetApiDelegate {
/**
* @see PetApi#updatePet
*/
- fun updatePet(pet: Pet,
- serverHttpRequest: ServerHttpRequest): ResponseEntity {
+ fun updatePet(pet: Pet): ResponseEntity {
getRequest().ifPresent { request ->
for (mediaType in MediaType.parseMediaTypes(request.getHeader("Accept"))) {
if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) {
@@ -146,8 +140,7 @@ interface PetApiDelegate {
*/
fun updatePetWithForm(petId: kotlin.Long,
name: kotlin.String?,
- status: kotlin.String?,
- serverHttpRequest: ServerHttpRequest): ResponseEntity {
+ status: kotlin.String?): ResponseEntity {
return ResponseEntity(HttpStatus.NOT_IMPLEMENTED)
}
@@ -158,8 +151,7 @@ interface PetApiDelegate {
*/
fun uploadFile(petId: kotlin.Long,
additionalMetadata: kotlin.String?,
- file: Resource?,
- serverHttpRequest: ServerHttpRequest): ResponseEntity {
+ file: Resource?): 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 08aca0640b15..c2330402ef04 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,7 +14,6 @@ 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 +53,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,serverHttpRequest: ServerHttpRequest): ResponseEntity {
- return getDelegate().deleteOrder(orderId, serverHttpRequest)
+ 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)
}
@Operation(
@@ -73,8 +72,8 @@ interface StoreApi {
value = ["/store/inventory"],
produces = ["application/json"]
)
- fun getInventory(serverHttpRequest: ServerHttpRequest): ResponseEntity