Skip to content

Commit 4c32ad8

Browse files
committed
[java][spring] Spring HTTP Interface library: Validate Spring Boot version (3 or 4) and fail early if unsupported
1 parent 9c5d4d2 commit 4c32ad8

4 files changed

Lines changed: 7 additions & 2 deletions

File tree

modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/SpringCodegen.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ public SpringCodegen() {
327327
supportedLibraries.put(SPRING_BOOT, "Spring-boot Server application.");
328328
supportedLibraries.put(SPRING_CLOUD_LIBRARY,
329329
"Spring-Cloud-Feign client with Spring-Boot auto-configured settings.");
330-
supportedLibraries.put(SPRING_HTTP_INTERFACE, "Spring 6 HTTP interfaces (testing)");
330+
supportedLibraries.put(SPRING_HTTP_INTERFACE, "Spring 6 HTTP interfaces (testing). Requires Spring Boot 3 or 4.");
331331
setLibrary(SPRING_BOOT);
332332
final CliOption library = new CliOption(CodegenConstants.LIBRARY, CodegenConstants.LIBRARY_DESC)
333333
.defaultValue(SPRING_BOOT);
@@ -644,6 +644,10 @@ public void processOpts() {
644644
}
645645
}
646646
} else if (SPRING_HTTP_INTERFACE.equals(library)) {
647+
if (!(isUseSpringBoot3() || isUseSpringBoot4())) {
648+
throw new IllegalArgumentException("Library '" + SPRING_HTTP_INTERFACE + "' is only supported with Spring Boot 3 or 4");
649+
}
650+
647651
String httpInterfacesAbstractConfiguratorFile = useHttpServiceProxyFactoryInterfacesConfigurator ?
648652
"httpServiceProxyFactoryInterfacesConfigurator.mustache" :
649653
"httpInterfacesConfiguration.mustache";

modules/openapi-generator/src/main/resources/JavaSpring/libraries/spring-http-interface/README.mustache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# OpenAPI generated API stub
22

3-
[Spring Framework 6.1 HTTP Interface](https://docs.spring.io/spring-framework/docs/6.1.0/reference/html/integration.html#rest-http-interface)
3+
[Spring Framework 6.1 HTTP Interface](https://docs.spring.io/spring-framework/reference/integration/rest-clients.html#rest-http-interface)
44

55

66
## Overview

modules/openapi-generator/src/main/resources/JavaSpring/libraries/spring-http-interface/pom.mustache renamed to modules/openapi-generator/src/main/resources/JavaSpring/libraries/spring-http-interface/pom-sb3.mustache

File renamed without changes.

modules/openapi-generator/src/test/java/org/openapitools/codegen/java/spring/SpringCodegenTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6621,6 +6621,7 @@ public void shouldNotHaveDocumentationAnnotationWhenUsingLibrarySpringHttpInterf
66216621
codegen.setOpenAPI(openAPI);
66226622
codegen.setOutputDir(output.getAbsolutePath());
66236623
codegen.setLibrary(SPRING_HTTP_INTERFACE);
6624+
codegen.setUseSpringBoot3(true);
66246625
codegen.setAnnotationLibrary(AnnotationLibrary.SWAGGER2);
66256626
codegen.setDocumentationProvider(DocumentationProvider.SPRINGDOC);
66266627

0 commit comments

Comments
 (0)