Property `type` change on referenced component schema is silently ignored
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 68/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Ít trao đổi
- Công nghệ
- java
- Lĩnh vực
- api, backend-api-design
Hướng nghiên cứu
Bắt đầu từ OpenApiCompare.fromContents và fromSpecifications, sử dụng reproduction old.yaml/new.yaml được cung cấp với ParseOptions.setResolveFully(true). Theo dõi cách ChangedOpenApi ghi nhận các thay đổi của schema được tham chiếu và vị trí Schema.getType()/getTypes() được so sánh. Được xem là hoàn tất khi thay đổi weight từ integer thành string tạo ra kết quả changedOperations hoặc changedSchemas không rỗng với một mục INCOMPATIBLE, trong khi các thay đổi của required và enum vẫn được phát hiện.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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.
- Ngôn ngữ chính
- Java
- Star
- 1.1k
- Fork
- 190
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của OpenAPITools/openapi-diff
-
enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
OpenAPITools/openapi-diff#506 ·
-
good first issue help wanted
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
OpenAPITools/openapi-diff#364 ·
-
Render capabilities
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 55/100
OpenAPITools/openapi-diff#893 · 1 bình luận ·
-
Breaking/Non-Breaking classification
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 55/100
OpenAPITools/openapi-diff#886 ·
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
OpenAPITools/openapi-diff#883 ·
Tất cả issue của OpenAPITools/openapi-diff
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
elastic/gradle-plugins#157 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
cryptomator/hub#497 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
johanhaleby/occurrent#1120 ·