-
Notifications
You must be signed in to change notification settings - Fork 166
Open
Open
Copy link
Labels
Breaking/Non-Breaking classificationIssues related to Breaking/Non-Breaking changes classificationIssues related to Breaking/Non-Breaking changes classification
Milestone
Description
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.
Metadata
Metadata
Assignees
Labels
Breaking/Non-Breaking classificationIssues related to Breaking/Non-Breaking changes classificationIssues related to Breaking/Non-Breaking changes classification