OpenAPITools / OpenAPITools/openapi-diff

[2.1.0-beta.6 and oas-3.1.0] Request body property data type change is detected as compatible or no_change

Đang mở
#528 1 bình luận 3 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ả

  1. string to object (actual: compatible, expected: incompatible)
  2. string to integer/integer to string (actual: no_change, expected: incompatible)

Case 1:
old.yml

openapi: 3.1.0
info:
  title: Demo API
  version: v1
paths:
  /endpoint:
    post:
      requestBody:
        content:
          application/json:
            schema:
              type: object
              required:
                - requiredProp
                - requiredToRemoveProp
                - dataTypeChangedRequiredProp
                - requiredToOptionalProp
              properties:
                requiredProp:
                  type: string
                optionalProp:
                  type: string
                optionalToRemoveProp:
                  type: string
                requiredToRemoveProp:
                  type: string
                dataTypeChangedRequiredProp:
                  type: string
                dataTypeChangedOptionalProp:
                  type: string
                optionalToRequiredProp:
                  type: string
                requiredToOptionalProp:
                  type: string
      responses:
        default:
          description: successful operation
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: integer
                    format: int64
                    example: 201

new.yml

openapi: 3.1.0
info:
  title: Demo API
  version: v1
paths:
  /endpoint:
    post:
      requestBody:
        content:
          application/json:
            schema:
              type: object
              required:
                - requiredProp
                - requiredToRemoveProp
                - dataTypeChangedRequiredProp
                - requiredToOptionalProp
              properties:
                requiredProp:
                  type: string
                optionalProp:
                  type: string
                optionalToRemoveProp:
                  type: string
                requiredToRemoveProp:
                  type: string
                dataTypeChangedRequiredProp:
                  type: object
                  properties:
                    id:
                      type: string
                dataTypeChangedOptionalProp:
                  type: string
                optionalToRequiredProp:
                  type: string
                requiredToOptionalProp:
                  type: string
      responses:
        default:
          description: successful operation
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: integer
                    format: int64
                    example: 201

Case 2:
old.yml

openapi: 3.1.0
info:
  title: Demo API
  version: v1
paths:
  /endpoint:
    post:
      requestBody:
        content:
          application/json:
            schema:
              type: object
              required:
                - requiredProp
                - requiredToRemoveProp
                - dataTypeChangedRequiredProp
                - requiredToOptionalProp
              properties:
                requiredProp:
                  type: string
                optionalProp:
                  type: string
                optionalToRemoveProp:
                  type: string
                requiredToRemoveProp:
                  type: string
                dataTypeChangedRequiredProp:
                  type: integer
                dataTypeChangedOptionalProp:
                  type: string
                optionalToRequiredProp:
                  type: string
                requiredToOptionalProp:
                  type: string
      responses:
        default:
          description: successful operation
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: integer
                    format: int64
                    example: 201

new.yml

openapi: 3.1.0
info:
  title: Demo API
  version: v1
paths:
  /endpoint:
    post:
      requestBody:
        content:
          application/json:
            schema:
              type: object
              required:
                - requiredProp
                - requiredToRemoveProp
                - dataTypeChangedRequiredProp
                - requiredToOptionalProp
              properties:
                requiredProp:
                  type: string
                optionalProp:
                  type: string
                optionalToRemoveProp:
                  type: string
                requiredToRemoveProp:
                  type: string
                dataTypeChangedRequiredProp:
                  type: string
                dataTypeChangedOptionalProp:
                  type: string
                optionalToRequiredProp:
                  type: string
                requiredToOptionalProp:
                  type: string
      responses:
        default:
          description: successful operation
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: integer
                    format: int64
                    example: 201

Examples are having data-type change only for required property but tested the same for optional property giving same output
Command used: docker run --rm -t -v $(pwd):/specs openapitools/openapi-diff:2.1.0-beta.6 /specs/old.yml /specs/new.yml --state

EDIT: The same changes are considered as incompatible with openapi: 3.0.3 and below

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 bằng cách tái hiện báo cáo với old.yml và new.yml bằng lệnh Docker openapi-diff đã nêu, so sánh kết quả của OpenAPI 3.1.0 với hành vi của 3.0.3. Theo dõi việc so sánh kiểu của schema request-body và thêm phạm vi kiểm thử hồi quy cho các thay đổi string/object và string/integer; hoàn tất khi các thay đổi này được báo cáo là không tương thích.

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
Khá rõ ràng
Mức phù hợp với người mới
38/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.