OpenAPITools / OpenAPITools/openapi-diff

ChangedSchema in a readOnly property for requestBody is not filtered out from the result.

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

还没有人认领这个 Issue。

主要语言
Java
星标
1.1k
派生
190
PR 合并指标
30 天内没有已合并 PR

描述

Old API
{
  "openapi":"3.0.0",
  "info":{
    "title":"API",
    "version":"0.1.0"
  },
  "paths":{
    "/resource":{
      "post":{
        "responses":{
          "200":{
            "description":"Created resource",
            "content":{
              "application/json":{
                "schema":{
                  "$ref":"#/components/schemas/CreateResourceResponse"
                }
              }
            }
          }
        },
        "summary":"Create resource",
        "requestBody":{
          "content":{
            "application/json":{
              "schema":{
                "$ref":"#/components/schemas/CreateResourceRequest"
              }
            }
          },
          "description":"Definition of the resource"
        }
      }
    }
  },
  "components": {
    "schemas": {
      "CreateResourceResponse": {
        "type": "object",
        "properties": {
          "resources": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        }
      },
      "CreateResourceRequest": {
        "type": "object",
        "properties": {
          "foo": {
            "$ref": "#/components/schemas/Foo"
          }
        }
      },
      "Foo": {
        "type": "object",
        "properties": {
          "bar": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Bar"
            },
            "readOnly": true
          }
        }
      },
      "Bar": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string"
          }
        }
      }
    }
  }
}
New API
{
  "openapi":"3.0.0",
  "info":{
    "title":"API",
    "version":"0.1.0"
  },
  "paths":{
    "/resource":{
      "post":{
        "responses":{
          "200":{
            "description":"Created resource",
            "content":{
              "application/json":{
                "schema":{
                  "$ref":"#/components/schemas/CreateResourceResponse"
                }
              }
            }
          }
        },
        "summary":"Create resource",
        "requestBody":{
          "content":{
            "application/json":{
              "schema":{
                "$ref":"#/components/schemas/CreateResourceRequest"
              }
            }
          },
          "description":"Definition of the resource"
        }
      }
    }
  },
  "components": {
    "schemas": {
      "CreateResourceResponse": {
        "type": "object",
        "properties": {
          "resources": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        }
      },
      "CreateResourceRequest": {
        "type": "object",
        "properties": {
          "foo": {
            "$ref": "#/components/schemas/Foo"
          }
        }
      },
      "Foo": {
        "type": "object",
        "properties": {
          "bar": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Bar"
            },
            "readOnly": true
          }
        }
      },
      "Bar": {
        "type": "object",
        "properties": {
          "name": {
            "type": "integer"
          }
        }
      }
    }
  }
}

In this example, the property bar in Foo schema is a readOnly property and Foo is referenced by request body of the endpoint.
When Bar schema is changed, it's filtered out from the request body but the change exists in the list of ChangedSchema in ChangedOpenApi, which results incompatible changes but shows nothing.

==========================================================================
==                            API CHANGE LOG                            ==
==========================================================================
                                   API                                    
--------------------------------------------------------------------------
--                                Result                                --
--------------------------------------------------------------------------
                 API changes broke backward compatibility                 
--------------------------------------------------------------------------

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

首先使用 Old API 和 New API 示例重现该问题,重点关注请求体中 readOnly bar 属性的 ChangedSchema 和 ChangedOpenApi 结果。跟踪已更改的 Bar schema 如何从请求体兼容性检查中过滤掉,但仍保留在 ChangedSchema 中;完成的标准是,最终的变更列表和兼容性输出不再报告该已过滤的变更。

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

评估

技术栈
java
领域
api, backend-api-design
Issue 类型
缺陷
难度
4/5
预计耗时
3-5 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
48/100

把新 issue 发到你的邮箱

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