OpenAPITools / OpenAPITools/openapi-diff

Bug: erroneous detection of changes with mediaTypes, failure to generate html/markdown reports

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

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

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ả

Hello

I've run into an interesting problem with version 2.1.2 of openapi-diff. I've redacted/dumbed down this example spec to be the smallest piece possible.
It would seem that in this case, where the content of then endpoint is uses mediaType's, changes are being detected (though not breaking) but even when the specs are identical.

I boiled the repro to the simplest form, you can take this example, put it in two separate files, and diff them with 2.1.2 (or 2.1.1 - but for instance, 2.1.0.beta-11 does NOT exhibit this)

openapi: '3.0.3'
info:
  license:
    name: ''
  termsOfService: ''
  title: "my test service"
  version: 'Latest'
tags:
  - name: mytestTag
    description: endpoints
paths:
  /v4/mytest/formats/{downloadFormat}/records/{recordId}:
    get:
      tags:
        - mytestTag
      summary: Converts record to provided format
      operationId: getV4DownloadsFormatsRecords
      deprecated: false
      x-ebsco-secured-endpoint:
        requiredScopes: [ ]
      security:
        - Authorization: [ ]
      parameters:
        - name: downloadFormat
          in: path
          description: Export format
          required: true
          schema:
            type: string
          example: 'csv'
        - name: recordId
          in: path
          description: Unique record identifier
          required: true
          example: 'ax74x2wyin'
          schema:
            type: string
      responses:
        '200':
          description: OK
          content:
            text/csv:
              schema:
                type: string
                format: byte
              example: 'blah'
            application/vnd.openxmlformats-officedocument.wordprocessingml.document:
              schema:
                type: string
                format: byte
              example: 'blah'
            application/pdf:
              schema:
                type: string
                format: byte
              example: 'blah'
            application/x-bibtex:
              schema:
                type: string
                format: byte
              example: 'blah'
            application/marc:
              schema:
                type: string
                format: byte
              example: 'blah'
            text/xml:
              schema:
                type: string
                format: byte
              example: 'blah'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
components:
  responses:
    BadRequest:
      description: 'BadRequest'
      content:
        application/json:
          example:
            name: BAD_REQUEST
            details:
              - field: '#/login/username'
                issue: BAD_REQUEST
                location: body
            debugId: '123456789'
            message: Request contains errors
            informationLink: 'http://developer.foo.com/apidoc/blah#BAD_REQUEST'
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    NotFound:
      description: 'NotFound'
      content:
        application/json:
          example:
            name: NOT_FOUND
            details:
              - field: '#/login/username'
                issue: USERNAME_IS_NOT_FOUND
                location: body
            debugId: '123456789'
            message: Item is not found
            informationLink: 'http://developer.foo.com/apidoc/blah#USERNAME_IS_NOT_FOUND'
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    Unauthorized:
      description: 'Unauthorized'
      content:
        application/json:
          example:
            name: UNAUTHORIZED
            details:
              - field: '#/login/username'
                issue: NOT_AUTHORIZED
                location: body
            debugId: '123456789'
            message: User is not authorized
            informationLink: 'http://developer.foo.com/apidoc/blah#NOT_AUTHORIZED'
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    Forbidden:
      description: 'Forbidden'
      content:
        application/json:
          example:
            name: FORBIDDEN
            details:
              - field: '#/login/username'
                issue: FORBIDDEN
                location: body
            debugId: '123456789'
            message: Access denied
            informationLink: 'http://developer.foo.com/apidoc/blah#FORBIDDEN'
          schema:
            $ref: '#/components/schemas/ErrorResponse'
  schemas:
    ErrorResponse:
      type: object
      description: Common Error response
      x-examples:
        example-1:
          name: VALIDATION_ERROR
          details:
            - field: '#/login/username'
              issue: REQUIRED_FIELD_MISSING
              location: body
          debugId: '123456789'
          message: Invalid data provided
          informationLink: 'http://developer.foo.com/apidoc/blah#VALIDATION_ERROR'
  securitySchemes:
    Authorization:
      description: Authorization token
      type: http
      scheme: bearer
      bearerFormat: JWT

This will result in changes being detected, specifically around the mediaTypes

Image

So the detection of changes when the files are identical is curious.. but furthermore, attempting to generate the html or markdown version of the report fails generate with the following exception (for markdown)

Unexpected exception. Reason: Cannot invoke "org.openapitools.openapidiff.core.model.ChangedSchema.isDiscriminatorPropertyChanged()" because "schema" is null

and for html

Unexpected exception. Reason: Cannot invoke "org.openapitools.openapidiff.core.model.ChangedSchema.isIncompatible()" because "schema" is null

When running the command like so:

java -jar openapi-diff-cli-2.1.2-all.jar anothertest.yaml samefile.yaml --html blah.html --fail-on-incompatible

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 YAML OpenAPI được cung cấp và lệnh java -jar openapi-diff-cli-2.1.2-all.jar anothertest.yaml samefile.yaml --html blah.html --fail-on-incompatible. Kiểm tra phần so sánh mediaTypes và các đường dẫn báo cáo HTML/Markdown; hoàn thành khi các đặc tả giống hệt không hiển thị thay đổi nào và cả hai định dạng báo cáo đều được tạo mà không xảy ra ngoại lệ con trỏ null.

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, cli
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
45/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.