feat(kotlin): Add support for Jackson3 and SpringBoot 4
Merged
TO
3mo ago+9222+9222+0123456789012345678901234567890123456789-11-11-01234567890123456789
Add support for generating Kotlin client with Jackson3 and SpringBoot4 with okHttp and spring-restclient.
Based on the work of @yonatankarp
Manually tested these changes in a couple of our projects and confirm they are still compiling and functioning as intended.
Fixes #23114
PR checklist
- Read the contribution guidelines.
- Run the following to build the project and update samples:
(For Windows users, please run the script in WSL)./mvnw clean package || exit ./bin/generate-samples.sh ./bin/configs/*.yaml || exit ./bin/utils/export_docs_generators.sh || exit
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. - If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.
Kotlin Technical committee member mentions:
@karismann, @Zomzog, @andrewemery, @4brunu, @stefankoppier, @e5l
Summary by cubic
Adds opt-in Kotlin client support for Jackson 3 and Spring Boot 4 in OkHttp and jvm-spring-restclient. This enables latest-stack users while keeping existing defaults; generation now fails if useJackson3=true without serializationLibrary=jackson.
- Jackson 3: switch to
tools.jackson.*withJsonMapper/jsonMapperand the Kotlin module; set non-absent inclusion, ignore unknown properties, disable timestamp dates, and honor unknown-enum defaults whenenumUnknownDefaultCase=true. OkHttp now importstools.jackson.core.type.TypeReference. - Spring RestClient: with
useSpringBoot4=true, useJacksonJsonHttpMessageConverterbacked by the generatedSerializer; keepMappingJackson2HttpMessageConverterotherwise. Align converter setup with the Java RestClient and fixregisterDefaultsplacement so our custom mapper is retained. - Templates/CI/docs: Gradle adds
jackson3_version(3.1.5) and sets Spring Boot 4.1.0 whenuseSpringBoot4=true; keep Boot 3/2 otherwise. CI builds new samples:kotlin-jackson3andkotlin-jvm-spring-4-restclient-jackson3. Docs updated. Tests enforce thatuseJackson3requires Jackson serialization.
Usage and migration
- Jackson 3: set
serializationLibrary=jacksonanduseJackson3=true. Generated builds usetools.jackson.module:jackson-module-kotlin:3.1.5andtools.jackson.*imports. - Spring Boot 4 RestClient: set
library=jvm-spring-restclientanduseSpringBoot4=true. Generated clients use Boot 4.1.0 andJacksonJsonHttpMessageConverter. - No changes unless you opt in.