OpenAPITools / OpenAPITools/openapi-diff

Unify Handling of allOf/anyOf and oneOf in Diff logic

Đang mở
#772 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

enhancement
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

Mô tả

Current Behavior:

The diffing mechanism currently handles allOf/anyOf and oneOf differently within composed schemas:

  1. allOf/anyOf: These schemas are recursively resolved and their properties are merged into the parent schema before the main diffing occurs. This happens in SchemaDiff#resolveComposedSchema, where properties from allOf/anyOf subschemas are added to the parent using SchemaDiff#addSchema. The original allOf/anyOf structure is effectively flattened.

  2. oneOf: These schemas are not merged beforehand. Instead, the ComposedSchemaDiffResult#diff method performs a structural comparison of the oneOf lists between the old and new schemas. It identifies added, removed, or changed oneOf options, storing the results in a ChangedOneOfSchema object which is then attached to the ChangedSchema.

Suggested Behavior:

This difference in processing leads to an inconsistency. While the merging for allOf/anyOf simplifies property comparison later, it loses the structural information about changes within the allOf/anyOf lists. Conversely, oneOf retains this structural information because it's crucial for understanding changes in available options.

Consider unifying the approach. Perhaps allOf/anyOf could also be compared structurally, similar to oneOf, to provide a more consistent and potentially more informative diff result regarding the composition itself, rather than just the flattened outcome. This would allow tracking additions, removals, or modifications within allOf/anyOf lists directly.

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. 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.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Bắt đầu với SchemaDiff#resolveComposedSchema và SchemaDiff#addSchema để hiểu cách allOf/anyOf được làm phẳng, sau đó đọc ComposedSchemaDiffResult#diff và ChangedOneOfSchema để xem cách so sánh oneOf hiện có. Xác định cách các phần tử được thêm, xóa và sửa đổi về mặt cấu trúc trong allOf/anyOf cần xuất hiện cùng với các thay đổi thuộc tính đã được làm phẳng; hoàn tất khi diff báo cáo nhất quán các thay đổi về composition mà không làm mất các chi tiết liên quan.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
java
Lĩnh vực
api
Loại issue
Tính năng
Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
35/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.