Setting dateLibrary=java11 fails to map "java.time" types

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

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

評価

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

調査の方向性

AbstractJavaCodegen.java の 488~515 行付近を読み、その後 processOpts() と既存の dateLibrary 分岐を調べてください。java11 オプションの説明と、関連する日付ライブラリのマッピングおよび import の設定方法を確認してください。dateLibrary=java11 を選択すると、別途 java11=true オプションを指定しなくても、期待される java.time のマッピングと import が設定されれば完了です。

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

説明

https://github.com/swagger-api/swagger-codegen-generators/blob/master/src/main/java/io/swagger/codegen/v3/generators/java/AbstractJavaCodegen.java#L488-L515

In the above source code of AbstractJavaCodegen, the dateLibrary enum registers "java11" in the CLI options list. However, the processOpts() method only checks for "threetenbp", "joda", dateLibrary.startsWith("java8"), and "legacy":
• Missing if branch. Because there is no else if ("java11".equals(dateLibrary)) block in AbstractJavaCodegen.processOpts(), the generator skips setting up java.time type mappings and imports.
• Fallback to java.util.Date. By default, AbstractJavaCodegen initializes typeMapping.put("date", "Date"), which resolves to java.util.Date when no dateLibrary branch overrides it.
• Flag discrepancy. Although the CLI description claims "java11" automatically sets java11=true, the code only reads java11 if you explicitly pass true in your configuration.

This leads to the required strange combination of configuration options:

<configOptions>
    <!-- don't use "java11" - a bug in swagger lets this fall back to "legacy" -->
    <dateLibrary>java8</dateLibrary>
    <java11>true</java11>
    <jakarta>true</jakarta>
</configOptions>
主要言語
Mustache
スター
299
フォーク
439
PR マージ指標
30日以内にマージされた PR はありません

環境構築

はじめの一歩

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

swagger-api/swagger-codegen-generators のほかの issue

swagger-api/swagger-codegen-generators の issue をすべて見る

似ている issue

Backend & API Design の issue をもっと見る

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

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