Skip to content

[kotlin][client] Respect explicit useJackson3=false with useSpringBoot4 on jvm-spring-restclient - #25130

Merged
wing328 merged 1 commit into
OpenAPITools:masterfrom
seonwooj0810:fix/issue-24842-kotlin-respect-usejackson3
Oct 7, 2026
Merged

wing328 merged 1 commit into
OpenAPITools:masterfrom
seonwooj0810:fix/issue-24842-kotlin-respect-usejackson3

Conversation

@seonwooj0810

@seonwooj0810 seonwooj0810 commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #24842

Since #24709, useSpringBoot4=true on jvm-spring-restclient switches to Jackson 3 even when the user explicitly sets useJackson3=false. The check used !isUseJackson3(), which cannot tell "not set" from "explicitly false". It can't because AbstractKotlinCodegen.processOpts() always writes useJackson3 back into additionalProperties. Projects that compiled with 7.24.0 against their own Jackson 2 build (see the issue) now get a tools.jackson Serializer.kt and JacksonJsonHttpMessageConverter.

The fix records whether useJackson3 was configured before super.processOpts(). Jackson 3 is only auto-enabled when the option was not set. With useSpringBoot4=true alone, the output is unchanged and still Jackson 3 by default. An explicit useJackson3=false now generates the Jackson 2 serializer, the MappingJackson2HttpMessageConverter constructor and the Jackson 2 Gradle dependencies.

Verification done:

  • Added KotlinClientCodegenModelTest.shouldRespectExplicitJackson3FalseWithSpringBoot4. It fails without the change because PetApi.kt has no MappingJackson2HttpMessageConverter, and passes with it.
  • KotlinClientCodegenModelTest (69) and KotlinClientCodegenApiTest (31) pass, including the existing shouldAutoEnableJackson3WithSpringBoot4.
  • Regenerated kotlin-jvm-spring-4-restclient-jackson3, kotlin-jvm-spring-3-restclient and kotlin-jackson3: no sample diff. export_docs_generators.sh: no doc diff.
  • Generated a client with useSpringBoot4=true,useJackson3=false (with and without useSpringBoot3=true). ./gradlew compileKotlin succeeds against Spring Boot 4.1.0 + Jackson 2.22.1 (Gradle 8.14.5, JDK 21).

PR checklist

  • Read the contribution guidelines.
  • Ran the build/tests for modules/openapi-generator, regenerated the affected Kotlin samples (no changes) and exported docs (no changes).
  • @mention technical committee — deferring to maintainers.

Summary by cubic

Fixes #24842 by honoring an explicit useJackson3=false on jvm-spring-restclient instead of overriding it when useSpringBoot4=true is set. Since #24709, processOpts() always wrote useJackson3 back, so the generator couldn't tell "not set" from "explicitly false" and auto-enabled Jackson 3. The check now records whether the option was configured before processOpts() runs. With useSpringBoot4=true alone, the output is unchanged and still defaults to Jackson 3; an explicit useJackson3=false now generates the Jackson 2 serializer, the MappingJackson2HttpMessageConverter constructor, and the Jackson 2 Gradle dependencies.

  • Adds a regression test covering explicit useJackson3=false with useSpringBoot4=true.

Written for commit daf9dc0. Summary will update on new commits.

Review in cubic

…t4 on jvm-spring-restclient (OpenAPITools#24842)

Signed-off-by: seonwoo_jung <79202163+seonwooj0810@users.noreply.github.com>

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

1 issue found across 2 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/KotlinClientCodegen.java">

<violation number="1" location="modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/KotlinClientCodegen.java:444">
P2: `setUseJackson3(false)` leaves no map entry, so this check treats the caller's explicit choice as omitted and enables Jackson 3 for Boot 4. Track setter-configured values too.</violation>
</file>

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

}

// super.processOpts() always writes useJackson3 back, so remember whether the user set it
boolean useJackson3Configured = additionalProperties.containsKey(USE_JACKSON_3);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2: setUseJackson3(false) leaves no map entry, so this check treats the caller's explicit choice as omitted and enables Jackson 3 for Boot 4. Track setter-configured values too.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/KotlinClientCodegen.java, line 444:

<comment>`setUseJackson3(false)` leaves no map entry, so this check treats the caller's explicit choice as omitted and enables Jackson 3 for Boot 4. Track setter-configured values too.</comment>

<file context>
@@ -440,6 +440,9 @@ public void processOpts() {
         }
 
+        // super.processOpts() always writes useJackson3 back, so remember whether the user set it
+        boolean useJackson3Configured = additionalProperties.containsKey(USE_JACKSON_3);
+
         super.processOpts();
</file context>

@wing328

wing328 commented Oct 7, 2026

Copy link
Copy Markdown
Member

thanks for the PR

cc @karismann (2019/03) @Zomzog (2019/04) @andrewemery (2019/10) @4brunu (2019/11) @yutaka0m (2020/03) @stefankoppier (2022/06) @e5l (2024/10)

@wing328 wing328 added this to the 7.27.0 milestone Oct 7, 2026
@wing328
wing328 merged commit 57a655e into OpenAPITools:master Oct 7, 2026
15 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.

[BUG][KOTLIN] Fails to compile after updating to 7.25.0 with useJackson3=false useSpringBoot4=true

2 participants