Skip to content

spring-http-interface: introduce springHttpClientAdapter, fix paramDoc.mustache#19710

Merged
wing328 merged 28 commits intoOpenAPITools:masterfrom
ibaranga:master
Mar 15, 2026
Merged

spring-http-interface: introduce springHttpClientAdapter, fix paramDoc.mustache#19710
wing328 merged 28 commits intoOpenAPITools:masterfrom
ibaranga:master

Conversation

@ibaranga
Copy link
Contributor

@ibaranga ibaranga commented Sep 29, 2024

Addressing issue #19712

What

  • Introduce springHttpClientAdapter useHttpServiceProxyFactoryInterfacesConfigurator for spring-http-interface
  • Added an spring-http-interface-specific empty paramDoc.mustache

Why

  • Enable selecting different HTTP client implementations when generating Spring HTTP client interfaces
  • Provides additional flexibility for users who want to generate non-reactive Spring Boot applications

How

- springHttpClientAdapter: Allows users to choose between different HTTP client implementations used in HttpInterfacesAbstractConfigurator:
- web-client (set by default, to ensure backward compatibility)
- rest-client
- rest-template
- Separate templates for each HttpInterfacesAbstractConfigurator implementation:
- httpInterfacesRestClientConfiguration.mustache
- httpInterfacesRestTemplateConfiguration.mustache
- httpInterfacesWebClientConfiguration.mustache
- Log warning for configuration mismatch
- When reactive: false is used in combination with the reactive web-client, it warns users of potential configuration
mismatches, and suggests switching to rest-template or rest-client for non-reactive configurations.

  • spring-http-interface: introduce springHttpClientAdapter, fix paramDoc.mustache #19710 (comment)

  • Remove unnecessary paramDoc

    • Added an spring-http-interface-specific empty paramDoc.mustache in JavaSpring/libraries/spring-http-interface/paramDoc.mustache
    • This prevents inheriting the @Parameter annotations from the default Spring template located at JavaSpring/paramDoc.mustache.
    • Otherwise, the generated code includes @Parameter annotations on request body parameters, which were causing compile errors due to missing imports

