Skip to content

Crash if inherited property is structurally equal but not reference identical #482

Description

If a definition defines a property, and inherits from another definition that also defines the property:

  • If the properties are reference identical, it's allowed
  • If the properties are equivalent (but not reference identical), the tool crashes

Organic PRs hitting problem

Test Cases

Pass - Reference Identical

{
  "swagger": "2.0",
  "info": {
    "title": "structural-equality",
    "version": "1.0"
  },
  "paths": {},
  "definitions": {
    "Foo": {
      "type": "object",
      "properties": {
        "bar": {
          "$ref": "#/definitions/MyObject"
        }
      },
      "allOf": [
        {
          "$ref": "#/definitions/Foo2"
        }
      ]
    },
    "Foo2": {
      "type": "object",
      "properties": {
        "bar": {
          "$ref": "#/definitions/MyObject"
        }
      }
    },
    "MyObject": {
      "type": "object",
      "additionalProperties": {
        "type": "string"
      }
    }
  }
}

Fail - Structurally Equal

{
  "swagger": "2.0",
  "info": {
    "title": "structural-equality",
    "version": "1.0"
  },
  "paths": {},
  "definitions": {
    "Foo": {
      "type": "object",
      "properties": {
        "bar": {
          "type": "object",
          "additionalProperties": {
            "type": "string"
          }
        }
      },
      "allOf": [
        {
          "$ref": "#/definitions/Foo2"
        }
      ]
    },
    "Foo2": {
      "type": "object",
      "properties": {
        "bar": {
          "type": "object",
          "additionalProperties": {
            "type": "string"
          }
        }
      }
    }
  }
}

Error

    incompatible properties : bar
      definitions/Foo/properties/bar
        at file:///home/mharder/openapi-diff-mh/incompat-prop/src/test/specs/incompatible-properties/structural-equality-fail.json#L12:8
      definitions/Foo2/properties/bar
        at file:///home/mharder/openapi-diff-mh/incompat-prop/src/test/specs/incompatible-properties/structural-equality-fail.json#L28:8

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions