Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

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

オープン 初心者向け
#24,842 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
76/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
kotlin, spring-boot
領域
tooling

調査の方向性

レポートに示されている生成済みの Serializer.kt から始め、提供された Gradle オプションを使って 7.24.0 と 7.25.0 の生成結果を比較します。関連する issue または PR #24709 の変更と議論を確認し、その後、useJackson3=false によって com.fasterxml.jackson の import が生成され、生成されたソースが Spring Boot 4 と Jackson 2 でコンパイルできることを検証します。

索引モデルが issue の本文から書いたものです。

説明

Issue: Bug
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

主要言語
Java
スター
26.8k
フォーク
7.7k
平均マージ
3日 16時間
マージ済み PR(30日)
122

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

OpenAPITools/openapi-generator のほかの issue

OpenAPITools/openapi-generator の issue をすべて見る

似ている issue

Java の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。