OpenAPITools / OpenAPITools/openapi-diff
Changing response field type from `oneOf: string, number` to `string` shouldn't break
オープン
まだ誰も着手していません。
Breaking/Non-Breaking classification
- 主要言語
- Java
- スター
- 1.1k
- フォーク
- 190
- PR マージ指標
- 30日以内にマージされた PR はありません
説明
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.
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
提供された base.yml ファイルと revision.yml ファイルから始め、openapi-diff breaking base.yml revision.yml を実行して、報告された互換性結果を再現します。応答プロパティ id のスキーマ比較経路を追跡し、その後、oneOf を type: integer に絞り込むことが受け入れられ、破壊的変更の結果が報告されないことを示すテストカバレッジを追加します。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- java
- 領域
- api
- issue の種類
- バグ
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 48/100