Azure / openapi-diff

Command line tool to detect breaking changes between two openapi specifications
MIT License
253 stars 34 forks source link

Error "incompatible properties" for properties compatible via $ref #331

Closed mikeharder closed 2 months ago

mikeharder commented 2 months ago

The two bar properties should be considered compatible, because the types are effectively identical (one just flows through an extra $ref):

"FooBarString": {
  "type":"object",
  "properties": {
    "bar": {
      "type":"string"
    }
  },
  "allOf": [
    {
      "$ref": "#/definitions/FooBarStringRef"
    }
  ]
},
"FooBarStringRef": {
  "type":"object",
  "properties": {
    "bar": {
      "$ref":"#/definitions/MyString"
    }
  }
},
"MyString": {
  "type": "string"
}

Instead they generate an error:

    incompatible properties : bar
      definitions/FooBarString/properties/bar
        at file:///mnt/vss/_work/1/s/src/test/specs/compatible-properties-ref.json#L13:8
      definitions/FooBarStringRef/properties/bar
        at file:///mnt/vss/_work/1/s/src/test/specs/compatible-properties-ref.json#L26:8