Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
814ee9b
spring-http-interface: introduce `springHttpClientAdapter`, fix `para…
ibaranga Sep 29, 2024
f1bbe1b
fix imports
ibaranga Sep 29, 2024
4e03298
Update SpringCodegen.java
ibaranga Sep 29, 2024
0f9bfb1
fix docs and default value
ibaranga Oct 1, 2024
33649f3
Merge remote-tracking branch 'origin/master'
ibaranga Oct 1, 2024
c85e8cd
Merge remote-tracking branch 'myfork/master'
ibaranga Oct 1, 2024
4c3bdae
fix docs and default value
ibaranga Oct 1, 2024
277c928
Merge remote-tracking branch 'origin/master'
ibaranga Oct 9, 2024
6addc9a
revert to HttpServiceProxyFactory.builder for backward compatibility
ibaranga Oct 16, 2024
21e024a
Merge remote-tracking branch 'origin/master'
ibaranga Oct 16, 2024
1ab55cd
Merge remote-tracking branch 'origin/master'
ibaranga Oct 17, 2024
0cd4f75
Merge remote-tracking branch 'origin/master'
ibaranga Nov 30, 2024
6a55e5d
spring-http-interface: introduce `useHttpServiceProxyFactoryInterface…
ibaranga Nov 30, 2024
d84e5f3
Merge remote-tracking branch 'origin/master'
ibaranga Nov 30, 2024
02bb3c7
spring-http-interface: introduce `useHttpServiceProxyFactoryInterface…
ibaranga Nov 30, 2024
c79efb9
spring-http-interface: introduce `useHttpServiceProxyFactoryInterface…
ibaranga Nov 30, 2024
79fbb71
spring-http-interface: fix generated files
ibaranga Nov 30, 2024
176322a
Merge remote-tracking branch 'origin/master'
ibaranga Mar 4, 2025
71e28b3
remove unnecessary imports from httpServiceProxyFactoryInterfacesConf…
ibaranga Mar 4, 2025
3de14ae
Merge branch 'OpenAPITools:master' into master
ibaranga Mar 4, 2025
6408374
remove unnecessary paramDoc.mustache, update `useHttpServiceProxyFact…
ibaranga Mar 6, 2025
ba281f4
Merge remote-tracking branch 'origin/master'
ibaranga Mar 6, 2025
9c5d4d2
Merge remote-tracking branch 'OpenAPITools/master' into 19712-spring-…
Bragolgirith Mar 14, 2026
4c32ad8
[java][spring] Spring HTTP Interface library: Validate Spring Boot ve…
Bragolgirith Mar 14, 2026
e92cd38
Merge pull request #1 from Bragolgirith/19712-spring-http-interface-u…
ibaranga Mar 14, 2026
2be6901
Set `useSpringBoot3: "true"` for all sample configs using `library: s…
ibaranga Mar 14, 2026
4c2f091
Regenerate samples using `library: spring-http-interface`
ibaranga Mar 14, 2026
032ad83
Update "spring-http-interface" docs "Spring 6 HTTP interfaces (testin…
ibaranga Mar 14, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/samples-jdk17.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ on:
- samples/client/petstore/spring-http-interface/**
- samples/client/petstore/spring-http-interface-reactive-noResponseEntity/**
- samples/client/petstore/spring-http-interface-noResponseEntity/**
- samples/client/petstore/spring-http-interface-useHttpServiceProxyFactoryInterfacesConfigurator/**
- samples/client/petstore/java/webclient-jakarta/**
- samples/client/petstore/java/microprofile-rest-client-outer-enum/**
# servers
Expand All @@ -29,6 +30,7 @@ on:
- samples/client/petstore/spring-http-interface/**
- samples/client/petstore/spring-http-interface-reactive-noResponseEntity/**
- samples/client/petstore/spring-http-interface-noResponseEntity/**
- samples/client/petstore/spring-http-interface-useHttpServiceProxyFactoryInterfacesConfigurator/**
- samples/client/petstore/java/webclient-jakarta/**
- samples/client/petstore/java/microprofile-rest-client-outer-enum/**
# servers
Expand All @@ -54,6 +56,7 @@ jobs:
- samples/client/petstore/spring-http-interface
- samples/client/petstore/spring-http-interface-reactive-noResponseEntity
- samples/client/petstore/spring-http-interface-noResponseEntity
- samples/client/petstore/spring-http-interface-useHttpServiceProxyFactoryInterfacesConfigurator
- samples/client/petstore/java/webclient-jakarta
- samples/client/petstore/java/microprofile-rest-client-outer-enum
# servers
Expand Down
1 change: 1 addition & 0 deletions bin/configs/spring-http-interface-noResponseEntity.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ additionalProperties:
useBeanValidation: "true"
performBeanValidation: "true"
useResponseEntity: "false"
useSpringBoot3: "true"
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ additionalProperties:
useBeanValidation: "true"
performBeanValidation: "true"
useResponseEntity: "false"
useSpringBoot3: "true"

1 change: 1 addition & 0 deletions bin/configs/spring-http-interface-reactive.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ additionalProperties:
# validation should be ignored
useBeanValidation: "true"
performBeanValidation: "true"
useSpringBoot3: "true"

Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
generatorName: spring
library: spring-http-interface
outputDir: samples/client/petstore/spring-http-interface-useHttpServiceProxyFactoryInterfacesConfigurator
inputSpec: modules/openapi-generator/src/test/resources/3_0/spring/petstore-with-fake-endpoints-models-for-testing.yaml
templateDir: modules/openapi-generator/src/main/resources/JavaSpring
additionalProperties:
artifactId: spring-http-interface-useHttpServiceProxyFactoryInterfacesConfigurator
snapshotVersion: "true"
hideGenerationTimestamp: "true"
# documentation provider should be ignored
documentationProvider: "springdoc"
# annotation provider should be ignored
annotationLibrary: "swagger2"
# validation should be ignored
useBeanValidation: "true"
performBeanValidation: "true"
useHttpServiceProxyFactoryInterfacesConfigurator: "true"
useSpringBoot3: "true"
1 change: 1 addition & 0 deletions bin/configs/spring-http-interface.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ additionalProperties:
# validation should be ignored
useBeanValidation: "true"
performBeanValidation: "true"
useSpringBoot3: "true"
3 changes: 2 additions & 1 deletion docs/generators/java-camel.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|interfaceOnly|Whether to generate only API interface stubs without the server files.| |false|
|invokerPackage|root package for generated code| |org.openapitools.api|
|legacyDiscriminatorBehavior|Set to false for generators with better support for discriminators. (Python, Java, Go, PowerShell, C# have this enabled by default).|<dl><dt>**true**</dt><dd>The mapping in the discriminator includes descendent schemas that allOf inherit from self and the discriminator mapping schemas in the OAS document.</dd><dt>**false**</dt><dd>The mapping in the discriminator includes any descendent schemas that allOf inherit from self, any oneOf schemas, any anyOf schemas, any x-discriminator-values, and the discriminator mapping schemas in the OAS document AND Codegen validates that oneOf and anyOf schemas contain the required discriminator and throws an error if the discriminator is missing.</dd></dl>|false|
|library|library template (sub-template)|<dl><dt>**spring-boot**</dt><dd>Spring-boot Server application.</dd><dt>**spring-cloud**</dt><dd>Spring-Cloud-Feign client with Spring-Boot auto-configured settings.</dd><dt>**spring-http-interface**</dt><dd>Spring 6 HTTP interfaces (testing)</dd></dl>|spring-boot|
|library|library template (sub-template)|<dl><dt>**spring-boot**</dt><dd>Spring-boot Server application.</dd><dt>**spring-cloud**</dt><dd>Spring-Cloud-Feign client with Spring-Boot auto-configured settings.</dd><dt>**spring-http-interface**</dt><dd>Spring 6 HTTP interfaces (testing). Requires Spring Boot 3 or 4.</dd></dl>|spring-boot|
|licenseName|The name of the license| |Unlicense|
|licenseUrl|The URL of the license| |http://unlicense.org|
|modelPackage|package for generated models| |org.openapitools.model|
Expand Down Expand Up @@ -109,6 +109,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|useEnumCaseInsensitive|Use `equalsIgnoreCase` when String for enum comparison| |false|
|useFeignClientContextId|Whether to generate Feign client with contextId parameter.| |true|
|useFeignClientUrl|Whether to generate Feign client with url parameter.| |true|
|useHttpServiceProxyFactoryInterfacesConfigurator|Generate HttpInterfacesAbstractConfigurator based on an HttpServiceProxyFactory instance (as opposed to a WebClient instance, when disabled) for generating Spring HTTP interfaces.| |false|
|useJackson3|Set it in order to use jackson 3 dependencies (only allowed when `useSpringBoot4` is set and incompatible with `openApiNullable`).| |false|
|useJakartaEe|whether to use Jakarta EE namespace instead of javax| |false|
|useOneOfInterfaces|whether to use a java interface to describe a set of oneOf options, where each option is a class that implements the interface| |true|
Expand Down
3 changes: 2 additions & 1 deletion docs/generators/spring.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|interfaceOnly|Whether to generate only API interface stubs without the server files.| |false|
|invokerPackage|root package for generated code| |org.openapitools.api|
|legacyDiscriminatorBehavior|Set to false for generators with better support for discriminators. (Python, Java, Go, PowerShell, C# have this enabled by default).|<dl><dt>**true**</dt><dd>The mapping in the discriminator includes descendent schemas that allOf inherit from self and the discriminator mapping schemas in the OAS document.</dd><dt>**false**</dt><dd>The mapping in the discriminator includes any descendent schemas that allOf inherit from self, any oneOf schemas, any anyOf schemas, any x-discriminator-values, and the discriminator mapping schemas in the OAS document AND Codegen validates that oneOf and anyOf schemas contain the required discriminator and throws an error if the discriminator is missing.</dd></dl>|false|
|library|library template (sub-template)|<dl><dt>**spring-boot**</dt><dd>Spring-boot Server application.</dd><dt>**spring-cloud**</dt><dd>Spring-Cloud-Feign client with Spring-Boot auto-configured settings.</dd><dt>**spring-http-interface**</dt><dd>Spring 6 HTTP interfaces (testing)</dd></dl>|spring-boot|
|library|library template (sub-template)|<dl><dt>**spring-boot**</dt><dd>Spring-boot Server application.</dd><dt>**spring-cloud**</dt><dd>Spring-Cloud-Feign client with Spring-Boot auto-configured settings.</dd><dt>**spring-http-interface**</dt><dd>Spring 6 HTTP interfaces (testing). Requires Spring Boot 3 or 4.</dd></dl>|spring-boot|
|licenseName|The name of the license| |Unlicense|
|licenseUrl|The URL of the license| |http://unlicense.org|
|modelPackage|package for generated models| |org.openapitools.model|
Expand Down Expand Up @@ -102,6 +102,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|useEnumCaseInsensitive|Use `equalsIgnoreCase` when String for enum comparison| |false|
|useFeignClientContextId|Whether to generate Feign client with contextId parameter.| |true|
|useFeignClientUrl|Whether to generate Feign client with url parameter.| |true|
|useHttpServiceProxyFactoryInterfacesConfigurator|Generate HttpInterfacesAbstractConfigurator based on an HttpServiceProxyFactory instance (as opposed to a WebClient instance, when disabled) for generating Spring HTTP interfaces.| |false|
|useJackson3|Set it in order to use jackson 3 dependencies (only allowed when `useSpringBoot4` is set and incompatible with `openApiNullable`).| |false|
|useJakartaEe|whether to use Jakarta EE namespace instead of javax| |false|
|useOneOfInterfaces|whether to use a java interface to describe a set of oneOf options, where each option is a class that implements the interface| |true|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ public class SpringCodegen extends AbstractJavaCodegen
public static final String SPRING_BOOT = "spring-boot";
public static final String SPRING_CLOUD_LIBRARY = "spring-cloud";
public static final String SPRING_HTTP_INTERFACE = "spring-http-interface";
public static final String USE_HTTP_SERVICE_PROXY_FACTORY_INTERFACES_CONFIGURATOR = "useHttpServiceProxyFactoryInterfacesConfigurator";
public static final String HTTP_INTERFACES_CONFIGURATOR_DEPENDENCY = "httpInterfacesConfiguratorDependency";
public static final String API_FIRST = "apiFirst";
public static final String SPRING_CONTROLLER = "useSpringController";
public static final String HATEOAS = "hateoas";
Expand Down Expand Up @@ -183,6 +185,7 @@ public enum RequestMappingMode {
protected boolean useJackson3 = false;
@Getter @Setter
protected boolean additionalNotNullAnnotations = false;
@Setter boolean useHttpServiceProxyFactoryInterfacesConfigurator = false;

public SpringCodegen() {
super();
Expand Down Expand Up @@ -317,10 +320,14 @@ public SpringCodegen() {

cliOptions.add(CliOption.newBoolean(USE_DEDUCTION_FOR_ONE_OF_INTERFACES, "whether to use deduction for generated oneOf interfaces", useDeductionForOneOfInterfaces));
cliOptions.add(CliOption.newString(SPRING_API_VERSION, "Value for 'version' attribute in @RequestMapping (for Spring 7 and above)."));
cliOptions.add(CliOption.newString(USE_HTTP_SERVICE_PROXY_FACTORY_INTERFACES_CONFIGURATOR,
"Generate HttpInterfacesAbstractConfigurator based on an HttpServiceProxyFactory instance (as opposed to a WebClient instance, when disabled) for generating Spring HTTP interfaces.")
.defaultValue("false")
);
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_HTTP_INTERFACE, "Spring 6 HTTP interfaces (testing)");
supportedLibraries.put(SPRING_HTTP_INTERFACE, "Spring 6 HTTP interfaces (testing). Requires Spring Boot 3 or 4.");
setLibrary(SPRING_BOOT);
final CliOption library = new CliOption(CodegenConstants.LIBRARY, CodegenConstants.LIBRARY_DESC)
.defaultValue(SPRING_BOOT);
Expand Down Expand Up @@ -542,7 +549,9 @@ public void processOpts() {
} else {
this.applyJackson2Package();
}

convertPropertyToStringAndWriteBack(RESOURCE_FOLDER, this::setResourceFolder);
convertPropertyToBooleanAndWriteBack(USE_HTTP_SERVICE_PROXY_FACTORY_INTERFACES_CONFIGURATOR, this::setUseHttpServiceProxyFactoryInterfacesConfigurator);

convertPropertyToBooleanAndWriteBack(ADDITIONAL_NOT_NULL_ANNOTATIONS, this::setAdditionalNotNullAnnotations);

Expand Down Expand Up @@ -635,9 +644,23 @@ public void processOpts() {
}
}
} else if (SPRING_HTTP_INTERFACE.equals(library)) {
supportingFiles.add(new SupportingFile("httpInterfacesConfiguration.mustache",
if (!(isUseSpringBoot3() || isUseSpringBoot4())) {
throw new IllegalArgumentException("Library '" + SPRING_HTTP_INTERFACE + "' is only supported with Spring Boot 3 or 4");
}

String httpInterfacesAbstractConfiguratorFile = useHttpServiceProxyFactoryInterfacesConfigurator ?
"httpServiceProxyFactoryInterfacesConfigurator.mustache" :
"httpInterfacesConfiguration.mustache";

supportingFiles.add(new SupportingFile(httpInterfacesAbstractConfiguratorFile,
(sourceFolder + File.separator + configPackage).replace(".", java.io.File.separator), "HttpInterfacesAbstractConfigurator.java"));
writePropertyBack(USE_BEANVALIDATION, false);

writePropertyBack(HTTP_INTERFACES_CONFIGURATOR_DEPENDENCY,
useHttpServiceProxyFactoryInterfacesConfigurator ?
"HttpServiceProxyFactory" :
reactive ? "WebClient" : "RestClient"
);
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# OpenAPI generated API stub

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


## Overview
Expand All @@ -9,13 +9,13 @@ By using the [OpenAPI-Spec](https://openapis.org), you can easily generate an AP
This is an example of building API stub interfaces in Java using the Spring framework.

The stubs generated can be used in your existing Spring application for HTTP integration with other REST services
To use auto-generated interfaces you have to create your own configuration which extends default abstract configurator & provide `{{#reactive}}WebClient{{/reactive}}{{^reactive}}RestClient{{/reactive}}` instance via constructor
To use auto-generated interfaces you have to create your own configuration which extends default abstract configurator & provide `{{httpInterfacesConfiguratorDependency}}` instance via constructor
```java
@Configuration
public class MyConfiguration extends {{configPackage}}.HttpInterfacesAbstractConfigurator {

public MyConfiguration({{#reactive}}WebClient{{/reactive}}{{^reactive}}RestClient{{/reactive}} client) {
super(client);
public MyConfiguration({{httpInterfacesConfiguratorDependency}} my{{httpInterfacesConfiguratorDependency}}) { // separately created {{httpInterfacesConfiguratorDependency}} instance
super(my{{httpInterfacesConfiguratorDependency}});
}
}
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/**
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) ({{{generatorVersion}}}).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
package {{configPackage}};

{{#apiInfo}}
{{#apis}}
import {{apiPackage}}.{{classname}};
{{/apis}}
{{/apiInfo}}

import org.springframework.context.annotation.Bean;
import org.springframework.web.service.invoker.HttpServiceProxyFactory;

public abstract class HttpInterfacesAbstractConfigurator {

private final HttpServiceProxyFactory factory;

public HttpInterfacesAbstractConfigurator(final HttpServiceProxyFactory factory) {
this.factory = factory;
}

{{#apiInfo}}
{{#apis}}
@Bean(name = "{{configPackage}}.HttpInterfacesAbstractConfigurator.{{classVarName}}")
{{classname}} {{classVarName}}HttpProxy() {
return factory.createClient({{classname}}.class);
}

{{/apis}}
{{/apiInfo}}

}
Original file line number Diff line number Diff line change
Expand Up @@ -6621,6 +6621,7 @@ public void shouldNotHaveDocumentationAnnotationWhenUsingLibrarySpringHttpInterf
codegen.setOpenAPI(openAPI);
codegen.setOutputDir(output.getAbsolutePath());
codegen.setLibrary(SPRING_HTTP_INTERFACE);
codegen.setUseSpringBoot3(true);
codegen.setAnnotationLibrary(AnnotationLibrary.SWAGGER2);
codegen.setDocumentationProvider(DocumentationProvider.SPRINGDOC);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# OpenAPI generated API stub

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


## Overview
Expand All @@ -14,8 +14,8 @@ To use auto-generated interfaces you have to create your own configuration which
@Configuration
public class MyConfiguration extends org.openapitools.configuration.HttpInterfacesAbstractConfigurator {

public MyConfiguration(RestClient client) {
super(client);
public MyConfiguration(RestClient myRestClient) { // separately created RestClient instance
super(myRestClient);
}
}
```
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# OpenAPI generated API stub

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


## Overview
Expand All @@ -14,8 +14,8 @@ To use auto-generated interfaces you have to create your own configuration which
@Configuration
public class MyConfiguration extends org.openapitools.configuration.HttpInterfacesAbstractConfigurator {

public MyConfiguration(WebClient client) {
super(client);
public MyConfiguration(WebClient myWebClient) { // separately created WebClient instance
super(myWebClient);
}
}
```
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# OpenAPI generated API stub

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


## Overview
Expand All @@ -14,8 +14,8 @@ To use auto-generated interfaces you have to create your own configuration which
@Configuration
public class MyConfiguration extends org.openapitools.configuration.HttpInterfacesAbstractConfigurator {

public MyConfiguration(WebClient client) {
super(client);
public MyConfiguration(WebClient myWebClient) { // separately created WebClient instance
super(myWebClient);
}
}
```
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# OpenAPI generated API stub

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


## Overview
Expand All @@ -14,8 +14,8 @@ To use auto-generated interfaces you have to create your own configuration which
@Configuration
public class MyConfiguration extends org.openapitools.configuration.HttpInterfacesAbstractConfigurator {

public MyConfiguration(RestClient client) {
super(client);
public MyConfiguration(RestClient myRestClient) { // separately created RestClient instance
super(myRestClient);
}
}
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# OpenAPI Generator Ignore
# Generated by openapi-generator https://github.com/openapitools/openapi-generator

# Use this file to prevent files from being overwritten by the generator.
# The patterns follow closely to .gitignore or .dockerignore.

# As an example, the C# client generator defines ApiClient.cs.
# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line:
#ApiClient.cs

# You can match any string of characters against a directory, file or extension with a single asterisk (*):
#foo/*/qux
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux

# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
#foo/**/qux
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux

# You can also negate patterns with an exclamation (!).
# For example, you can ignore all files in a docs folder with the file extension .md:
#docs/*.md
# Then explicitly reverse the ignore rule for a single file:
#!docs/README.md
Loading
Loading