Property `type` change on referenced component schema is silently ignored
還沒有人認領這個 Issue。
評估
- 難度
- 3/5
- 預估耗時
- 1-2 天
- 新手友好度
- 68/100
- Issue 類型
- 缺陷
- 描述清晰度
- 描述清楚
- 活躍度
- 冷清
- 技術堆疊
- java
研究方向
從 OpenApiCompare.fromContents 和 fromSpecifications 開始,使用提供的 old.yaml/new.yaml 重現案例,並設定 ParseOptions.setResolveFully(true)。追蹤 ChangedOpenApi 如何記錄被參照 schema 的變更,以及在哪裡比較 Schema.getType()/getTypes()。完成的標準是:將 weight 從 integer 變更為 string 後,產生非空的 changedOperations 或 changedSchemas 結果,並包含一個 INCOMPATIBLE 項目,同時仍能偵測到 required 和 enum 的變更。
由索引模型根據 Issue 內容生成。
描述
Library version: org.openapitools.openapidiff:openapi-diff-core:2.1.7
Java: 21
OpenAPI version of test specs: 3.1.0 (also reproduces on 3.0.x)
Summary
When the only difference between two specs is a type change on a property of a referenced component schema, OpenApiCompare.fromContents reports zero changes. Both getChangedOperations() and getChangedSchemas() are empty. Other property-level changes (required list deltas, enum value deltas) on the same referenced schema are detected normally — only type swaps are dropped.
Minimal reproduction
old.yaml:
openapi: 3.1.0
info:
title: t
version: '1'
paths:
/widgets:
get:
responses:
'200':
description: ok
content:
application/json:
schema:
$ref: '#/components/schemas/Widget'
components:
schemas:
Widget:
type: object
properties:
weight:
type: integer
new.yaml — identical except for weight.type:
openapi: 3.1.0
info:
title: t
version: '1'
paths:
/widgets:
get:
responses:
'200':
description: ok
content:
application/json:
schema:
$ref: '#/components/schemas/Widget'
components:
schemas:
Widget:
type: object
properties:
weight:
type: string
import org.openapitools.openapidiff.core.OpenApiCompare;
import org.openapitools.openapidiff.core.model.ChangedOpenApi;
import java.nio.file.*;
public class Repro {
public static void main(String[] a) throws Exception {
String prev = Files.readString(Path.of("old.yaml"));
String curr = Files.readString(Path.of("new.yaml"));
ChangedOpenApi d = OpenApiCompare.fromContents(prev, curr);
System.out.println("missingEndpoints: " + d.getMissingEndpoints().size());
System.out.println("newEndpoints: " + d.getNewEndpoints().size());
System.out.println("changedOperations:" + d.getChangedOperations().size());
System.out.println("changedSchemas: " + d.getChangedSchemas().size());
}
}
Actual output
missingEndpoints: 0
newEndpoints: 0
changedOperations:0
changedSchemas: 0
Expected output
A non-empty changedOperations (or changedSchemas) containing an INCOMPATIBLE entry for the property weight on Widget.
Other findings
- Reproduces with
OpenAPIParser+ParseOptions.setResolveFully(true)andOpenApiCompare.fromSpecifications(...). - Inverting the spec versions (3.1.0 ↔ 3.0.3) does not change the result.
- The same fixture with a
required:list change instead (e.g. addingweighttorequired) is detected correctly —changedOperationsandchangedSchemasare populated. So the parser does diff the referenced schema; only thetypefield is being skipped. - As a workaround, walking the resolved
Schematree manually aftersetResolveFully(true)and comparingSchema.getType()/Schema.getTypes()recovers the change.
Happy to put up a PR if pointers to where the schema-type comparator lives would help.
- 主要語言
- Java
- 星號
- 1.1k
- 分支
- 190
- PR 合併指標
- 30 天內沒有已合併 PR
環境準備
- 提供 Dockerfile 或 Docker Compose 檔案
- 沒有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
OpenAPITools/openapi-diff 的其他 Issue
-
enhancement
難度 2/5 1-3 小時 新手友好度 68/100
OpenAPITools/openapi-diff#506 ·
-
good first issue help wanted
難度 2/5 1-3 小時 新手友好度 68/100
OpenAPITools/openapi-diff#364 ·
-
Render capabilities
難度 3/5 1-2 天 新手友好度 55/100
OpenAPITools/openapi-diff#893 · 1 則留言 ·
-
[Bug] Backward compatibility check fails on reordered discriminator mappings可能已有人在做 @MoChiUaena 於 8 天前認領。 未關閉Breaking/Non-Breaking classification
難度 3/5 1-2 天 新手友好度 55/100
OpenAPITools/openapi-diff#886 ·
-
難度 5/5 一週以上 新手友好度 25/100
OpenAPITools/openapi-diff#883 ·
查看 OpenAPITools/openapi-diff 的全部 Issue
相似的 Issue
-
bug
難度 2/5 1-3 小時 新手友好度 75/100
apache/skywalking#14120 ·
維護者通常 1 天內回覆
-
enhancement
難度 2/5 1-3 小時 新手友好度 75/100
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 85/100
micronaut-projects/micronaut-core#13677 ·
維護者通常 1 天內回覆
-
new feature
難度 2/5 1-3 小時 新手友好度 62/100
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 78/100
apache/rocketmq-dashboard#5594 ·
維護者通常 3 天內回覆