Changing request field type from `string` to `oneOf: string, number` shouldn't break
まだ誰も着手していません。
評価
調査の方向性
base.yml と revision.yml を使い、openapi-diff base.yml revision.yml でレポートを再現してから、name プロパティに対するリクエストボディスキーマの互換性処理を追跡します。integer から integer と string を含む oneOf に変更しても、breaking change として表示されなくなれば完了です。
索引モデルが issue の本文から書いたものです。
説明
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.
- 主要言語
- Java
- スター
- 1.1k
- フォーク
- 190
- PR マージ指標
- 30日以内にマージされた PR はありません
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- 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
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
elastic/gradle-plugins#157 ·
-
enhancement Tools
難易度 1/5 1時間未満 初心者へのやさしさ 75/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
apache/rocketmq-dashboard#5008 ·
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
-
DETECT_PARAMETER_NAMES=false silently disables @ConstructorProperties-based Creator detection too オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
FasterXML/jackson-databind#6229 ·