openapi-changes icon indicating copy to clipboard operation
openapi-changes copied to clipboard

Openapi-changes misaligns properties of added field with existing fields

Open cschierle opened this issue 9 months ago • 0 comments

I compared the two attached schemas with docker run --rm -t -v ${PWD}:/work:rw pb33f/openapi-changes html-report rentals_old.yaml rentals_new.yaml. The only effective change should be the newly added field firstComment with its size constraints. (also tested with summary and json report)

The tool detects the field addition, but somehow erroneously aligns its size constraints with the id field:

Image

Additionally, it hallucinates a change in the type of the startDate field which it apparently compared to the type of id:

Image

rentals_old.yaml:

openapi: 3.1.0
info:
  version: 1.0.0
servers:
- url: http://localhost
  description: Generated server url
paths:
  /rentals/{id}:
    get:
      tags:
      - rental-controller
      operationId: getRental
      parameters:
      - name: id
        in: path
        required: true
        schema:
          type: integer
          format: int64
      responses:
        "200":
          description: OK
          content:
            '*/*':
              schema:
                $ref: "#/components/schemas/RentalDto"
    put:
      tags:
      - rental-controller
      operationId: prolong
      parameters:
      - name: id
        in: path
        required: true
        schema:
          type: integer
          format: int64
      - name: newEndDate
        in: query
        required: true
        schema:
          type: string
          format: date
      responses:
        "200":
          description: OK
          content:
            '*/*':
              schema:
                $ref: "#/components/schemas/RentalDto"
    delete:
      tags:
      - rental-controller
      operationId: cancel
      parameters:
      - name: id
        in: path
        required: true
        schema:
          type: integer
          format: int64
      responses:
        "204":
          description: No Content
  /rentals/{id}/comments/{index}:
    put:
      tags:
      - rental-controller
      operationId: updateComment
      parameters:
      - name: id
        in: path
        required: true
        schema:
          type: integer
          format: int64
      - name: index
        in: path
        required: true
        schema:
          type: integer
          format: int32
      - name: comment
        in: query
        required: true
        schema:
          type: string
      responses:
        "200":
          description: OK
          content:
            '*/*':
              schema:
                $ref: "#/components/schemas/RentalDto"
  /rentals:
    get:
      tags:
      - rental-controller
      operationId: getAll
      parameters:
      - name: pageable
        in: query
        required: true
        schema:
          $ref: "#/components/schemas/Pageable"
      responses:
        "200":
          description: OK
          content:
            '*/*':
              schema:
                $ref: "#/components/schemas/PageRentalDto"
    post:
      tags:
      - rental-controller
      operationId: create
      parameters:
      - name: createRentalDto
        in: query
        required: true
        schema:
          $ref: "#/components/schemas/CreateRentalDto"
      responses:
        "200":
          description: OK
          content:
            '*/*':
              schema:
                $ref: "#/components/schemas/RentalDto"
  /rentals/{id}/comments:
    post:
      tags:
      - rental-controller
      operationId: comment
      parameters:
      - name: id
        in: path
        required: true
        schema:
          type: integer
          format: int64
      - name: comment
        in: query
        required: true
        schema:
          type: string
      responses:
        "200":
          description: OK
          content:
            '*/*':
              schema:
                $ref: "#/components/schemas/RentalDto"
components:
  schemas:
    RentalDto:
      type: object
      properties:
        id:
          type: integer
          format: int64
        carId:
          type: integer
          format: int64
        employeeId:
          type: integer
          format: int64
        startDate:
          type: string
          format: date
        endDate:
          type: string
          format: date
        comments:
          type: array
          items:
            type: string
    CreateRentalDto:
      type: object
      properties:
        carId:
          type: integer
          format: int64
        employeeId:
          type: integer
          format: int64
        startDate:
          type: string
          format: date
        endDate:
          type: string
          format: date
    Pageable:
      type: object
      properties:
        offset:
          type: integer
          format: int64
        sort:
          $ref: "#/components/schemas/Sort"
        unpaged:
          type: boolean
        paged:
          type: boolean
        pageSize:
          type: integer
          format: int32
        pageNumber:
          type: integer
          format: int32
    Sort:
      type: object
      properties:
        empty:
          type: boolean
        sorted:
          type: boolean
        unsorted:
          type: boolean
    PageRentalDto:
      type: object
      properties:
        totalPages:
          type: integer
          format: int32
        totalElements:
          type: integer
          format: int64
        size:
          type: integer
          format: int32
        content:
          type: array
          items:
            $ref: "#/components/schemas/RentalDto"
        number:
          type: integer
          format: int32
        sort:
          $ref: "#/components/schemas/Sort"
        first:
          type: boolean
        last:
          type: boolean
        numberOfElements:
          type: integer
          format: int32
        pageable:
          $ref: "#/components/schemas/Pageable"
        empty:
          type: boolean

rentals_new.yaml:

openapi: 3.1.0
info:
  version: 1.0.0
servers:
- url: http://localhost
  description: Generated server url
paths:
  /rentals/{id}:
    get:
      tags:
      - rental-controller
      operationId: getRental
      parameters:
      - name: id
        in: path
        required: true
        schema:
          type: integer
          format: int64
      responses:
        "200":
          description: OK
          content:
            '*/*':
              schema:
                $ref: "#/components/schemas/RentalDto"
    put:
      tags:
      - rental-controller
      operationId: prolong
      parameters:
      - name: id
        in: path
        required: true
        schema:
          type: integer
          format: int64
      - name: newEndDate
        in: query
        required: true
        schema:
          type: string
          format: date
      responses:
        "200":
          description: OK
          content:
            '*/*':
              schema:
                $ref: "#/components/schemas/RentalDto"
    delete:
      tags:
      - rental-controller
      operationId: cancel
      parameters:
      - name: id
        in: path
        required: true
        schema:
          type: integer
          format: int64
      responses:
        "204":
          description: No Content
  /rentals/{id}/comments/{index}:
    put:
      tags:
      - rental-controller
      operationId: updateComment
      parameters:
      - name: id
        in: path
        required: true
        schema:
          type: integer
          format: int64
      - name: index
        in: path
        required: true
        schema:
          type: integer
          format: int32
      - name: comment
        in: query
        required: true
        schema:
          type: string
      responses:
        "200":
          description: OK
          content:
            '*/*':
              schema:
                $ref: "#/components/schemas/RentalDto"
  /rentals:
    get:
      tags:
      - rental-controller
      operationId: getAll
      parameters:
      - name: pageable
        in: query
        required: true
        schema:
          $ref: "#/components/schemas/Pageable"
      responses:
        "200":
          description: OK
          content:
            '*/*':
              schema:
                $ref: "#/components/schemas/PageRentalDto"
    post:
      tags:
      - rental-controller
      operationId: create
      parameters:
      - name: createRentalDto
        in: query
        required: true
        schema:
          $ref: "#/components/schemas/CreateRentalDto"
      responses:
        "200":
          description: OK
          content:
            '*/*':
              schema:
                $ref: "#/components/schemas/RentalDto"
  /rentals/{id}/comments:
    post:
      tags:
      - rental-controller
      operationId: comment
      parameters:
      - name: id
        in: path
        required: true
        schema:
          type: integer
          format: int64
      - name: comment
        in: query
        required: true
        schema:
          type: string
      responses:
        "200":
          description: OK
          content:
            '*/*':
              schema:
                $ref: "#/components/schemas/RentalDto"
components:
  schemas:
    RentalDto:
      type: object
      properties:
        id:
          type: integer
          format: int64
        carId:
          type: integer
          format: int64
        employeeId:
          type: integer
          format: int64
        startDate:
          type: string
          format: date
        endDate:
          type: string
          format: date
        comments:
          type: array
          items:
            type: string
        firstComment:
          type: string
          maxLength: 255
          minLength: 1
    CreateRentalDto:
      type: object
      properties:
        carId:
          type: integer
          format: int64
        employeeId:
          type: integer
          format: int64
        startDate:
          type: string
          format: date
        endDate:
          type: string
          format: date
    Pageable:
      type: object
      properties:
        offset:
          type: integer
          format: int64
        sort:
          $ref: "#/components/schemas/Sort"
        paged:
          type: boolean
        unpaged:
          type: boolean
        pageSize:
          type: integer
          format: int32
        pageNumber:
          type: integer
          format: int32
    Sort:
      type: object
      properties:
        empty:
          type: boolean
        sorted:
          type: boolean
        unsorted:
          type: boolean
    PageRentalDto:
      type: object
      properties:
        totalPages:
          type: integer
          format: int32
        totalElements:
          type: integer
          format: int64
        size:
          type: integer
          format: int32
        content:
          type: array
          items:
            $ref: "#/components/schemas/RentalDto"
        number:
          type: integer
          format: int32
        sort:
          $ref: "#/components/schemas/Sort"
        first:
          type: boolean
        last:
          type: boolean
        numberOfElements:
          type: integer
          format: int32
        pageable:
          $ref: "#/components/schemas/Pageable"
        empty:
          type: boolean

cschierle avatar Mar 06 '25 07:03 cschierle