OpenAPITools / OpenAPITools/openapi-diff
Changing request field type from `string` to `oneOf: string, number` shouldn't break
オープン
まだ誰も着手していません。
Breaking/Non-Breaking classification
- 主要言語
- Java
- スター
- 1.1k
- フォーク
- 190
- PR マージ指標
- 30日以内にマージされた PR はありません
説明
Describe the bug
In the request body, if you change the following field:
requestBody:
content:
application/json:
schema:
type: object
properties:
name:
type: integer
required:
- name
required: true
to:
requestBody:
content:
application/json:
schema:
type: object
properties:
name:
oneOf:
- type: integer
- type: string
required:
- name
required: true
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:
type: integer
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:
oneOf:
- type: integer
- type: string
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 base.yml revision.yml - Observe the following output:
==========================================================================
== API CHANGE LOG ==
==========================================================================
User Service
--------------------------------------------------------------------------
-- What's Changed --
--------------------------------------------------------------------------
- POST /users
Request:
- Changed application/json
Schema: Broken compatibility
Changed property type: name (integer -> object)
--------------------------------------------------------------------------
-- Result --
--------------------------------------------------------------------------
API changes broke backward compatibility
--------------------------------------------------------------------------
Expected behavior
openapi-diff shouldn't mark this as a breaking change. Actually, the request body should be considered as a contravariant contract: widening a field type isn't a breaking change.
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
base.yml と revision.yml を使い、openapi-diff base.yml revision.yml でレポートを再現してから、name プロパティに対するリクエストボディスキーマの互換性処理を追跡します。integer から integer と string を含む oneOf に変更しても、breaking change として表示されなくなれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- java, openapi
- 領域
- api
- issue の種類
- バグ
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 活発さ
- 停滞
- 明瞭さ
- 明確に書かれている
- 初心者へのやさしさ
- 50/100