OpenAPITools / OpenAPITools/openapi-generator

[BUG] [Elm] Outputs duplicate types, as well as overlapping types with same name

オープン
#13,653 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

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

Issue: Bug
主要言語
Java
スター
26.8k
フォーク
7.7k
PR マージ指標
PR 指標を取得中

説明

Bug Report Checklist
  • Have you provided a full/minimal spec to reproduce the issue?
  • Using the full Stripe API spec.

  • Have you validated the input using an OpenAPI validator (example)?
  • I used the CLI with validate and it found no issues.

  • Have you tested with the latest master to confirm the issue still exists?
  • Yes

  • Have you searched for related issues/PRs?
  • What's the actual output vs expected output?
Description
openapi-generator version

Latest master

OpenAPI declaration file content or url

https://raw.githubusercontent.com/stripe/openapi/master/openapi/spec3.json

Generation Details
java -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar generate    -i https://raw.githubusercontent.com/stripe/openapi/master/openapi/spec3.json    -g elm    -o ./elm-stripeFix

All in the same file, there will be this Status:

type Status
    = StatusActive
    | StatusBlocked
    | StatusInactive


statusVariants : List Status
statusVariants =
    [ StatusActive
    , StatusBlocked
    , StatusInactive
    ]


stringFromStatus : Status -> String
stringFromStatus model =
    case model of
        StatusActive ->
            "active"

        StatusBlocked ->
            "blocked"

        StatusInactive ->
            "inactive"

...right along with this Status somewhere else:

type Status
    = StatusExpired
    | StatusLost
    | StatusSubmitted
    | StatusUnsubmitted
    | StatusWon


statusVariants : List Status
statusVariants =
    [ StatusExpired
    , StatusLost
    , StatusSubmitted
    , StatusUnsubmitted
    , StatusWon
    ]


stringFromStatus : Status -> String
stringFromStatus model =
    case model of
        StatusExpired ->
            "expired"

        StatusLost ->
            "lost"

        StatusSubmitted ->
            "submitted"

        StatusUnsubmitted ->
            "unsubmitted"

        StatusWon ->
            "won"


Obviously this causes a conflict, and fixing it is not trivial as all references to Status are now ambiguous.

Suggest a fix

Ideally, have types belonging to different domains go in separate type modules.

At the least, add a number or underscore to the end of one of them if need be.

Naive fix would be to merge the enums and just treat them as one.

Also, this includes totally identical types and encoder/decoders. They can have everything exactly the same, and still be repeated 5 different places in the file.

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

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

調査の方向性

レポートに示されている Stripe OpenAPI 仕様と Elm 生成コマンドを使って問題を再現し、その後、生成された Elm 出力を調べて重複する型や衝突する型を確認します。生成された型とそのエンコーダー、デコーダー、参照が互いに競合せず、同一の定義が繰り返されなければ完了です。

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

評価

技術スタック
elm, openapi
領域
api, tooling
issue の種類
バグ
難易度
5/5
見積もり時間
1週間以上
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
30/100

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

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