Changing response field type from `oneOf: string, number` to `string` shouldn't break
还没有人认领这个 Issue。
评估
调研方向
从提供的 base.yml 和 revision.yml 文件开始,运行 openapi-diff breaking base.yml revision.yml 以复现报告的兼容性结果。跟踪响应属性 id 的模式比较路径,然后添加覆盖测试,表明将 oneOf 收窄为 type: integer 会被接受,并且不会报告破坏性变更结果。
由索引模型根据 Issue 内容生成。
描述
Describe the bug
In the response body, if you change the following field:
content:
application/json:
schema:
properties:
id:
oneOf:
- type: integer
- type: string
required:
- id
type: object
to:
content:
application/json:
schema:
properties:
id:
type: integer
required:
- id
type: object
Then openapi-diff reports this as a breaking change.
To Reproduce
base.yml
openapi: 3.0.1
info:
title: User Service
version: 1.0.0
paths:
/users:
post:
requestBody:
content:
application/json:
schema:
type: object
properties:
name:
type: integer
required:
- name
required: true
responses:
201:
description: Created
content:
application/json:
schema:
properties:
id:
oneOf:
- type: integer
- type: string
required:
- id
type: object
revision.yml
openapi: 3.0.1
info:
title: User Service
version: 1.0.0
paths:
/users:
post:
requestBody:
content:
application/json:
schema:
type: object
properties:
name:
type: integer
required:
- name
required: true
responses:
201:
description: Created
content:
application/json:
schema:
properties:
id:
type: integer
required:
- id
type: object
- Download the two files base.yml and revision.yml
- Run
openapi-diff breaking base.yml revision.yml - Observe the following output:
==========================================================================
== API CHANGE LOG ==
==========================================================================
User Service
--------------------------------------------------------------------------
-- What's Changed --
--------------------------------------------------------------------------
- POST /users
Return Type:
- Changed 201 Created
Media types:
- Changed application/json
Schema: Broken compatibility
Changed property type: id (object -> integer)
--------------------------------------------------------------------------
-- Result --
--------------------------------------------------------------------------
API changes broke backward compatibility
--------------------------------------------------------------------------
Expected behavior
openapi-diff shouldn't mark this as a breaking change. Actually, the response body should be considered as a covariant contract: narrowing a field type isn't a breaking change.
- 主要语言
- Java
- 星标
- 1.1k
- 派生
- 190
- PR 合并指标
- 30 天内没有已合并 PR
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
OpenAPITools/openapi-diff 的其他 Issue
-
enhancement
难度 2/5 1-3 小时 新手友好度 68/100
OpenAPITools/openapi-diff#506 ·
-
good first issue help wanted
难度 2/5 1-3 小时 新手友好度 68/100
OpenAPITools/openapi-diff#364 ·
-
bug OpenAP 3.1.0 Support
难度 3/5 1-2 天 新手友好度 68/100
OpenAPITools/openapi-diff#910 · 1 条评论 ·
-
Render capabilities
难度 3/5 1-2 天 新手友好度 55/100
OpenAPITools/openapi-diff#893 · 1 条评论 ·
-
Breaking/Non-Breaking classification
难度 3/5 1-2 天 新手友好度 55/100
OpenAPITools/openapi-diff#886 ·
查看 OpenAPITools/openapi-diff 的全部 Issue
相似的 Issue
-
awaiting triage bug Causes friction Hop Gui P1 P2 Transforms
难度 2/5 1-3 小时 新手友好度 75/100
-
难度 2/5 1-3 小时 新手友好度 75/100
apache/flink-agents#1152 ·
-
难度 2/5 1-3 小时 新手友好度 75/100
-
难度 2/5 1-3 小时 新手友好度 70/100
jenkinsci/blueocean-plugin#5417 ·
-
难度 2/5 1-3 小时 新手友好度 75/100
objectionary/eo-graphs#75 ·