Skip to content

Conversation

phactum-mnestler
Copy link
Contributor

As discussed in #21628, breaking changes in Spring 7 HttpHeaders are incompatible with the currently generated code. In particular, HttpHeaders#containsKey and HttpHeaders#entrySet will no longer be available.

Because the replacement for entrySet, headerSet, only became available in Spring Web 6.1.15, this PR also bumps the Spring Web patch version generated by the restclient library from 6.1.6 to 6.1.21. If this is considered a breaking change, feel free to retarget the PR for 8.x accordingly.

This PR does NOT modify the webclient generator, as that generator still generates a Spring Boot 2.7 project and thus does not have the headerSet method available without a breaking change.

To verify this change:

  1. Generate a PetStore project with the restclient or (resttemplate with useSpringBoot3 enabled)
  2. Verify headers work correctly
  3. Modify the project to use Spring 7.0.0-M7 instead
  4. Verify headers still work correctly

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.

@phactum-mnestler
Copy link
Contributor Author

@wing328 and @typat, feel free to give input. As mentioned in the description, this change should be compatible from Spring 6.1.15 to Spring 7.0.0-M7.
Also mentioning the committee members as requested in the MR template: @cachescrubber @welshm @MelleD @atextor @manedev79 @javisst @borsch @banlevente @Zomzog @martin-mfg

Copy link

@typat typat left a comment

Choose a reason for hiding this comment

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

these changes look good to me! thanks for making these updates. I'll test this today in my project as well and report if there are any issues.

@wing328
Copy link
Member

wing328 commented Aug 5, 2025

thanks for the pr

i'll try to include it in the upcoming release

@ahoehma
Copy link

ahoehma commented Aug 5, 2025

@phactum-mnestler one question ... what happens if a project which is still using springboot 3.5.x update to the new openapi-gen version? I guess then the generated client code will have compiler errors because the surrounding project still using "older" springboot. In my project I'm using the openapi-generator-maven-plugin. But I include only the generated java-code into my surrounding project.

@phactum-mnestler
Copy link
Contributor Author

@ahoehma Spring Boot 3.5 ships with at least Spring Web 6.2.7, so it should be compatible with this change. If you'd like, try this out in your project and let us know if anything breaks!

@wing328 wing328 merged commit f659457 into OpenAPITools:master Aug 6, 2025
97 checks passed
Goopher pushed a commit to Goopher/openapi-generator that referenced this pull request Sep 9, 2025
…penAPITools#21691)

* [spring] Adapt HttpHeaders access to remain compatible with Spring 7

* update pom.xml patch version
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.

4 participants