ExpandAllOf() throws "incompatible properties" if schemas are compatible but not equal
@mikeharder がすでに取り組んでいます。
2024年12月3日 から。
評価
この issue はまだ評価されていません。
説明
The following spec should be valid per JSON Schema and Swagger. However, we throw error incompatible properties when trying to process it, since DogOwner.pet is type Dog, which is compatible with but not equal to PetOwner.pet of type Pet.
@JeffreyRichter, @mikekistler: Do you think the code should be changed to allow types that are compatible but not equal? If so, should it be conditioned on whether the swagger is handwritten or typespec-generated, under the assumption that SDKs for TypeSpec will be generated directly from TypeSpec and not the intermediate Swagger?
We recently fixed a similar issue in https://github.com/Azure/openapi-diff/pull/329, although in this case the types were identical with just an extra step of indirection.
@markcowl and I believe this is valid swagger, but some of our SDK generators may not handle it correctly, which might be why it's not allowed in openapi-diff. However, openapi-diff should not be responsible for this. It should be tested directly by the SDK generation tests.
Repro Steps
Save spec below to file test.json, then run npx @azure/oad test.json test.json.
Error: incompatible properties : pet
definitions/DogOwner/properties/pet
at file:///home/mharder/tmp/oad/test.json#L61:8
definitions/PetOwner/properties/pet
at file:///home/mharder/tmp/oad/test.json#L53:8
{
"swagger": "2.0",
"info": {
"version": "1.0.0",
"title": "title",
},
"paths": {
},
"definitions": {
"Pet": {
"type": "object",
"properties": {
"name": {
"type": "string"
}
}
},
"Dog": {
"type": "object",
"properties": {
"bones": {
"type": "integer"
}
},
"allOf": [{"$ref": "#/definitions/Pet"}]
},
"PetOwner": {
"type": "object",
"properties": {
"ssn": {
"type": "integer"
},
"pet": {
"$ref": "#/definitions/Pet"
}
}
},
"DogOwner": {
"type": "object",
"properties": {
"pet": {
"$ref": "#/definitions/Dog"
}
},
"allOf": [{"$ref": "#/definitions/PetOwner"}]
}
}
}
- 主要言語
- C#
- スター
- 290
- フォーク
- 50
- 平均マージ
- 2日 21時間
- マージ済み PR(30日)
- 10
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
Azure/openapi-diff のほかの issue
-
Azure/openapi-diff#482 · 担当者 1 名 ·
-
Azure/openapi-diff#479 · コメント 2 件 · 担当者 1 名 ·
-
Azure/openapi-diff#456 · 担当者 1 名 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
Azure/openapi-diff#445 ·
-
Azure/openapi-diff#371 · コメント 7 件 · 担当者 1 名 ·
Azure/openapi-diff の issue をすべて見る
似ている issue
-
Documentation
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
cake-build/cake#5024 ·
-
Frontend status/draft TechnicalDebt
難易度 2/5 1〜2日 初心者へのやさしさ 75/100
Altinn/altinn-auth#4143 ·
-
.NET Flaky Test Testing Tests
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
getsentry/sentry-dotnet#5617 · コメント 1 件 ·
-
:watch: Not Triaged dotnet-fsharp/svc
難易度 1/5 1時間未満 初心者へのやさしさ 90/100
-
Client customer-reported needs-team-attention question Service Attention WebPubSub
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
Azure/azure-sdk-for-net#63292 · コメント 3 件 · リアクション 1 件 ·