OpenAPITools / OpenAPITools/openapi-diff

[Bug] Backward compatibility check fails on reordered discriminator mappings

未关闭
#886 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

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. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

从现有的 OneOfDiffTest 和 issue 中提到的 oneOf_discriminator-missing_1.yaml 示例开始。添加或运行映射顺序重新排列的用例,然后跟踪该用例所调用的比较入口点。当仅 discriminator 映射顺序不同时,所示的两个 schema 被视为兼容,即表示完成。

由索引模型根据 Issue 内容生成。

评估

技术栈
java
领域
api
Issue 类型
缺陷
难度
3/5
预计耗时
1-2 天
活跃度
停滞
描述清晰度
描述清楚
新手友好度
55/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。