Azure / Azure/openapi-diff

Crash if inherited property is structurally equal but not reference identical

未关闭
#482 0 条评论 0 个 reaction 已指派 1 人 已被 @mikeharder 认领 在 GitHub 查看
主要语言
C#
星标
290
派生
50
平均合并
5 天 13 小时
30 天内合并 PR
5

描述

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
- https://github.com/Azure/azure-rest-api-specs/actions/runs/25541171453

## Test Cases

- https://github.com/Azure/openapi-diff/pull/481

### Pass - Reference Identical

```json
{
"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
```json
{
"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
```

贡献指南

打开贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。