diff --git a/.github/workflows/samples-kotlin-server-jdk17.yaml b/.github/workflows/samples-kotlin-server-jdk17.yaml
index 11b9f872b531..22d45ef94c88 100644
--- a/.github/workflows/samples-kotlin-server-jdk17.yaml
+++ b/.github/workflows/samples-kotlin-server-jdk17.yaml
@@ -8,6 +8,7 @@ on:
- 'samples/server/petstore/kotlin-server-modelMutable/**'
- 'samples/server/petstore/kotlin-springboot-*/**'
- 'samples/server/petstore/kotlin-server-required-and-nullable-properties/**'
+ - 'samples/server/petstore/kotlin-spring-declarative*/**'
# comment out due to gradle build failure
# - samples/server/petstore/kotlin-spring-default/**
pull_request:
@@ -17,6 +18,7 @@ on:
- 'samples/server/petstore/kotlin-server-modelMutable/**'
- 'samples/server/petstore/kotlin-springboot-*/**'
- 'samples/server/petstore/kotlin-server-required-and-nullable-properties/**'
+ - 'samples/server/petstore/kotlin-spring-declarative*/**'
# comment out due to gradle build failure
# - samples/server/petstore/kotlin-spring-default/**
@@ -44,6 +46,10 @@ jobs:
- samples/server/petstore/kotlin-server/ktor
- samples/server/petstore/kotlin-server/ktor2
- samples/server/petstore/kotlin-misk
+ - samples/server/petstore/kotlin-spring-declarative-interface
+ - samples/server/petstore/kotlin-spring-declarative-interface-reactive-coroutines
+ - samples/server/petstore/kotlin-spring-declarative-interface-reactive-reactor-wrapped
+ - samples/server/petstore/kotlin-spring-declarative-interface-wrapped
# comment out due to gradle build failure
# - samples/server/petstore/kotlin-spring-default/
steps:
diff --git a/bin/configs/kotlin-spring-declarative-interface-reactive-coroutines.yaml b/bin/configs/kotlin-spring-declarative-interface-reactive-coroutines.yaml
new file mode 100644
index 000000000000..e2ad5943459f
--- /dev/null
+++ b/bin/configs/kotlin-spring-declarative-interface-reactive-coroutines.yaml
@@ -0,0 +1,16 @@
+generatorName: kotlin-spring
+outputDir: samples/server/petstore/kotlin-spring-declarative-interface-reactive-coroutines
+library: spring-declarative-http-interface
+inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore.yaml
+templateDir: modules/openapi-generator/src/main/resources/kotlin-spring
+additionalProperties:
+ documentationProvider: springDoc
+ annotationLibrary: swagger2
+ useSwaggerUI: "false"
+ serializableModel: "true"
+ beanValidations: "true"
+ interfaceOnly: true
+ reactive: true
+ declarativeInterfaceWrapResponses: false
+ useFlowForArrayReturnType: false
+ declarativeInterfaceReactiveMode: "coroutines"
diff --git a/bin/configs/kotlin-spring-declarative-interface-reactive-reactor-wrapped.yaml b/bin/configs/kotlin-spring-declarative-interface-reactive-reactor-wrapped.yaml
new file mode 100644
index 000000000000..99ea39a3c8a6
--- /dev/null
+++ b/bin/configs/kotlin-spring-declarative-interface-reactive-reactor-wrapped.yaml
@@ -0,0 +1,16 @@
+generatorName: kotlin-spring
+outputDir: samples/server/petstore/kotlin-spring-declarative-interface-reactive-reactor-wrapped
+library: spring-declarative-http-interface
+inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore.yaml
+templateDir: modules/openapi-generator/src/main/resources/kotlin-spring
+additionalProperties:
+ documentationProvider: springDoc
+ annotationLibrary: swagger2
+ useSwaggerUI: "false"
+ serializableModel: "true"
+ beanValidations: "true"
+ interfaceOnly: true
+ reactive: true
+ declarativeInterfaceWrapResponses: true
+ useFlowForArrayReturnType: false
+ declarativeInterfaceReactiveMode: "reactor"
diff --git a/bin/configs/kotlin-spring-declarative-interface-wrapped.yaml b/bin/configs/kotlin-spring-declarative-interface-wrapped.yaml
new file mode 100644
index 000000000000..978584977ae2
--- /dev/null
+++ b/bin/configs/kotlin-spring-declarative-interface-wrapped.yaml
@@ -0,0 +1,15 @@
+generatorName: kotlin-spring
+outputDir: samples/server/petstore/kotlin-spring-declarative-interface-wrapped
+library: spring-declarative-http-interface
+inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore.yaml
+templateDir: modules/openapi-generator/src/main/resources/kotlin-spring
+additionalProperties:
+ documentationProvider: springDoc
+ annotationLibrary: swagger2
+ useSwaggerUI: "false"
+ serializableModel: "true"
+ beanValidations: "true"
+ interfaceOnly: true
+ reactive: false
+ declarativeInterfaceWrapResponses: true
+ useFlowForArrayReturnType: false
diff --git a/bin/configs/kotlin-spring-declarative-interface.yaml b/bin/configs/kotlin-spring-declarative-interface.yaml
new file mode 100644
index 000000000000..436e59186636
--- /dev/null
+++ b/bin/configs/kotlin-spring-declarative-interface.yaml
@@ -0,0 +1,15 @@
+generatorName: kotlin-spring
+outputDir: samples/server/petstore/kotlin-spring-declarative-interface
+library: spring-declarative-http-interface
+inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore.yaml
+templateDir: modules/openapi-generator/src/main/resources/kotlin-spring
+additionalProperties:
+ documentationProvider: springDoc
+ annotationLibrary: swagger2
+ useSwaggerUI: "false"
+ serializableModel: "true"
+ beanValidations: "true"
+ interfaceOnly: true
+ reactive: false
+ declarativeInterfaceWrapResponses: true
+ useFlowForArrayReturnType: false
diff --git a/docs/generators/kotlin-spring.md b/docs/generators/kotlin-spring.md
index e79fdd782b70..3326822cbf3a 100644
--- a/docs/generators/kotlin-spring.md
+++ b/docs/generators/kotlin-spring.md
@@ -27,6 +27,8 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|basePackage|base package (invokerPackage) for generated code| |org.openapitools|
|beanQualifiers|Whether to add fully-qualifier class names as bean qualifiers in @Component and @RestController annotations. May be used to prevent bean names clash if multiple generated libraries (contexts) added to single project.| |false|
|configPackage|configuration package for generated code| |org.openapitools.configuration|
+|declarativeInterfaceReactiveMode|What type of reactive style to use in Spring Http declarative interface|
- **coroutines**
- Use kotlin-idiomatic 'suspend' functions
- **reactor**
- Use reactor return wrappers 'Mono' and 'Flux'
|coroutines|
+|declarativeInterfaceWrapResponses|Whether (when false) to return actual type (e.g. List<Fruit>) and handle non 2xx responses via exceptions or (when true) return entire ResponseEntity (e.g. ResponseEntity<List<Fruit>>)| |false|
|delegatePattern|Whether to generate the server files using the delegate pattern| |false|
|documentationProvider|Select the OpenAPI documentation provider.|- **none**
- Do not publish an OpenAPI specification.
- **source**
- Publish the original input OpenAPI specification.
- **springfox**
- Generate an OpenAPI 2 (fka Swagger RESTful API Documentation Specification) specification using SpringFox 2.x. Deprecated (for removal); use springdoc instead.
- **springdoc**
- Generate an OpenAPI 3 specification using SpringDoc.
|springdoc|
|enumPropertyNaming|Naming convention for enum properties: 'camelCase', 'PascalCase', 'snake_case', 'UPPERCASE', and 'original'| |original|
@@ -34,7 +36,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|gradleBuildFile|generate a gradle build file using the Kotlin DSL| |true|
|groupId|Generated artifact package's organization (i.e. maven groupId).| |org.openapitools|
|interfaceOnly|Whether to generate only API interface stubs without the server files.| |false|
-|library|library template (sub-template)|- **spring-boot**
- Spring-boot Server application.
- **spring-cloud**
- Spring-Cloud-Feign client with Spring-Boot auto-configured settings.
|spring-boot|
+|library|library template (sub-template)|- **spring-boot**
- Spring-boot Server application.
- **spring-cloud**
- Spring-Cloud-Feign client with Spring-Boot auto-configured settings.
- **spring-declarative-http-interface**
- Spring Declarative Interface client
|spring-boot|
|modelMutable|Create mutable models| |false|
|modelPackage|model package for generated code| |org.openapitools.model|
|packageName|Generated artifact package name.| |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 821726610733..fe46ac1483fb 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
@@ -70,6 +70,7 @@ public class KotlinSpringServerCodegen extends AbstractKotlinCodegen
public static final String BASE_PACKAGE = "basePackage";
public static final String SPRING_BOOT = "spring-boot";
public static final String SPRING_CLOUD_LIBRARY = "spring-cloud";
+ public static final String SPRING_DECLARATIVE_HTTP_INTERFACE_LIBRARY = "spring-declarative-http-interface";
public static final String EXCEPTION_HANDLER = "exceptionHandler";
public static final String GRADLE_BUILD_FILE = "gradleBuildFile";
public static final String SERVICE_INTERFACE = "serviceInterface";
@@ -84,6 +85,8 @@ public class KotlinSpringServerCodegen extends AbstractKotlinCodegen
public static final String DELEGATE_PATTERN = "delegatePattern";
public static final String USE_TAGS = "useTags";
public static final String BEAN_QUALIFIERS = "beanQualifiers";
+ public static final String DECLARATIVE_INTERFACE_WRAP_RESPONSES = "declarativeInterfaceWrapResponses";
+ public static final String DECLARATIVE_INTERFACE_REACTIVE_MODE = "declarativeInterfaceReactiveMode";
public static final String USE_SPRING_BOOT3 = "useSpringBoot3";
public static final String USE_FLOW_FOR_ARRAY_RETURN_TYPE = "useFlowForArrayReturnType";
@@ -91,6 +94,20 @@ public class KotlinSpringServerCodegen extends AbstractKotlinCodegen
public static final String USE_REQUEST_MAPPING_ON_CONTROLLER = "useRequestMappingOnController";
public static final String USE_REQUEST_MAPPING_ON_INTERFACE = "useRequestMappingOnInterface";
+ @Getter
+ public enum DeclarativeInterfaceReactiveMode {
+ coroutines("Use kotlin-idiomatic 'suspend' functions", "reactiveModeCoroutines"),
+ reactor("Use reactor return wrappers 'Mono' and 'Flux'", "reactiveModeReactor");
+
+ private final String description;
+ private final String additionalPropertyName;
+
+ DeclarativeInterfaceReactiveMode(String description, String additionalPropertyName) {
+ this.description = description;
+ this.additionalPropertyName = additionalPropertyName;
+ }
+ }
+
public enum RequestMappingMode {
api_interface("Generate the @RequestMapping annotation on the generated Api Interface."),
controller("Generate the @RequestMapping annotation on the generated Api Controller Implementation."),
@@ -135,6 +152,8 @@ public String getDescription() {
@Setter private boolean delegatePattern = false;
@Setter protected boolean useTags = false;
@Setter private boolean beanQualifiers = false;
+ @Setter private DeclarativeInterfaceReactiveMode declarativeInterfaceReactiveMode = DeclarativeInterfaceReactiveMode.coroutines;
+ @Setter private boolean declarativeInterfaceWrapResponses = false;
@Getter @Setter
protected boolean useSpringBoot3 = false;
@@ -220,9 +239,14 @@ public KotlinSpringServerCodegen() {
" (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(USE_FLOW_FOR_ARRAY_RETURN_TYPE, "Whether to use Flow for array/collection return types when reactive is enabled. If false, will use List instead.", useFlowForArrayReturnType);
+ addSwitch(DECLARATIVE_INTERFACE_WRAP_RESPONSES,
+ "Whether (when false) to return actual type (e.g. List) and handle non 2xx responses via exceptions or (when true) return entire ResponseEntity (e.g. ResponseEntity>)",
+ declarativeInterfaceWrapResponses);
supportedLibraries.put(SPRING_BOOT, "Spring-boot Server application.");
supportedLibraries.put(SPRING_CLOUD_LIBRARY,
"Spring-Cloud-Feign client with Spring-Boot auto-configured settings.");
+ supportedLibraries.put(SPRING_DECLARATIVE_HTTP_INTERFACE_LIBRARY,
+ "Spring Declarative Interface client");
setLibrary(SPRING_BOOT);
CliOption cliOpt = new CliOption(CodegenConstants.LIBRARY, CodegenConstants.LIBRARY_DESC);
@@ -238,6 +262,14 @@ public KotlinSpringServerCodegen() {
}
cliOptions.add(requestMappingOpt);
+ CliOption declarativeInterfaceReactiveModeOpt = new CliOption(DECLARATIVE_INTERFACE_REACTIVE_MODE,
+ "What type of reactive style to use in Spring Http declarative interface")
+ .defaultValue(declarativeInterfaceReactiveMode.name());
+ for (DeclarativeInterfaceReactiveMode mode : DeclarativeInterfaceReactiveMode.values()) {
+ declarativeInterfaceReactiveModeOpt.addEnum(mode.name(), mode.getDescription());
+ }
+ cliOptions.add(declarativeInterfaceReactiveModeOpt);
+
if (null != defaultDocumentationProvider()) {
CliOption documentationProviderCliOption = new CliOption(DOCUMENTATION_PROVIDER,
"Select the OpenAPI documentation provider.")
@@ -518,6 +550,41 @@ public void processOpts() {
this.setUseFlowForArrayReturnType(convertPropertyToBoolean(USE_FLOW_FOR_ARRAY_RETURN_TYPE));
}
}
+ if (library.equals(SPRING_DECLARATIVE_HTTP_INTERFACE_LIBRARY)) {
+ this.setReactive(convertPropertyToBoolean(REACTIVE));
+ if (additionalProperties.containsKey(USE_FLOW_FOR_ARRAY_RETURN_TYPE)) {
+ this.setUseFlowForArrayReturnType(convertPropertyToBoolean(USE_FLOW_FOR_ARRAY_RETURN_TYPE));
+ }
+ if (this.isUseFlowForArrayReturnType()) {
+ {
+ throw new IllegalArgumentException("Additional property '" + USE_FLOW_FOR_ARRAY_RETURN_TYPE + "' must be set to 'false' as it is not supported by Spring declarative HTTP interface");
+ }
+ }
+ if (additionalProperties.containsKey(DECLARATIVE_INTERFACE_REACTIVE_MODE)) {
+ try {
+ DeclarativeInterfaceReactiveMode optValue = DeclarativeInterfaceReactiveMode.valueOf(
+ String.valueOf(additionalProperties.get(DECLARATIVE_INTERFACE_REACTIVE_MODE)));
+ setDeclarativeInterfaceReactiveMode(optValue);
+ writePropertyBack(optValue.getAdditionalPropertyName(), true);
+ additionalProperties.remove(DECLARATIVE_INTERFACE_REACTIVE_MODE);
+ } catch (IllegalArgumentException e) {
+ throw new IllegalArgumentException(
+ "Invalid value for additional property '" + DECLARATIVE_INTERFACE_REACTIVE_MODE + "'. Supported values are " + Arrays.toString(DeclarativeInterfaceReactiveMode.values()) + "."
+ );
+ }
+ }
+ }
+ }
+ if (SPRING_DECLARATIVE_HTTP_INTERFACE_LIBRARY.equals(library)) {
+ this.setUseSpringBoot3(true);
+ this.setInterfaceOnly(true);
+ this.setUseFeignClient(false);
+ this.setSkipDefaultInterface(true);
+
+ writePropertyBack(USE_SPRING_BOOT3, useSpringBoot3);
+ writePropertyBack(INTERFACE_ONLY, interfaceOnly);
+ writePropertyBack(USE_FEIGN_CLIENT, useFeignClient);
+ writePropertyBack(SKIP_DEFAULT_INTERFACE, skipDefaultInterface);
}
writePropertyBack(REACTIVE, reactive);
writePropertyBack(EXCEPTION_HANDLER, exceptionHandler);
@@ -606,7 +673,7 @@ public void processOpts() {
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
- if (this.exceptionHandler && !library.equals(SPRING_CLOUD_LIBRARY)) {
+ if (this.exceptionHandler && !(library.equals(SPRING_CLOUD_LIBRARY) || library.equals(SPRING_DECLARATIVE_HTTP_INTERFACE_LIBRARY))) {
supportingFiles.add(new SupportingFile("exceptions.mustache",
sanitizeDirectory(sourceFolder + File.separator + apiPackage), "Exceptions.kt"));
}
@@ -699,8 +766,29 @@ public void processOpts() {
apiTestTemplateFiles.clear();
}
+ if (library.equals(SPRING_DECLARATIVE_HTTP_INTERFACE_LIBRARY)) {
+ LOGGER.info("Setup code generator for Kotlin Spring Declarative Http interface");
+
+ supportingFiles.add(new SupportingFile("pom-sb3.mustache", "pom.xml"));
+
+ if (this.gradleBuildFile) {
+ supportingFiles.add(new SupportingFile("buildGradle-sb3-Kts.mustache", "build.gradle.kts"));
+ supportingFiles.add(new SupportingFile("settingsGradle.mustache", "settings.gradle"));
+
+ String gradleWrapperPackage = "gradle.wrapper";
+ supportingFiles.add(new SupportingFile("gradlew.mustache", "", "gradlew"));
+ supportingFiles.add(new SupportingFile("gradlew.bat.mustache", "", "gradlew.bat"));
+ supportingFiles.add(new SupportingFile("gradle-wrapper.properties.mustache",
+ gradleWrapperPackage.replace(".", File.separator), "gradle-wrapper.properties"));
+ supportingFiles.add(new SupportingFile("gradle-wrapper.jar",
+ gradleWrapperPackage.replace(".", File.separator), "gradle-wrapper.jar"));
+ }
+
+ apiTemplateFiles.put("apiInterface.mustache", "Client.kt");
+ apiTestTemplateFiles.clear();
+ }
- if (!reactive && !library.equals(SPRING_CLOUD_LIBRARY)) {
+ if (!reactive && !(library.equals(SPRING_CLOUD_LIBRARY) || library.equals(SPRING_DECLARATIVE_HTTP_INTERFACE_LIBRARY))) {
if (DocumentationProvider.SPRINGFOX.equals(getDocumentationProvider())) {
supportingFiles.add(new SupportingFile("springfoxDocumentationConfig.mustache",
(sourceFolder + File.separator + basePackage).replace(".", java.io.File.separator),
diff --git a/modules/openapi-generator/src/main/resources/kotlin-spring/libraries/spring-declarative-http-interface/README.mustache b/modules/openapi-generator/src/main/resources/kotlin-spring/libraries/spring-declarative-http-interface/README.mustache
new file mode 100644
index 000000000000..ad4a56a33945
--- /dev/null
+++ b/modules/openapi-generator/src/main/resources/kotlin-spring/libraries/spring-declarative-http-interface/README.mustache
@@ -0,0 +1,9 @@
+# OpenAPI generated API stub
+
+Spring Framework stub
+
+## Overview
+This code was generated by the [OpenAPI Generator](https://openapi-generator.tech) project.
+By using the [OpenAPI-Spec](https://openapis.org).
+This generates Spring 6+ declarative HTTP interfaces that can be used to easily instantiate an http client.
+```
\ No newline at end of file
diff --git a/modules/openapi-generator/src/main/resources/kotlin-spring/libraries/spring-declarative-http-interface/apiInterface.mustache b/modules/openapi-generator/src/main/resources/kotlin-spring/libraries/spring-declarative-http-interface/apiInterface.mustache
new file mode 100644
index 000000000000..6f724779ff6c
--- /dev/null
+++ b/modules/openapi-generator/src/main/resources/kotlin-spring/libraries/spring-declarative-http-interface/apiInterface.mustache
@@ -0,0 +1,82 @@
+/**
+* NOTE: Auto generated by OpenAPI Generator ({{{generatorVersion}}})
+* Spring 6 Declarative HTTP Interface
+*/
+package {{package}}
+
+{{#imports}}import {{import}}
+{{/imports}}
+{{#useRequestMappingOnInterface}}
+import {{#apiPackage}}{{.}}.{{/apiPackage}}{{classname}}.Companion.BASE_PATH
+{{/useRequestMappingOnInterface}}
+
+{{#swagger2AnnotationLibrary}}
+import io.swagger.v3.oas.annotations.*
+import io.swagger.v3.oas.annotations.enums.*
+import io.swagger.v3.oas.annotations.media.*
+import io.swagger.v3.oas.annotations.responses.*
+import io.swagger.v3.oas.annotations.security.*
+{{/swagger2AnnotationLibrary}}
+{{#swagger1AnnotationLibrary}}
+import io.swagger.annotations.Api
+import io.swagger.annotations.ApiOperation
+import io.swagger.annotations.ApiParam
+import io.swagger.annotations.ApiResponse
+import io.swagger.annotations.ApiResponses
+import io.swagger.annotations.Authorization
+import io.swagger.annotations.AuthorizationScope
+{{/swagger1AnnotationLibrary}}
+
+import org.springframework.web.service.annotation.*
+import org.springframework.web.bind.annotation.*
+import org.springframework.http.ResponseEntity
+
+{{#useBeanValidation}}
+import org.springframework.validation.annotation.Validated
+import {{javaxPackage}}.validation.Valid
+import {{javaxPackage}}.validation.constraints.*
+{{/useBeanValidation}}
+
+{{#reactiveModeReactor}}
+import reactor.core.publisher.Flux
+import reactor.core.publisher.Mono
+{{/reactiveModeReactor}}
+
+import kotlin.collections.List
+import kotlin.collections.Map
+
+{{#useRequestMappingOnInterface}}@HttpExchange(
+"{{=<% %>=}}\${api.base-path:$BASE_PATH}<%={{ }}=%>"
+){{/useRequestMappingOnInterface}}
+{{#useBeanValidation}}
+@Validated
+{{/useBeanValidation}}
+{{#operations}}
+interface {{classname}} {
+
+{{#operation}}
+ {{#httpMethod}}
+ @HttpExchange(
+ url = PATH_{{#lambda.uppercase}}{{#lambda.snakecase}}{{{operationId}}}{{/lambda.snakecase}}{{/lambda.uppercase}},
+ method = "{{httpMethod}}"
+ )
+ {{/httpMethod}}{{!
+ }}{{#reactiveModeCoroutines}}suspend {{/reactiveModeCoroutines}}{{!
+ }}fun {{operationId}}(
+ {{#allParams}}
+ {{>queryParams}}{{>pathParams}}{{>headerParams}}{{>cookieParams}}{{>httpInterfaceBodyParams}}{{>formParams}}{{^-last}},{{/-last}}
+ {{/allParams}}
+ ): {{>httpInterfaceReturnTypes}}
+
+{{/operation}}
+ companion object {
+ //for your own safety never directly reuse these path definitions in tests
+ {{#useRequestMappingOnInterface}}
+ const val BASE_PATH: String = "{{=<% %>=}}<%contextPath%><%={{ }}=%>"
+ {{/useRequestMappingOnInterface}}
+ {{#operation}}
+ const val PATH_{{#lambda.uppercase}}{{#lambda.snakecase}}{{{operationId}}}{{/lambda.snakecase}}{{/lambda.uppercase}}: String = "{{{path}}}"
+ {{/operation}}
+ }
+}
+{{/operations}}
\ No newline at end of file
diff --git a/modules/openapi-generator/src/main/resources/kotlin-spring/libraries/spring-declarative-http-interface/buildGradle-sb3-Kts.mustache b/modules/openapi-generator/src/main/resources/kotlin-spring/libraries/spring-declarative-http-interface/buildGradle-sb3-Kts.mustache
new file mode 100644
index 000000000000..86d733a7bee6
--- /dev/null
+++ b/modules/openapi-generator/src/main/resources/kotlin-spring/libraries/spring-declarative-http-interface/buildGradle-sb3-Kts.mustache
@@ -0,0 +1,68 @@
+import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
+
+group = "{{groupId}}"
+version = "{{artifactVersion}}"
+java.sourceCompatibility = JavaVersion.VERSION_17
+
+repositories {
+ mavenCentral()
+ maven { url = uri("https://repo.spring.io/milestone") }
+}
+
+tasks.withType {
+ kotlinOptions.jvmTarget = "17"
+}
+
+plugins {
+ val kotlinVersion = "1.9.25"
+ id("org.jetbrains.kotlin.jvm") version kotlinVersion
+ id("org.jetbrains.kotlin.plugin.jpa") version kotlinVersion
+ id("org.jetbrains.kotlin.plugin.spring") version kotlinVersion
+ id("org.springframework.boot") version "3.0.2"
+ id("io.spring.dependency-management") version "1.0.14.RELEASE"
+}
+
+tasks.getByName("bootJar") {
+ enabled = false
+}
+
+tasks.getByName("jar") {
+ enabled = true
+}
+
+dependencyManagement {
+ imports {
+ mavenBom("org.springframework.cloud:spring-cloud-dependencies:2021.0.5")
+ }
+}
+
+dependencies {
+{{#reactive}} val kotlinxCoroutinesVersion = "1.6.1"
+{{/reactive}} implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
+ implementation("org.jetbrains.kotlin:kotlin-reflect"){{^reactive}}
+ implementation("org.springframework.boot:spring-boot-starter-web"){{/reactive}}{{#reactive}}
+ implementation("org.springframework.boot:spring-boot-starter-webflux")
+ implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:$kotlinxCoroutinesVersion")
+ implementation("org.jetbrains.kotlinx:kotlinx-coroutines-reactor:$kotlinxCoroutinesVersion"){{/reactive}}{{#springDocDocumentationProvider}}{{#useSwaggerUI}}
+ implementation("org.springdoc:springdoc-openapi-starter-{{#reactive}}webflux{{/reactive}}{{^reactive}}webmvc{{/reactive}}-ui:2.6.0"){{/useSwaggerUI}}{{^useSwaggerUI}}
+ implementation("org.springdoc:springdoc-openapi-starter-{{#reactive}}webflux{{/reactive}}{{^reactive}}webmvc{{/reactive}}-api:2.6.0"){{/useSwaggerUI}}{{/springDocDocumentationProvider}}{{#springFoxDocumentationProvider}}
+ implementation("io.springfox:springfox-swagger2:2.9.2"){{/springFoxDocumentationProvider}}{{#useSwaggerUI}}{{^springDocDocumentationProvider}}
+ implementation("org.webjars:swagger-ui:4.10.3")
+ implementation("org.webjars:webjars-locator-core"){{/springDocDocumentationProvider}}{{/useSwaggerUI}}{{^springFoxDocumentationProvider}}{{^springDocDocumentationProvider}}{{#swagger1AnnotationLibrary}}
+ implementation("io.swagger:swagger-annotations:1.6.6"){{/swagger1AnnotationLibrary}}{{#swagger2AnnotationLibrary}}
+ implementation("io.swagger.core.v3:swagger-annotations:2.2.0"){{/swagger2AnnotationLibrary}}{{/springDocDocumentationProvider}}{{/springFoxDocumentationProvider}}
+
+ implementation("com.google.code.findbugs:jsr305:3.0.2")
+ implementation("com.fasterxml.jackson.dataformat:jackson-dataformat-yaml")
+ implementation("com.fasterxml.jackson.dataformat:jackson-dataformat-xml")
+ implementation("com.fasterxml.jackson.datatype:jackson-datatype-jsr310")
+ implementation("com.fasterxml.jackson.module:jackson-module-kotlin")
+
+{{#hasAuthMethods}}
+ implementation("org.springframework.cloud:spring-cloud-starter-oauth2:2.2.5.RELEASE"){{/hasAuthMethods}}
+
+{{#useBeanValidation}}
+ implementation("jakarta.validation:jakarta.validation-api"){{/useBeanValidation}}
+ implementation("jakarta.annotation:jakarta.annotation-api:2.1.0")
+
+}
diff --git a/modules/openapi-generator/src/main/resources/kotlin-spring/libraries/spring-declarative-http-interface/gradle-wrapper.jar b/modules/openapi-generator/src/main/resources/kotlin-spring/libraries/spring-declarative-http-interface/gradle-wrapper.jar
new file mode 100644
index 000000000000..e6441136f3d4
Binary files /dev/null and b/modules/openapi-generator/src/main/resources/kotlin-spring/libraries/spring-declarative-http-interface/gradle-wrapper.jar differ
diff --git a/modules/openapi-generator/src/main/resources/kotlin-spring/libraries/spring-declarative-http-interface/gradle-wrapper.properties.mustache b/modules/openapi-generator/src/main/resources/kotlin-spring/libraries/spring-declarative-http-interface/gradle-wrapper.properties.mustache
new file mode 100644
index 000000000000..80187ac30432
--- /dev/null
+++ b/modules/openapi-generator/src/main/resources/kotlin-spring/libraries/spring-declarative-http-interface/gradle-wrapper.properties.mustache
@@ -0,0 +1,7 @@
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip
+networkTimeout=10000
+validateDistributionUrl=true
+zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists
diff --git a/modules/openapi-generator/src/main/resources/kotlin-spring/libraries/spring-declarative-http-interface/gradlew.bat.mustache b/modules/openapi-generator/src/main/resources/kotlin-spring/libraries/spring-declarative-http-interface/gradlew.bat.mustache
new file mode 100644
index 000000000000..25da30dbdeee
--- /dev/null
+++ b/modules/openapi-generator/src/main/resources/kotlin-spring/libraries/spring-declarative-http-interface/gradlew.bat.mustache
@@ -0,0 +1,92 @@
+@rem
+@rem Copyright 2015 the original author or authors.
+@rem
+@rem Licensed under the Apache License, Version 2.0 (the "License");
+@rem you may not use this file except in compliance with the License.
+@rem You may obtain a copy of the License at
+@rem
+@rem https://www.apache.org/licenses/LICENSE-2.0
+@rem
+@rem Unless required by applicable law or agreed to in writing, software
+@rem distributed under the License is distributed on an "AS IS" BASIS,
+@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+@rem See the License for the specific language governing permissions and
+@rem limitations under the License.
+@rem
+
+@if "%DEBUG%"=="" @echo off
+@rem ##########################################################################
+@rem
+@rem Gradle startup script for Windows
+@rem
+@rem ##########################################################################
+
+@rem Set local scope for the variables with windows NT shell
+if "%OS%"=="Windows_NT" setlocal
+
+set DIRNAME=%~dp0
+if "%DIRNAME%"=="" set DIRNAME=.
+@rem This is normally unused
+set APP_BASE_NAME=%~n0
+set APP_HOME=%DIRNAME%
+
+@rem Resolve any "." and ".." in APP_HOME to make it shorter.
+for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
+
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
+
+@rem Find java.exe
+if defined JAVA_HOME goto findJavaFromJavaHome
+
+set JAVA_EXE=java.exe
+%JAVA_EXE% -version >NUL 2>&1
+if %ERRORLEVEL% equ 0 goto execute
+
+echo. 1>&2
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
+echo. 1>&2
+echo Please set the JAVA_HOME variable in your environment to match the 1>&2
+echo location of your Java installation. 1>&2
+
+goto fail
+
+:findJavaFromJavaHome
+set JAVA_HOME=%JAVA_HOME:"=%
+set JAVA_EXE=%JAVA_HOME%/bin/java.exe
+
+if exist "%JAVA_EXE%" goto execute
+
+echo. 1>&2
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
+echo. 1>&2
+echo Please set the JAVA_HOME variable in your environment to match the 1>&2
+echo location of your Java installation. 1>&2
+
+goto fail
+
+:execute
+@rem Setup the command line
+
+set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
+
+
+@rem Execute Gradle
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
+
+:end
+@rem End local scope for the variables with windows NT shell
+if %ERRORLEVEL% equ 0 goto mainEnd
+
+:fail
+rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
+rem the _cmd.exe /c_ return code!
+set EXIT_CODE=%ERRORLEVEL%
+if %EXIT_CODE% equ 0 set EXIT_CODE=1
+if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
+exit /b %EXIT_CODE%
+
+:mainEnd
+if "%OS%"=="Windows_NT" endlocal
+
+:omega
diff --git a/modules/openapi-generator/src/main/resources/kotlin-spring/libraries/spring-declarative-http-interface/gradlew.mustache b/modules/openapi-generator/src/main/resources/kotlin-spring/libraries/spring-declarative-http-interface/gradlew.mustache
new file mode 100644
index 000000000000..9d0ce634cb11
--- /dev/null
+++ b/modules/openapi-generator/src/main/resources/kotlin-spring/libraries/spring-declarative-http-interface/gradlew.mustache
@@ -0,0 +1,249 @@
+#!/bin/sh
+
+#
+# Copyright © 2015-2021 the original authors.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# https://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+##############################################################################
+#
+# Gradle start up script for POSIX generated by Gradle.
+#
+# Important for running:
+#
+# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
+# noncompliant, but you have some other compliant shell such as ksh or
+# bash, then to run this script, type that shell name before the whole
+# command line, like:
+#
+# ksh Gradle
+#
+# Busybox and similar reduced shells will NOT work, because this script
+# requires all of these POSIX shell features:
+# * functions;
+# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
+# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
+# * compound commands having a testable exit status, especially «case»;
+# * various built-in commands including «command», «set», and «ulimit».
+#
+# Important for patching:
+#
+# (2) This script targets any POSIX shell, so it avoids extensions provided
+# by Bash, Ksh, etc; in particular arrays are avoided.
+#
+# The "traditional" practice of packing multiple parameters into a
+# space-separated string is a well documented source of bugs and security
+# problems, so this is (mostly) avoided, by progressively accumulating
+# options in "$@", and eventually passing that to Java.
+#
+# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
+# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
+# see the in-line comments for details.
+#
+# There are tweaks for specific operating systems such as AIX, CygWin,
+# Darwin, MinGW, and NonStop.
+#
+# (3) This script is generated from the Groovy template
+# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
+# within the Gradle project.
+#
+# You can find Gradle at https://github.com/gradle/gradle/.
+#
+##############################################################################
+
+# Attempt to set APP_HOME
+
+# Resolve links: $0 may be a link
+app_path=$0
+
+# Need this for daisy-chained symlinks.
+while
+APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
+[ -h "$app_path" ]
+do
+ls=$( ls -ld "$app_path" )
+link=${ls#*' -> '}
+case $link in #(
+/*) app_path=$link ;; #(
+*) app_path=$APP_HOME$link ;;
+esac
+done
+
+# This is normally unused
+# shellcheck disable=SC2034
+APP_BASE_NAME=${0##*/}
+# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
+APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
+
+# Use the maximum available, or set MAX_FD != -1 to use that value.
+MAX_FD=maximum
+
+warn () {
+echo "$*"
+} >&2
+
+die () {
+echo
+echo "$*"
+echo
+exit 1
+} >&2
+
+# OS specific support (must be 'true' or 'false').
+cygwin=false
+msys=false
+darwin=false
+nonstop=false
+case "$( uname )" in #(
+CYGWIN* ) cygwin=true ;; #(
+Darwin* ) darwin=true ;; #(
+MSYS* | MINGW* ) msys=true ;; #(
+NONSTOP* ) nonstop=true ;;
+esac
+
+CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
+
+
+# Determine the Java command to use to start the JVM.
+if [ -n "$JAVA_HOME" ] ; then
+if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+# IBM's JDK on AIX uses strange locations for the executables
+JAVACMD=$JAVA_HOME/jre/sh/java
+else
+JAVACMD=$JAVA_HOME/bin/java
+fi
+if [ ! -x "$JAVACMD" ] ; then
+die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+fi
+else
+JAVACMD=java
+if ! command -v java >/dev/null 2>&1
+then
+die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+fi
+fi
+
+# Increase the maximum file descriptors if we can.
+if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
+case $MAX_FD in #(
+max*)
+# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
+# shellcheck disable=SC2039,SC3045
+MAX_FD=$( ulimit -H -n ) ||
+warn "Could not query maximum file descriptor limit"
+esac
+case $MAX_FD in #(
+'' | soft) :;; #(
+*)
+# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
+# shellcheck disable=SC2039,SC3045
+ulimit -n "$MAX_FD" ||
+warn "Could not set maximum file descriptor limit to $MAX_FD"
+esac
+fi
+
+# Collect all arguments for the java command, stacking in reverse order:
+# * args from the command line
+# * the main class name
+# * -classpath
+# * -D...appname settings
+# * --module-path (only if needed)
+# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
+
+# For Cygwin or MSYS, switch paths to Windows format before running java
+if "$cygwin" || "$msys" ; then
+APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
+CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
+
+JAVACMD=$( cygpath --unix "$JAVACMD" )
+
+# Now convert the arguments - kludge to limit ourselves to /bin/sh
+for arg do
+if
+case $arg in #(
+-*) false ;; # don't mess with options #(
+/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
+[ -e "$t" ] ;; #(
+*) false ;;
+esac
+then
+arg=$( cygpath --path --ignore --mixed "$arg" )
+fi
+# Roll the args list around exactly as many times as the number of
+# args, so each arg winds up back in the position where it started, but
+# possibly modified.
+#
+# NB: a `for` loop captures its iteration list before it begins, so
+# changing the positional parameters here affects neither the number of
+# iterations, nor the values presented in `arg`.
+shift # remove old arg
+set -- "$@" "$arg" # push replacement arg
+done
+fi
+
+
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
+
+# Collect all arguments for the java command:
+# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
+# and any embedded shellness will be escaped.
+# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
+# treated as '${Hostname}' itself on the command line.
+
+set -- \
+"-Dorg.gradle.appname=$APP_BASE_NAME" \
+-classpath "$CLASSPATH" \
+org.gradle.wrapper.GradleWrapperMain \
+"$@"
+
+# Stop when "xargs" is not available.
+if ! command -v xargs >/dev/null 2>&1
+then
+die "xargs is not available"
+fi
+
+# Use "xargs" to parse quoted args.
+#
+# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
+#
+# In Bash we could simply go:
+#
+# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
+# set -- "${ARGS[@]}" "$@"
+#
+# but POSIX shell has neither arrays nor command substitution, so instead we
+# post-process each arg (as a line of input to sed) to backslash-escape any
+# character that might be a shell metacharacter, then use eval to reverse
+# that process (while maintaining the separation between arguments), and wrap
+# the whole thing up as a single "set" statement.
+#
+# This will of course break if any of these variables contains a newline or
+# an unmatched quote.
+#
+
+eval "set -- $(
+printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
+xargs -n1 |
+sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
+tr '\n' ' '
+)" '"$@"'
+
+exec "$JAVACMD" "$@"
diff --git a/modules/openapi-generator/src/main/resources/kotlin-spring/libraries/spring-declarative-http-interface/httpInterfaceBodyParams.mustache b/modules/openapi-generator/src/main/resources/kotlin-spring/libraries/spring-declarative-http-interface/httpInterfaceBodyParams.mustache
new file mode 100644
index 000000000000..c6383a787c4a
--- /dev/null
+++ b/modules/openapi-generator/src/main/resources/kotlin-spring/libraries/spring-declarative-http-interface/httpInterfaceBodyParams.mustache
@@ -0,0 +1 @@
+{{#isBodyParam}}{{#swagger2AnnotationLibrary}}@Parameter(description = "{{{description}}}"{{#required}}, required = true{{/required}}{{^isContainer}}{{#allowableValues}}{{#defaultValue}}, schema = Schema(allowableValues = ["{{{allowableValues}}}"], defaultValue = {{^isString}}"{{/isString}}{{#isString}}{{#isEnum}}"{{/isEnum}}{{/isString}}{{{defaultValue}}}{{^isString}}"{{/isString}}{{#isString}}{{#isEnum}}"{{/isEnum}}{{/isString}}){{/defaultValue}}{{/allowableValues}}{{^allowableValues}}{{#defaultValue}}, schema = Schema(defaultValue = {{^isString}}"{{/isString}}{{#isString}}{{#isEnum}}"{{/isEnum}}{{/isString}}{{{defaultValue}}}{{^isString}}"{{/isString}}{{#isString}}{{#isEnum}}"{{/isEnum}}{{/isString}}){{/defaultValue}}{{/allowableValues}}{{#allowableValues}}{{^defaultValue}}, schema = Schema(allowableValues = ["{{{allowableValues}}}"]){{/defaultValue}}{{/allowableValues}}{{/isContainer}}){{/swagger2AnnotationLibrary}}{{#swagger1AnnotationLibrary}}@ApiParam(value = "{{{description}}}"{{#required}}, required = true{{/required}}{{^isContainer}}{{#allowableValues}}, allowableValues = "{{{.}}}"{{/allowableValues}}{{/isContainer}}{{#defaultValue}}, defaultValue = "{{{.}}}"{{/defaultValue}}){{/swagger1AnnotationLibrary}}{{#useBeanValidation}} @Valid{{>beanValidationBodyParams}}{{/useBeanValidation}} @RequestBody{{^required}}(required = false){{/required}} {{{paramName}}}: {{>optionalDataType}}{{/isBodyParam}}
\ No newline at end of file
diff --git a/modules/openapi-generator/src/main/resources/kotlin-spring/libraries/spring-declarative-http-interface/httpInterfaceReturnTypes.mustache b/modules/openapi-generator/src/main/resources/kotlin-spring/libraries/spring-declarative-http-interface/httpInterfaceReturnTypes.mustache
new file mode 100644
index 000000000000..86f9cea77382
--- /dev/null
+++ b/modules/openapi-generator/src/main/resources/kotlin-spring/libraries/spring-declarative-http-interface/httpInterfaceReturnTypes.mustache
@@ -0,0 +1,47 @@
+{{! handle reactive map and array}}
+{{#reactive}}
+{{#isMap}}
+{{#reactiveModeReactor}}Mono<{{/reactiveModeReactor}}{{#declarativeInterfaceWrapResponses}}ResponseEntity<{{/declarativeInterfaceWrapResponses}}Map{{#declarativeInterfaceWrapResponses}}>{{/declarativeInterfaceWrapResponses}}{{#reactiveModeReactor}}>{{/reactiveModeReactor}}
+{{/isMap}}
+{{#isArray}}
+{{! array handle reactive - reactor with/without ResponseEntity wrapper}}
+{{#reactiveModeReactor}}
+{{#declarativeInterfaceWrapResponses}}Mono{{#declarativeInterfaceWrapResponses}}>>{{/declarativeInterfaceWrapResponses}}
+{{/reactiveModeReactor}}
+{{! array handle reactive - coroutines with/without ResponseEntity wrapper}}
+{{#reactiveModeCoroutines}}
+{{#declarativeInterfaceWrapResponses}}ResponseEntity<{{/declarativeInterfaceWrapResponses}}{{{returnContainer}}}<{{{returnType}}}>{{#declarativeInterfaceWrapResponses}}>{{/declarativeInterfaceWrapResponses}}
+{{/reactiveModeCoroutines}}
+{{/isArray}}
+{{! handle reactive non-container - with/without ResponseEntity wrapper}}
+{{^returnContainer}}
+{{#reactiveModeReactor}}
+Mono<{{#declarativeInterfaceWrapResponses}}ResponseEntity<{{/declarativeInterfaceWrapResponses}}{{{returnType}}}{{#declarativeInterfaceWrapResponses}}>{{/declarativeInterfaceWrapResponses}}>
+{{/reactiveModeReactor}}
+{{#reactiveModeCoroutines}}
+{{#declarativeInterfaceWrapResponses}}
+ResponseEntity<{{/declarativeInterfaceWrapResponses}}{{{returnType}}}{{#declarativeInterfaceWrapResponses}}>
+{{/declarativeInterfaceWrapResponses}}
+{{/reactiveModeCoroutines}}
+{{/returnContainer}}
+{{/reactive}}
+{{^reactive}}
+{{! handle non-reactive map and array}}
+{{#isMap}}
+{{#declarativeInterfaceWrapResponses}}
+ResponseEntity<{{/declarativeInterfaceWrapResponses}}Map{{#declarativeInterfaceWrapResponses}}>
+{{/declarativeInterfaceWrapResponses}}
+{{/isMap}}
+{{#isArray}}
+{{! array handle non-reactive - with/without ResponseEntity wrapper}}
+{{#declarativeInterfaceWrapResponses}}
+ResponseEntity<{{/declarativeInterfaceWrapResponses}}{{{returnContainer}}}<{{{returnType}}}>{{#declarativeInterfaceWrapResponses}}>
+{{/declarativeInterfaceWrapResponses}}
+{{/isArray}}
+{{! handle reactive non-container - with/without ResponseEntity wrapper}}
+{{^returnContainer}}
+{{#declarativeInterfaceWrapResponses}}
+ResponseEntity<{{/declarativeInterfaceWrapResponses}}{{{returnType}}}{{#declarativeInterfaceWrapResponses}}>
+{{/declarativeInterfaceWrapResponses}}
+{{/returnContainer}}
+{{/reactive}}
\ No newline at end of file
diff --git a/modules/openapi-generator/src/main/resources/kotlin-spring/libraries/spring-declarative-http-interface/pom-sb3.mustache b/modules/openapi-generator/src/main/resources/kotlin-spring/libraries/spring-declarative-http-interface/pom-sb3.mustache
new file mode 100644
index 000000000000..1d07922fc26a
--- /dev/null
+++ b/modules/openapi-generator/src/main/resources/kotlin-spring/libraries/spring-declarative-http-interface/pom-sb3.mustache
@@ -0,0 +1,241 @@
+
+ 4.0.0
+ {{groupId}}
+ {{artifactId}}
+ jar
+ {{artifactId}}
+ {{artifactVersion}}
+ {{#reactive}}
+ 1.6.1
+ {{/reactive}}{{#springDocDocumentationProvider}}{{#useSwaggerUI}}
+ 2.2.0
+ {{/useSwaggerUI}}{{/springDocDocumentationProvider}}{{#springFoxDocumentationProvider}}
+ 2.9.2
+ {{/springFoxDocumentationProvider}}{{#useSwaggerUI}}{{^springDocDocumentationProvider}}
+ 5.3.1
+ {{/springDocDocumentationProvider}}{{/useSwaggerUI}}{{^springFoxDocumentationProvider}}{{^springDocDocumentationProvider}}{{#swagger1AnnotationLibrary}}
+ 1.6.6
+ {{/swagger1AnnotationLibrary}}{{#swagger2AnnotationLibrary}}
+ 2.2.15
+ {{/swagger2AnnotationLibrary}}{{/springDocDocumentationProvider}}{{/springFoxDocumentationProvider}}
+ 3.0.2
+ 2.1.0
+ 1.7.10
+
+ 1.7.10
+ UTF-8
+
+
+ org.springframework.boot
+ spring-boot-starter-parent
+ 3.1.3
+
+
+
+
+ org.springframework.cloud
+ spring-cloud-starter-parent
+ 2021.0.5
+ pom
+ import
+
+
+
+
+
+ repository.spring.milestone
+ Spring Milestone Repository
+ https://repo.spring.io/milestone
+
+
+
+
+ spring-milestones
+ https://repo.spring.io/milestone
+
+
+
+ ${project.basedir}/src/main/kotlin
+ {{^interfaceOnly}}
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+
+
+
+ repackage
+
+
+
+ {{/interfaceOnly}}
+ {{#interfaceOnly}}
+ org.apache.maven.plugins
+ maven-source-plugin
+
+
+ attach-sources
+
+ jar
+
+
+
+ {{/interfaceOnly}}
+
+ kotlin-maven-plugin
+ org.jetbrains.kotlin
+ ${kotlin.version}
+
+
+ spring
+
+ 17
+
+
+
+ compile
+ compile
+
+ compile
+
+
+
+ test-compile
+ test-compile
+
+ test-compile
+
+
+
+
+
+ org.jetbrains.kotlin
+ kotlin-maven-allopen
+ ${kotlin.version}
+
+
+
+
+
+
+
+ org.jetbrains.kotlin
+ kotlin-stdlib-jdk8
+ ${kotlin.version}
+
+
+ org.jetbrains.kotlin
+ kotlin-reflect
+ ${kotlin.version}
+ {{^reactive}}
+
+ org.springframework.boot
+ spring-boot-starter-web
+ {{/reactive}}{{#reactive}}
+
+ org.springframework.boot
+ spring-boot-starter-webflux
+
+
+ org.jetbrains.kotlinx
+ kotlinx-coroutines-core
+ ${kotlinx-coroutines.version}
+
+
+ org.jetbrains.kotlinx
+ kotlinx-coroutines-reactor
+ ${kotlinx-coroutines.version}
+ {{/reactive}}
+
+ {{#springDocDocumentationProvider}}
+ {{#useSwaggerUI}}
+
+ org.springdoc
+ springdoc-openapi-starter-{{#reactive}}
+ webflux{{/reactive}}{{^reactive}}webmvc{{/reactive}}-ui
+
+ ${springdoc-openapi.version}
+ {{/useSwaggerUI}}{{^useSwaggerUI}}
+
+ org.springdoc
+ springdoc-openapi-{{#reactive}}webflux{{/reactive}}{{^reactive}}webmvc{{/reactive}}-core
+
+ ${springdoc-openapi.version}
+ {{/useSwaggerUI}}{{/springDocDocumentationProvider}}{{#springFoxDocumentationProvider}}
+
+
+ io.springfox
+ springfox-swagger2
+ ${springfox-swagger2.version}
+ {{/springFoxDocumentationProvider}}{{#useSwaggerUI}}{{^springDocDocumentationProvider}}
+
+ org.webjars
+ swagger-ui
+ ${swagger-ui.version}
+
+
+ org.webjars
+ webjars-locator-core
+ {{/springDocDocumentationProvider}}{{/useSwaggerUI}}{{^springFoxDocumentationProvider}}{{^springDocDocumentationProvider}}{{#swagger1AnnotationLibrary}}
+
+ io.swagger
+ swagger-annotations
+ ${swagger-annotations.version}
+ {{/swagger1AnnotationLibrary}}{{#swagger2AnnotationLibrary}}
+
+ io.swagger.core.v3
+ swagger-annotations
+ ${swagger-annotations.version}
+ {{/swagger2AnnotationLibrary}}{{/springDocDocumentationProvider}}{{/springFoxDocumentationProvider}}
+
+
+
+ com.google.code.findbugs
+ jsr305
+ ${findbugs-jsr305.version}
+
+ {{#hasAuthMethods}}
+
+ org.springframework.cloud
+ spring-cloud-starter-oauth2
+ {{^parentOverridden}}
+ 2.2.5.RELEASE
+ {{/parentOverridden}}
+
+ {{/hasAuthMethods}}
+
+ com.fasterxml.jackson.dataformat
+ jackson-dataformat-yaml
+
+
+ com.fasterxml.jackson.dataformat
+ jackson-dataformat-xml
+
+
+ com.fasterxml.jackson.datatype
+ jackson-datatype-jsr310
+
+
+ com.fasterxml.jackson.module
+ jackson-module-kotlin
+
+{{#useBeanValidation}}
+
+
+ jakarta.validation
+ jakarta.validation-api
+ {{/useBeanValidation}}
+
+ jakarta.annotation
+ jakarta.annotation-api
+ ${jakarta-annotation.version}
+ provided
+
+
+ org.jetbrains.kotlin
+ kotlin-test-junit5
+ ${kotlin-test-junit5.version}
+ test
+
+
+
diff --git a/modules/openapi-generator/src/main/resources/kotlin-spring/libraries/spring-declarative-http-interface/settingsGradle.mustache b/modules/openapi-generator/src/main/resources/kotlin-spring/libraries/spring-declarative-http-interface/settingsGradle.mustache
new file mode 100644
index 000000000000..fd23a36b9038
--- /dev/null
+++ b/modules/openapi-generator/src/main/resources/kotlin-spring/libraries/spring-declarative-http-interface/settingsGradle.mustache
@@ -0,0 +1,15 @@
+pluginManagement {
+ repositories {
+ maven { url = uri("https://repo.spring.io/snapshot") }
+ maven { url = uri("https://repo.spring.io/milestone") }
+ gradlePluginPortal()
+ }
+ resolutionStrategy {
+ eachPlugin {
+ if (requested.id.id == "org.springframework.boot") {
+ useModule("org.springframework.boot:spring-boot-gradle-plugin:${requested.version}")
+ }
+ }
+ }
+}
+rootProject.name = "{{artifactId}}"
diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/kotlin/spring/KotlinSpringServerCodegenTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/kotlin/spring/KotlinSpringServerCodegenTest.java
index 4835aa65e8ec..348f3c78d49c 100644
--- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/kotlin/spring/KotlinSpringServerCodegenTest.java
+++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/kotlin/spring/KotlinSpringServerCodegenTest.java
@@ -42,6 +42,8 @@
import static org.assertj.core.api.Assertions.assertThat;
import static org.openapitools.codegen.TestUtils.assertFileContains;
import static org.openapitools.codegen.TestUtils.assertFileNotContains;
+import static org.openapitools.codegen.languages.KotlinSpringServerCodegen.*;
+import static org.openapitools.codegen.languages.SpringCodegen.REACTIVE;
import static org.openapitools.codegen.languages.SpringCodegen.SPRING_BOOT;
import static org.openapitools.codegen.languages.features.DocumentationProviderFeatures.ANNOTATION_LIBRARY;
import static org.openapitools.codegen.languages.features.DocumentationProviderFeatures.DOCUMENTATION_PROVIDER;
@@ -1027,6 +1029,296 @@ public void generateSerializableModelWithXimplements() throws Exception {
);
}
+ @Test
+ public void generateHttpInterfaceReactiveWithReactorResponseEntity() throws Exception {
+ File output = Files.createTempDirectory("test").toFile().getCanonicalFile();
+ output.deleteOnExit();
+ String outputPath = output.getAbsolutePath().replace('\\', '/');
+
+ KotlinSpringServerCodegen codegen = new KotlinSpringServerCodegen();
+ codegen.setOutputDir(output.getAbsolutePath());
+ codegen.additionalProperties().put(CodegenConstants.LIBRARY, "spring-declarative-http-interface");
+ codegen.additionalProperties().put(REACTIVE, true);
+ codegen.additionalProperties().put(DECLARATIVE_INTERFACE_REACTIVE_MODE, "reactor");
+ codegen.additionalProperties().put(DECLARATIVE_INTERFACE_WRAP_RESPONSES, true);
+ codegen.additionalProperties().put(REQUEST_MAPPING_OPTION, "none");
+ codegen.additionalProperties().put(USE_FLOW_FOR_ARRAY_RETURN_TYPE, false);
+
+ ClientOptInput input = new ClientOptInput()
+ .openAPI(TestUtils.parseSpec("src/test/resources/3_0/kotlin/petstore.yaml"))
+ .config(codegen);
+ DefaultGenerator generator = new DefaultGenerator();
+
+ generator.setGeneratorPropertyDefault(CodegenConstants.MODELS, "true");
+ generator.setGeneratorPropertyDefault(CodegenConstants.MODEL_TESTS, "false");
+ generator.setGeneratorPropertyDefault(CodegenConstants.MODEL_DOCS, "false");
+ generator.setGeneratorPropertyDefault(CodegenConstants.APIS, "true");
+ generator.setGeneratorPropertyDefault(CodegenConstants.SUPPORTING_FILES, "false");
+
+ generator.opts(input).generate();
+
+ Path path = Paths.get(outputPath + "/src/main/kotlin/org/openapitools/api/StoreApiClient.kt");
+ assertFileContains(
+ path,
+ "import reactor.core.publisher.Flux\n"
+ + "import reactor.core.publisher.Mono",
+ " @HttpExchange(\n"
+ + " url = PATH_GET_INVENTORY,\n"
+ + " method = \"GET\"\n"
+ + " )\n"
+ + " fun getInventory(\n"
+ + " ): Mono>>",
+ " @HttpExchange(\n"
+ + " url = PATH_DELETE_ORDER,\n"
+ + " method = \"DELETE\"\n"
+ + " )\n"
+ + " fun deleteOrder(\n"
+ + " @Parameter(description = \"ID of the order that needs to be deleted\", required = true) @PathVariable(\"orderId\") orderId: kotlin.String\n"
+ + " ): Mono>",
+ " @HttpExchange(\n"
+ + " url = PATH_PLACE_ORDER,\n"
+ + " method = \"POST\"\n"
+ + " )\n"
+ + " fun placeOrder(\n"
+ + " @Parameter(description = \"order placed for purchasing the pet\", required = true) @Valid @RequestBody order: Order\n"
+ + " ): Mono>",
+ " companion object {\n"
+ + " //for your own safety never directly reuse these path definitions in tests\n"
+ + " const val PATH_DELETE_ORDER: String = \"/store/order/{orderId}\"\n"
+ + " const val PATH_GET_INVENTORY: String = \"/store/inventory\"\n"
+ + " const val PATH_GET_ORDER_BY_ID: String = \"/store/order/{orderId}\"\n"
+ + " const val PATH_PLACE_ORDER: String = \"/store/order\"\n"
+ + " }"
+ );
+ assertFileNotContains(
+ path,
+ "suspend"
+ );
+ }
+
+ @Test
+ public void generateHttpInterfaceReactiveWithCoroutinesResponseEntity() throws Exception {
+ File output = Files.createTempDirectory("test").toFile().getCanonicalFile();
+ output.deleteOnExit();
+ String outputPath = output.getAbsolutePath().replace('\\', '/');
+
+ KotlinSpringServerCodegen codegen = new KotlinSpringServerCodegen();
+ codegen.setOutputDir(output.getAbsolutePath());
+ codegen.additionalProperties().put(CodegenConstants.LIBRARY, "spring-declarative-http-interface");
+ codegen.additionalProperties().put(REACTIVE, true);
+ codegen.additionalProperties().put(DECLARATIVE_INTERFACE_REACTIVE_MODE, "coroutines");
+ codegen.additionalProperties().put(DECLARATIVE_INTERFACE_WRAP_RESPONSES, true);
+ codegen.additionalProperties().put(REQUEST_MAPPING_OPTION, "none");
+ codegen.additionalProperties().put(USE_FLOW_FOR_ARRAY_RETURN_TYPE, false);
+
+ ClientOptInput input = new ClientOptInput()
+ .openAPI(TestUtils.parseSpec("src/test/resources/3_0/kotlin/petstore.yaml"))
+ .config(codegen);
+ DefaultGenerator generator = new DefaultGenerator();
+
+ generator.setGeneratorPropertyDefault(CodegenConstants.MODELS, "true");
+ generator.setGeneratorPropertyDefault(CodegenConstants.MODEL_TESTS, "false");
+ generator.setGeneratorPropertyDefault(CodegenConstants.MODEL_DOCS, "false");
+ generator.setGeneratorPropertyDefault(CodegenConstants.APIS, "true");
+ generator.setGeneratorPropertyDefault(CodegenConstants.SUPPORTING_FILES, "false");
+
+ generator.opts(input).generate();
+
+ Path path = Paths.get(outputPath + "/src/main/kotlin/org/openapitools/api/StoreApiClient.kt");
+ assertFileContains(
+ path,
+ " suspend fun getInventory(\n"
+ + " ): ResponseEntity