[Kotlin][jvm-spring-restclient] make nullableReturnType type bound conditional in ApiClient#23657
Merged
wing328 merged 1 commit intoOpenAPITools:masterfrom Apr 30, 2026
Conversation
…nditional in ApiClient Fixes OpenAPITools#23654 PR OpenAPITools#23613 unconditionally relaxed the type bound from `T : Any` to `T : Any?` in ApiClient.kt.mustache for jvm-spring-restclient. This breaks compilation with Spring Boot 4 / Spring Framework 7, where stricter nullability handling rejects nullable bounds on RestClient.ResponseSpec.toEntity(). Make the relaxation conditional on the nullableReturnType option: - Default (nullableReturnType=false): T : Any (identical to pre-OpenAPITools#23613) - nullableReturnType=true: T : Any? (preserves the OpenAPITools#23613 NPE fix) Also restores I bound to Any everywhere (request bodies are never nullable) and removes the unnecessary `as Any` cast in nullableBody.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #23654
PR #23613 unconditionally relaxed the type bound from
T : AnytoT : Any?inApiClient.kt.mustacheforjvm-spring-restclient. This breaks compilation with Spring Boot 4 / Spring Framework 7, where stricter nullability handling rejects nullable bounds onRestClient.ResponseSpec.toEntity().Make the relaxation conditional on the
nullableReturnTypeoption:TboundnullableReturnType=false)T : AnynullableReturnType=trueT : Any?Also restores
Ibound toAnyeverywhere (request bodies are never nullable) and removes the unnecessaryas Anycast innullableBody.Verification:
./bin/generate-samples.sh bin/configs/kotlin-*.yaml— 112 generators, zero drift./bin/utils/export_docs_generators.sh— no doc changescc @wing328 @stefankoppier @karismann @Zomzog @andrewemery @4brunu @yutaka0m @e5l @dennisameling
PR checklist
./bin/generate-samples.sh bin/configs/kotlin-*.yaml— 112 generators, zero drift./bin/utils/export_docs_generators.sh— no doc changesmasterSummary by cubic
Conditionally relax the response type bound in
jvm-spring-restclientApiClient.kt.mustachebased onnullableReturnType. Restores Spring Boot 4 / Spring Framework 7 compatibility while keeping the nullable-return NPE fix.nullableReturnType=false):T : Any; whentrue:T : Any?, avoidingRestClient.ResponseSpec.toEntity()bound errors.I : Any) and remove the unnecessaryas Anycast.Written for commit c79ab9b. Summary will update on new commits. Review in cubic