openapi-diff icon indicating copy to clipboard operation
openapi-diff copied to clipboard

Deleted or renamed properties are marked as backwards compatible

Open Patrick-Bayer opened this issue 1 year ago • 6 comments

Hello folks,

i am testing your library as a maven plugin with version: 'org.openapitools.openapidiff:openapi-diff-core:2.1.0-beta.11' and discovered that the following changes do not result in failure due to backwards incompatibility even though they should, right?

  1. Removing properties from schemas
  2. Renaming properties

Patrick-Bayer avatar Jun 14 '24 12:06 Patrick-Bayer

Hello @Patrick-Bayer , I am facing same issue.

Sanady avatar Jul 18 '24 12:07 Sanady

Hello folks, mostly all incompatibility rules are collected in BackwardIncompatibleProp. As you can see it has:

  • RESPONSE_REQUIRED_DECREASED
  • REQUEST_BODY_REQUIRED_INCREASED.

Seems, author decided to only treat new required props on request and missing required props on response as incompatible. So it depends on the point of view. From my perspective - removing any payload property is a breaking change as API consumer can depend on it.

So the openapi-diff as a library should be smart enough to allow to configure of what is considered compatible change, and what is not. This behavior is configurable through the config file, but frankly speaking, it does not cover all possible cases. Good point to extend and review all the rules.

DrSatyr avatar Jan 24 '25 17:01 DrSatyr

BTW - REQUEST_BODY_REQUIRED_INCREASED is never used. Looks like a bug.

DrSatyr avatar Jan 24 '25 17:01 DrSatyr

Is there an update on this issue? I am also facing the same issue where a compatibility break in terms of schema change in response doesn't mark the diff as incompatible. Below is the example -

Original Spec

openapi: "3.0.0"
info:
  title: Sample API
  version: "1.0.0"
paths:
  /users:
    get:
      summary: Get all users
      responses:
        "200":
          description: A list of users
          content:
            application/json:
              schema:
                type: array
                items:
                  type: object
                  properties:
                    id:
                      type: string
                    name:
                      type: string

Updated spec

openapi: "3.0.0"
info:
  title: Sample API
  version: "2.0.0"
paths:
  /users:
    get:
      summary: Get all users
      responses:
        "200":
          description: A list of users
          content:
            application/json:
              schema:
                type: array
                items:
                  type: object
                  properties:
                    id:
                      type: string
                    fullname:  # Breaking change (renamed `name` → `fullname`)
                      type: string

This looks like a bug to me, but let me know if there is a configuration which would evaluate this diff as incompatible.

nakulshukla08 avatar Feb 25 '25 23:02 nakulshukla08

@nakulshukla08 there is an idea to solve this problem within the scope of discussion. But the first priority at the moment is to get 2.1.0 release happen.

Anyway, any contributions to discussion and related issues are appreciated, feel free to contribute.

DrSatyr avatar Feb 26 '25 13:02 DrSatyr

This bug is pretty bad, any update on it?

VictorPascualV avatar Jul 02 '25 12:07 VictorPascualV