Skip to content

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

Closed

Description

@pkubowicz

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

7.25.0 breaks backward compatibility, by force-setting useJackson3=true for Spring 4 and jvm-spring-restclient

It's incorrect to enforce Jackson 3 with those settings: Spring 4.0 and 4.1 work with Jackson 2, it's just deprecated. RestClient still works with Jackson 2.

openapi-generator version

7.25.0, it's a regression compared to 7.24.0

OpenAPI declaration file content or url
Generation Details

See 'steps to reproduce'

Steps to reproduce

I only generate sources and use my own build.gradle.kts, throwing away generator's one.

dependencies {
    api(platform("org.springframework.boot:spring-boot-dependencies:4.0.8"))

    api("org.springframework:spring-web")

    // api because Serializer.jacksonObjectMapper is public
    api("com.fasterxml.jackson.core:jackson-databind")
    api("org.openapitools:jackson-databind-nullable:0.2.11")
    implementation("com.fasterxml.jackson.module:jackson-module-kotlin")
}

openApiGenerate {
    configOptions.set(
        mapOf(
            "omitGradleWrapper" to "true",
            "library" to "jvm-spring-restclient",
            "useSpringBoot3" to "true",
            "useSpringBoot4" to "true",
            "useJackson3" to "false",
            "serializationLibrary" to "jackson",
        )
    )
}

What complied with 7.24.0, fails to compile in 7.25.0 because Serializer.kt is now:

import tools.jackson.databind.DeserializationFeature
import tools.jackson.databind.json.JsonMapper
import tools.jackson.databind.cfg.DateTimeFeature
import com.fasterxml.jackson.annotation.JsonInclude
import tools.jackson.module.kotlin.jsonMapper
import tools.jackson.module.kotlin.kotlinModule

object Serializer {
    @JvmStatic
    val jacksonObjectMapper: JsonMapper = jsonMapper {
        addModule(kotlinModule())
        changeDefaultPropertyInclusion { it.withValueInclusion(JsonInclude.Include.NON_ABSENT) }
        disable(DateTimeFeature.WRITE_DATES_AS_TIMESTAMPS)
        disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES)
    }
}

Because I explicitly set useJackson3=false, the generated code should import com.fasterxml.jackson

Related issues/PRs

#24709

Suggest a fix

Remove the addition of setUseJackson3(true) as pointed out in https://github.com/OpenAPITools/openapi-generator/pull/24709/changes#r3917417022

Activity

  1. Picazsoo commented on Sep 2, 2026

    @Picazsoo
    Contributor

    I agree with your analysis. The fix should be to set useJackson3=true as the default when useSpringBoot4=true, while still respecting any explicit user configuration. This way:

    1. Projects using Spring Boot 4 that want Jackson 3 get it by default
    2. Users who prefer Jackson 2 can explicitly set useJackson3=false to opt-out
    3. Any explicit user setting is honored, whether true or false

    The current behavior of forcing useJackson3=true and ignoring the user's explicit useJackson3=false setting breaks backward compatibility. The generated code should match what the user requests, not override it.

  2. pkubowicz commented on Oct 7, 2026

    @pkubowicz
    ContributorAuthor

    Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions