pb33f / openapi-changes

The world's sexiest OpenAPI breaking changes detector. Discover what changed between two OpenAPI specs, or a single spec over time. Supports OpenAPI 3.1, 3.0 and Swagger
https://pb33f.io/openapi-changes/
Other
180 stars 16 forks source link

[Bug] Do not detect breaking change #160

Open Ulashlo opened 1 month ago

Ulashlo commented 1 month ago

Under certain conditions, breaking change is not detected:

Schema old.json: old.json

Schema new.json: new.json

The difference:

Expected results: 3 changes, one breaking change:

Actual result:

openapi-changes report ./old.json ./new.json
{
  "reportSummary": {
    "components": {
      "totalChanges": 2,
      "breakingChanges": 0
    }
  },
  "changes": [
    {
      "breaking": false,
      "change": 3,
      "changeHash": "VMePO-HloQp2n7CFp8rj0EV60TIPsQ1RneJRnwpYTAA=",
      "changeText": "object_added",
      "context": {
        "newColumn": 11,
        "newLine": 80
      },
      "new": "test",
      "original": "",
      "property": "properties"
    },
    {
      "breaking": false,
      "change": 3,
      "changeHash": "AGK7dojIA4fx7E_gkgJ0KP-J9YZpNyct28IjRbaO3vE=",
      "changeText": "object_added",
      "context": {
        "newColumn": 11,
        "newLine": 77
      },
      "new": "testResultType",
      "original": "",
      "property": "properties"
    }
  ],
  "commitDetails": {
    "commitHash": "18a46e",
    "message": "New: ./new.json, Original: ./old.json",
    "author": "",
    "authorEmail": "",
    "committed": "2024-09-18T16:09:28.656168054+03:00",
    "changeReport": null
  }
}

If we just rename field resultType to testResultType, we will have correct result with breaking change:

openapi-changes report ./old.json ./new.json
{
  "reportSummary": {
    "components": {
      "totalChanges": 2,
      "breakingChanges": 1
    }
  },
  "changes": [
    {
      "breaking": false,
      "change": 3,
      "changeHash": "AGK7dojIA4fx7E_gkgJ0KP-J9YZpNyct28IjRbaO3vE=",
      "changeText": "object_added",
      "context": {
        "newColumn": 11,
        "newLine": 77
      },
      "new": "testResultType",
      "original": "",
      "property": "properties"
    },
    {
      "breaking": true,
      "change": 4,
      "changeHash": "0wYw40wu77CMYJOvUyA6ov1L3B6lIoODPxmyNkK2iw8=",
      "changeText": "object_removed",
      "context": {
        "originalColumn": 11,
        "originalLine": 77
      },
      "new": "",
      "original": "resultType",
      "property": "properties"
    }
  ],
  "commitDetails": {
    "commitHash": "4246ba",
    "message": "New: ./new.json, Original: ./old.json",
    "author": "",
    "authorEmail": "",
    "committed": "2024-09-18T16:15:33.685694174+03:00",
    "changeReport": null
  }
}