OpenAPITools / OpenAPITools/openapi-diff

[Bug] Backward compatibility check fails on reordered discriminator mappings

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

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

Breaking/Non-Breaking classification
主要言語
Java
スター
1.1k
フォーク
190
PR マージ指標
30日以内にマージされた PR はありません

説明

Ran into a compatibility issue, which I believe is a false positive. I have one polymorphic schema, that maps to two different property names. The backwards compatibility check fails if the mappings are re-ordered.

This should not be failing, because neither discriminator names nor the mapping changed.

For example, the following 2 should be considered compatible, but are not. Assume the actual schemas are identical. Schema A is mapped to a-type and z-type which are present in both mappings, but are ordered differently.

             schema:
               oneOf:
                 - $ref: '#/components/schemas/A'
                 - $ref: '#/components/schemas/B'
               discriminator:
                 propertyName: realtype
                 mapping:
                   z-type: '#/components/schemas/A'
                   a-type: '#/components/schemas/A'
                   b-type: '#/components/schemas/B'

and

              schema:
                oneOf:
                  - $ref: '#/components/schemas/A'
                  - $ref: '#/components/schemas/B'
                discriminator:
                  propertyName: realtype
                  mapping:
                    a-type: '#/components/schemas/A'
                    z-type: '#/components/schemas/A'
                    b-type: '#/components/schemas/B'

I was able to reproduce this in this repo by adding a test to OneOfDiffTest with the above as an example (based on oneOf_discriminator-missing_1.yaml).

  @Test
  public void testOneOfDiscrimitatorDifferentOrder() {
    assertOpenApiAreEquals(OPENAPI_DOC11, OPENAPI_DOC12);
  }

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

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

はじめの一歩

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

調査の方向性

既存の OneOfDiffTest と、issue で言及されている oneOf_discriminator-missing_1.yaml の例から始めます。マッピングを並べ替えたケースを追加または実行し、そのケースが通る比較のエントリポイントを追跡します。2 つの示されたスキーマが、discriminator マッピングの順序だけが異なる場合に互換として扱われれば完了です。

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

評価

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

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

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