OpenAPITools / OpenAPITools/openapi-diff

[Bug] Backward compatibility check fails on reordered discriminator mappings

Đang mở
#886 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.

Breaking/Non-Breaking classification
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ả

Ran into a compatibility issue, which I believe is a false positive. I have one polymorphic schema, that maps to two different property names. The backwards compatibility check fails if the mappings are re-ordered.

This should not be failing, because neither discriminator names nor the mapping changed.

For example, the following 2 should be considered compatible, but are not. Assume the actual schemas are identical. Schema A is mapped to a-type and z-type which are present in both mappings, but are ordered differently.

             schema:
               oneOf:
                 - $ref: '#/components/schemas/A'
                 - $ref: '#/components/schemas/B'
               discriminator:
                 propertyName: realtype
                 mapping:
                   z-type: '#/components/schemas/A'
                   a-type: '#/components/schemas/A'
                   b-type: '#/components/schemas/B'

and

              schema:
                oneOf:
                  - $ref: '#/components/schemas/A'
                  - $ref: '#/components/schemas/B'
                discriminator:
                  propertyName: realtype
                  mapping:
                    a-type: '#/components/schemas/A'
                    z-type: '#/components/schemas/A'
                    b-type: '#/components/schemas/B'

I was able to reproduce this in this repo by adding a test to OneOfDiffTest with the above as an example (based on oneOf_discriminator-missing_1.yaml).

  @Test
  public void testOneOfDiscrimitatorDifferentOrder() {
    assertOpenApiAreEquals(OPENAPI_DOC11, OPENAPI_DOC12);
  }

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 OneOfDiffTest hiện có và ví dụ oneOf_discriminator-missing_1.yaml được đề cập trong issue. Thêm hoặc chạy trường hợp mapping được sắp xếp lại, sau đó lần theo điểm vào của phép so sánh mà trường hợp đó thực thi. Hoàn thành khi hai schema được hiển thị được xử lý là tương thích trong trường hợp chỉ khác thứ tự mapping của discriminator.

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
Lỗi
Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Đặc tả rõ ràng
Mức phù hợp với người mới
55/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.