Skip to content

feat(kotlin-client): add Spring Boot 4 support for jvm-spring-restclient#23404

Draft
yonatankarp wants to merge 8 commits intoOpenAPITools:masterfrom
yonatankarp:feat/kotlin-client-spring-boot4
Draft

feat(kotlin-client): add Spring Boot 4 support for jvm-spring-restclient#23404
yonatankarp wants to merge 8 commits intoOpenAPITools:masterfrom
yonatankarp:feat/kotlin-client-spring-boot4

Conversation

@yonatankarp
Copy link
Copy Markdown
Contributor

@yonatankarp yonatankarp commented Apr 1, 2026

Summary

  • Adds useSpringBoot4 option for the jvm-spring-restclient library, which upgrades to Spring Boot 4 and implies useJackson3
  • Includes new kotlin-jvm-spring-4-restclient-jackson3 sample
  • Regenerated FILES for CI stability

Dependencies

Test plan

  • CI passes on generated samples
  • useSpringBoot4=true correctly implies useJackson3=true
  • Spring Boot 4 restclient sample compiles and tests pass

🤖 Generated with Claude Code


Summary by cubic

Adds Spring Boot 4 support to the Kotlin jvm-spring-restclient generator via a new useSpringBoot4 option. This switches generated clients to Spring Boot 4’s RestClient with Jackson 3 and includes a new sample with CI coverage.

  • New Features

    • Added useSpringBoot4 for jvm-spring-restclient (sets Spring Boot to 4.x).
    • useSpringBoot4 implies useJackson3 and uses JacksonJsonHttpMessageConverter with a shared Serializer.
    • Jackson 3 wiring across templates via {{jacksonPackage}}; Gradle pulls tools.jackson.module:jackson-module-kotlin:3.0.1.
    • New samples: kotlin-jvm-spring-4-restclient-jackson3 and kotlin-jackson3; added to CI.
    • Generator docs updated for useJackson3; tests added to validate option constraints.
  • Migration

    • To generate Spring Boot 4 clients: set useSpringBoot4=true (no need to set useJackson3; it’s implied).
    • Requires serializationLibrary=jackson; useJackson3 is incompatible with openApiNullable.
    • If you relied on MappingJackson2HttpMessageConverter, the Spring 4 path now uses JacksonJsonHttpMessageConverter.

Written for commit 00b3413. Summary will update on new commits.

yonatankarp and others added 8 commits March 10, 2026 14:30
Wire the existing AbstractKotlinCodegen Jackson 3 infrastructure into
the kotlin client generator. When useJackson3=true (requires
serializationLibrary=jackson), all templates use the tools.jackson
package instead of com.fasterxml.jackson, and build.gradle pulls
jackson-module-kotlin 3.0.1 without the separate JSR-310 module.

- Register useJackson3 CLI option in KotlinClientCodegen
- Add validation: requires jackson serialization, incompatible with openApiNullable
- Replace hardcoded com.fasterxml.jackson with {{jacksonPackage}} in all
  model, serializer, and library-specific templates
- Make JavaTimeModule conditional (not needed in Jackson 3) for jvm-ktor
- Add Jackson 3 dependency block in build.gradle.mustache
- Add tests for validation and generated output
- Add kotlin-jackson3 sample config and generated sample
- Add sample to CI workflow matrix
- Regenerate generator docs
Jackson 3 only moves databind/core/module to tools.jackson package.
The annotations artifact stays at com.fasterxml.jackson.annotation.
Also add AbstractKotlinCodegen Jackson 3 infrastructure so this branch
is self-contained for CI testing.
Jackson 3 moved/renamed several APIs:
- findAndRegisterModules() not needed (modules auto-discovered)
- SerializationFeature.WRITE_DATES_AS_TIMESTAMPS -> DateTimeFeature
- DeserializationFeature.READ_UNKNOWN_ENUM_VALUES_USING_DEFAULT_VALUE -> EnumFeature

Add conditionals in Serializer.kt.mustache for Jackson 2 vs 3.
Jackson 3 ObjectMapper is immutable — no more chaining .configure()
and .setSerializationInclusion(). Use jsonMapper {} builder DSL with:
- changeDefaultPropertyInclusion for NON_ABSENT inclusion
- enable/disable for DateTimeFeature, EnumFeature, DeserializationFeature
- addModule(kotlinModule()) instead of jacksonObjectMapper()
The upstream kotlin-spring PR added a guard throwing IllegalArgumentException
for useJackson3 on kotlin-client. Since this branch implements that support,
remove the guard while keeping the proper validation below it.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add useSpringBoot4 option that auto-enables Jackson 3 and generates
RestClient code using JacksonJsonHttpMessageConverter with Spring Boot 4.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant