[BUG][KOTLIN] Jackson3 option does not discover modules like Jackson2 does
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 88/100
Research direction
Start with kotlin-client/jvm-common/infrastructure/Serializer.kt.mustache and compare the useJackson3 block with the Jackson 2 output generated when useJackson3 is false. Generate a jvm-spring-restclient client using the reported options, then verify that Jackson 3 discovers classpath modules such as JsonNullableJackson3Module and handles JsonNullable fields correctly.
Written by the indexing model from the issue text.
Description
Bug Report Checklist
- Have you provided a full/minimal spec to reproduce the issue?
- Have you validated the input using an OpenAPI validator?
- Have you tested with the latest master to confirm the issue still exists?
- Have you searched for related issues/PRs?
- What's the actual output vs expected output?
- [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
Serializer generated with useJackson3: true is different from the one generated for Jackson 2: it does not load modules.
Any third-party Jackson 3 module on the classpath is silently ignored. Concrete case: org.openapitools:jackson-databind-nullable:0.2.11 ships META-INF/services/tools.jackson.databind.JacksonModule → JsonNullableJackson3Module, which never gets registered, so JsonNullable fields serialize/deserialize wrongly
openapi-generator version
7.25.0; not a regression, rather a bug in a new feature added in #24709
OpenAPI declaration file content or url
N/A (the bug is in the infrastructure code, not in models)
Generation Details
eneratorName: kotlin
configOptions:
library: jvm-spring-restclient
serializationLibrary: jackson
useSpringBoot3: true
useSpringBoot4: true
useJackson3: true
Steps to reproduce
Open <pkg>/infrastructure/Serializer.kt
Actual:
val jacksonObjectMapper: JsonMapper = jsonMapper {
addModule(kotlinModule())
...
}
Expected: parity with the Jackson 2 output, which is generated from the same template with
useJackson3: false
val jacksonObjectMapper: ObjectMapper = jacksonObjectMapper()
.findAndRegisterModules()
...
Related issues/PRs
#24709
Suggest a fix
Change kotlin-client/jvm-common/infrastructure/Serializer.kt.mustache; add findAndAddModules() as the first line of the {{#useJackson3}} jsonMapper { … } block.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- Avg merge
- 1d 10h
- Merged PRs (30d)
- 103
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from OpenAPITools/openapi-generator
-
Issue: Bug
Difficulty 1/5 Under an hour Newbie friendliness 91/100
OpenAPITools/openapi-generator#24978 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
OpenAPITools/openapi-generator#24975 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
OpenAPITools/openapi-generator#24852 · 1 comment ·
-
[BUG][KOTLIN] Fails to compile after updating to 7.25.0 with useJackson3=false useSpringBoot4=true OpenIssue: Bug
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
OpenAPITools/openapi-generator#24842 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
OpenAPITools/openapi-generator#24830 ·
All issues in OpenAPITools/openapi-generator
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
infinispan/infinispan#18150 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
-
untriaged
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
opensearch-project/k-NN#3597 ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100