Skip to content

Conversation

legion47T
Copy link
Contributor

As addressed in #21628 Spring Framework 7 changes the HttpHeader type in a way that's not compatible with the current Spring WebClient ApiClient code generated by OpenAPI.
This PR adapts the changes from #21691 for WebClient.

The new HttpHeader methods become available with Spring Boot 3.2, which is why I updated from 3.0.12 to 3.2.12.

Similar to mentioned PR one can verify operation with

  1. Generate a PetStore project with webclient for JakartaEE
  2. Run integration-tests (mvn integration-test -f samples/client/petstore/java/webclient-jakarta/pom.xml)
  3. Modify the project to use Spring Boot 4.0.0-M3 instead
  4. Rerun integration tests

Unfortunately I wasn't able to run more than the integration tests, i.e. I did not spin up an actual server yet.

Mentioning Java Spring committee members: @cachescrubber , @welshm , @MelleD , @atextor , @manedev79 , @javisst , @borsch , @banlevente , @Zomzog , @martin-mfg

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 || exit
    ./bin/generate-samples.sh ./bin/configs/*.yaml || exit
    ./bin/utils/export_docs_generators.sh || exit
    
    (For Windows users, please run the script in WSL)
    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 solves a reported issue, reference it using GitHub's linking syntax (e.g., having "fixes #123" present in the PR description)
  • If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.

@wing328
Copy link
Member

wing328 commented Oct 6, 2025

Thanks for the PR.

2. Run integration-tests (mvn integration-test -f samples/client/petstore/java/webclient-jakarta/pom.xml)
3. Modify the project to use Spring Boot 4.0.0-M3 instead

I ran the above against the master but the result is green (project compiles).

Am I supposed to get errors or the issues only occur during runtime?

@legion47T
Copy link
Contributor Author

legion47T commented Oct 6, 2025

This should be a compile time error.

When I

  1. replace <spring-boot-version>3.0.12</spring-boot-version> with <spring-boot-version>4.0.0-M3</spring-boot-version> in samples/client/petstore/java/webclient-jakarta/pom.xml and
  2. execute mvn clean integration-test -f samples/client/petstore/java/webclient-jakarta/

I get

[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /C:/Users/<user>/dev/projects/openapi-generator/samples/client/petstore/java/webclient-jakarta/src/main/java/org/openapitools/client/ApiClient.java:[349,27] Symbol nicht gefunden
  Symbol: Methode containsKey(java.lang.String)
  Ort: Variable defaultHeaders von Typ org.springframework.http.HttpHeaders
[ERROR] /C:/Users/<user>/dev/projects/openapi-generator/samples/client/petstore/java/webclient-jakarta/src/main/java/org/openapitools/client/ApiClient.java:[729,57] Symbol nicht gefunden
  Symbol: Methode entrySet()
  Ort: Variable headers von Typ org.springframework.http.HttpHeaders
[INFO] 2 errors

@wing328
Copy link
Member

wing328 commented Oct 6, 2025

still no luck. it compiles fine:

[INFO]
[INFO] --- jar:3.3.0:jar (default-jar) @ petstore-webclient ---
[INFO] Building jar: C:\Users\wing3\Code\openapi-generator\samples\client\petstore\java\webclient-jakarta\target\petstore-webclient-1.0.0.jar
[INFO]
[INFO] --- source:3.3.1:jar-no-fork (attach-sources) @ petstore-webclient ---
[INFO] Building jar: C:\Users\wing3\Code\openapi-generator\samples\client\petstore\java\webclient-jakarta\target\petstore-webclient-1.0.0-sources.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  13.664 s
[INFO] Finished at: 2025-10-06T16:53:39+08:00
[INFO] ------------------------------------------------------------------------
[INFO] 7 goals, 7 executed
[INFO]
[INFO] Publishing build scan...
[INFO] https://ge.openapi-generator.tech/s/awruj67pjmpgw
[INFO]

wing3@MSI MINGW64 ~/Code/openapi-generator (master)
$ git diff
diff --git a/samples/client/petstore/java/webclient-jakarta/pom.xml b/samples/client/petstore/java/webclient-jakarta/pom.xml
index 695f884ed60..ef2fa1939e9 100644
--- a/samples/client/petstore/java/webclient-jakarta/pom.xml
+++ b/samples/client/petstore/java/webclient-jakarta/pom.xml
@@ -123,7 +123,7 @@
         <jackson-version>2.19.2</jackson-version>
         <jackson-databind-version>2.19.2</jackson-databind-version>
         <jackson-databind-nullable-version>0.2.7</jackson-databind-nullable-version>
-        <spring-boot-version>3.0.12</spring-boot-version>
+        <spring-boot-version>4.0.0-M3</spring-boot-version>
         <jakarta-annotation-version>2.1.1</jakarta-annotation-version>
         <reactor-version>3.5.12</reactor-version>
         <reactor-netty-version>1.2.8</reactor-netty-version>

wing3@MSI MINGW64 ~/Code/openapi-generator (master)

I'm using JDK17 (on Windows). Not sure if it matters.

@legion47T
Copy link
Contributor Author

I'm on 24. I'll test whether that makes a difference, but I'd be surprised honestly.
Spring Framework removed the necessary interface from the class, so it shouldn't compile irrespecitve of the Java version.

@legion47T
Copy link
Contributor Author

Java 17 behaves identically.

@legion47T
Copy link
Contributor Author

If I read your build correctly it seems you did not clean before testing. I would assume the JAR you're testing against is still depending on Spring Boot 3 and Maven didn't see the need for a rebuild to resolve against Spring Boot 4.

@wing328
Copy link
Member

wing328 commented Oct 6, 2025

Ah you're right. Now I can reproduce the issue and able to confirm your fix addressed the compilation errors.

Thanks for the contribution. Let's give it a try

@wing328 wing328 merged commit b8d8059 into OpenAPITools:master Oct 6, 2025
104 checks passed
@wing328 wing328 added this to the 7.17.0 milestone Oct 6, 2025
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.

2 participants