PR checklist

  • Read the contribution guidelines.
  • Pull Request title clearly describes the work in the pull request and Pull Request description provides details about how to validate the work. Missing information here may result in delayed response from the community.
  • Run the following to build the project and update samples:
    ./mvnw clean package 
    ./bin/generate-samples.sh ./bin/configs/*.yaml
    ./bin/utils/export_docs_generators.sh
    
    (For Windows users, please run the script in Git BASH)
    Commit all changed files.
    This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
    These must match the expectations made by your contribution.
    You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example ./bin/generate-samples.sh bin/configs/java*.
    IMPORTANT: Do NOT purge/delete any folders/files (e.g. tests) when regenerating the samples as manually written tests may be removed.
  • File the PR against the correct branch: master (upcoming 7.x.0 minor release - breaking changes with fallbacks), 8.0.x (breaking changes without fallbacks)
  • If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.

@cachescrubber @welshm @MelleD @atextor @manedev79 @javisst @borsch @banlevente @Zomzog @martin-mfg

…mDoc.mustache`

---
### What
- Introduce `springHttpClientAdapter` for `spring-http-interface`
  - This property is used for selecting HTTP client implementation in Spring HTTP interfaces, with separate templates for each client configuration
- Added an `spring-http-interface`-specific **empty** `paramDoc.mustache`
---

### Why
- Enable selecting different HTTP client implementations when generating Spring HTTP client interfaces
- Provides additional flexibility for users who want to generate non-reactive Spring Boot applications.
---

### How
- `springHttpClientAdapter`: Allows users to choose between different HTTP client implementations used in `HttpInterfacesAbstractConfigurator`:
  - `web-client` (set by default, to ensure **backward compatibility**)
  - `rest-client`
  - `rest-template`
- Separate templates for each `HttpInterfacesAbstractConfigurator` implementation:
  - `httpInterfacesRestClientConfiguration.mustache`
  - `httpInterfacesRestTemplateConfiguration.mustache`
  - `httpInterfacesWebClientConfiguration.mustache`
- Log warning for configuration mismatch
  - When `reactive: false` is used in combination with the reactive `web-client`, it warns users of potential configuration mismatches, and suggests switching to `rest-template` or `rest-client` for non-reactive configurations.
- Remove unnecessary paramDoc
  - Added an `spring-http-interface`-specific **empty** `paramDoc.mustache` in `JavaSpring/libraries/spring-http-interface/paramDoc.mustache`
  - This prevents inheriting the `@Parameter` annotations from the default Spring template located at `JavaSpring/paramDoc.mustache`.
  - Otherwise, the generated code includes `@Parameter` annotations on request body parameters, which were causing compile errors due to missing imports

---

### Testing Done

- **Manual testing**: Verified that the generated code uses `WebClient`, `RestTemplate`, or `RestClient` based on the value of the `springHttpClientAdapter` property.
- **Tested different configurations**:
   - **`reactive: false` & `web-client`**: Logs a warning, suggesting the use of `rest-client` or `rest-template`.
   - **`springHttpClientAdapter: rest-template`**: Generates code with `RestTemplateAdapter` using the `httpInterfacesRestTemplateConfiguration.mustache`.
   - **`springHttpClientAdapter: web-client` (default)**: Generates code using `WebClientAdapter` from `httpInterfacesWebClientConfiguration.mustache` and ensures backward compatibility.
- **Tested `paramDoc.mustache` change**: Verified that the empty `paramDoc.mustache` prevents the generation of `@Parameter` annotations on request body parameters and resolves the compile errors caused by missing imports.

---

### PR checklist

- [ ] Read the [contribution guidelines](https://github.com/openapitools/openapi-generator/blob/master/CONTRIBUTING.md).
- [ ] Pull Request title clearly describes the work in the pull request and Pull Request description provides details about how to validate the work. Missing information here may result in delayed response from the community.
- [ ] Run the following to [build the project](https://github.com/OpenAPITools/openapi-generator#14---build-projects) and update samples:
  ```
  ./mvnw clean package
  ./bin/generate-samples.sh ./bin/configs/*.yaml
  ./bin/utils/export_docs_generators.sh
  ```
  (For Windows users, please run the script in [Git BASH](https://gitforwindows.org/))
  Commit all changed files.
  This is important, as CI jobs will verify _all_ generator outputs of your HEAD commit as it would merge with master.
  These must match the expectations made by your contribution.
  You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example `./bin/generate-samples.sh bin/configs/java*`.
  IMPORTANT: Do **NOT** purge/delete any folders/files (e.g. tests) when regenerating the samples as manually written tests may be removed.
- [ ] File the PR against the [correct branch](https://github.com/OpenAPITools/openapi-generator/wiki/Git-Branches): `master` (upcoming `7.x.0` minor release - breaking changes with fallbacks), `8.0.x` (breaking changes without fallbacks)
- [ ] If your PR is targeting a particular programming language, @mention the [technical committee](https://github.com/openapitools/openapi-generator/#62---openapi-generator-technical-committee) members, so they are more likely to review the pull request.
@Bean(name = "{{configPackage}}.HttpInterfacesAbstractConfigurator.{{classVarName}}")
{{classname}} {{classVarName}}HttpProxy() {
HttpServiceProxyFactory factory = HttpServiceProxyFactory.builder(WebClientAdapter.forClient(webClient)).build();
HttpServiceProxyFactory factory = HttpServiceProxyFactory.builderFor(WebClientAdapter.forClient(webClient)).build();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is marked as deprecated, replacing it with builderFor, which is also in line with the rest of the httpInterfaces*Configuration.mustache templates

@wing328
Copy link
Member

wing328 commented Oct 1, 2024

@ibaranga
Copy link
Contributor Author

ibaranga commented Oct 1, 2024

@wing328 thanks, fixed!

@wing328 wing328 modified the milestones: 7.9.0, 7.10.0 Oct 8, 2024
@wing328
Copy link
Member

wing328 commented Oct 11, 2024

please review the errors reported by the CI when you've time.

@ibaranga
Copy link
Contributor Author

please review the errors reported by the CI when you've time.

Thanks again, @wing328, I've just updated the PR!

@wing328
Copy link
Member

wing328 commented Nov 18, 2024

filed #20129 to trigger all the tests

let's see how that goes

@wing328 wing328 modified the milestones: 7.10.0, 7.11.0 Nov 18, 2024
@wing328
Copy link
Member

wing328 commented Nov 18, 2024

@ibaranga can you please add sample to test the new option similar to #20071 (comment) ?

@davidkarlsen
Copy link

It would be good to test this with latest GA version of spring, as #20174 is related

@wing328
Copy link
Member

wing328 commented Nov 25, 2024

@davidkarlsen do you mind doing a test locally for that?

git checkout -b ibaranga-master master
git pull https://github.com/ibaranga/openapi-generator.git master

@wing328 wing328 modified the milestones: 7.15.0, 7.16.0 Aug 22, 2025
@wing328 wing328 modified the milestones: 7.16.0, 8.0.0, 7.17.0 Sep 28, 2025
@dejavuhuh
Copy link

Do you have any plans to support Kotlin?🤔

@wing328 wing328 modified the milestones: 7.17.0, 7.18.0 Oct 29, 2025
@Picazsoo
Copy link
Contributor

Picazsoo commented Nov 5, 2025

Do you have any plans to support Kotlin?🤔

I just opened an issue here and plan to contribute a PR with barebones implementation of kotlin-spring declarative http interface in coming days.

@wing328 wing328 modified the milestones: 7.18.0, 7.19.0 Dec 22, 2025
@wing328 wing328 modified the milestones: 7.19.0, 7.20.0 Jan 19, 2026
@wing328 wing328 modified the milestones: 7.20.0, 7.21.0 Feb 16, 2026
@Bragolgirith
Copy link
Contributor

Bragolgirith commented Mar 13, 2026

Hi, it seems this PR was close to being merged about a year ago, but hasn’t been updated since.
What is the current blocker? Is there anything I can do to help move it forward?

@wing328
Copy link
Member

wing328 commented Mar 13, 2026

@Bragolgirith can you please file a new one based on this PR with resolved merged conflicts?

…http-interface-useHttpServiceProxyFactoryInterfacesConfigurator
…rsion (3 or 4) and fail early if unsupported
@Bragolgirith
Copy link
Contributor

I wouldn't want to steal the attribution from the original PR author, so (for now) I've now created a PR to @ibaranga's fork with the following changes:

  • Merged from master and resolved conflicts
  • Added a check to fail early if a Spring Boot version other than 3 or 4 is used

@ibaranga Would you be willing to take a look and - if at all possible - merge it soon-ish? :)

…seHttpServiceProxyFactoryInterfacesConfigurator

19712 spring-http-interface: introduce `springHttpClientAdapter`, `fix paramDoc.mustache` - merge from master
@ibaranga
Copy link
Contributor Author

Thanks @Bragolgirith - merged!

@ibaranga ibaranga requested a review from martin-mfg March 14, 2026 16:18
@wing328
Copy link
Member

wing328 commented Mar 14, 2026

I wouldn't want to steal the attribution from the original PR author

@ibaranga will be listed as co-author in your (@Bragolgirith) PR. That's how git works.

Just triggered the workflow. Will merge if all tests pass.

@ibaranga
Copy link
Contributor Author

I wouldn't want to steal the attribution from the original PR author

@ibaranga will be listed as co-author in your (@Bragolgirith) PR. That's how git works.

Just triggered the workflow. Will merge if all tests pass.

Thanks @wing328 !

Just pushed a few follow-up fixes to satisfy the spring-http-interface early-checks ("Requires Spring Boot 3 or 4."):

  • Set useSpringBoot3: "true" for all relevant sample configs and regenerated the samples.

  • Updated the docs in java-camel.md and spring.md to explicitly state the Spring Boot 3 or 4 requirement.

All checks (except docker/maven publish) are passing on my fork.

@wing328 wing328 merged commit ed0e031 into OpenAPITools:master Mar 15, 2026
81 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants