Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

oasdiff fails to detect a breaking chnage for type change #280

Closed
gssbzn opened this issue Jun 1, 2023 · 2 comments · Fixed by #286
Closed

oasdiff fails to detect a breaking chnage for type change #280

gssbzn opened this issue Jun 1, 2023 · 2 comments · Fixed by #286
Labels
bug Something isn't working

Comments

@gssbzn
Copy link
Contributor

gssbzn commented Jun 1, 2023

Describe the bug
This may be similar to #276 but if I change elements in an array of the response it seems to fail to recognize the breaking change

$ oasdiff -version
oasdiff version: 1.5.14

To Reproduce
Base

openapi: 3.0.1
info:
  title: Test
  version: "2.0"
servers:
- url: http://localhost:8080
tags:
- name: Tests
  description: Test tag.
paths:
  /api/atlas/v2/changeOfResponseArrayFieldTest:
    get:
      tags:
      - Tests
      summary: This is a test
      description: Test description.
      operationId: getTest
      parameters:
      - name: new
        in: query
        description: Test param
        schema:
          type: string
      responses:
        "200":
          description: OK
          content:
            application/vnd.atlas.2023-01-01+json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/ChangeOfResponseArrayFieldTestView'
              x-xgen-version: 2023-01-01
      security:
      - DigestAuth: []
components:
  schemas:
    ChangeOfResponseArrayFieldTestView:
      type: object
      properties:
        oldField:
          type: string
          description: A nested view
  securitySchemes:
    DigestAuth:
      type: http
      scheme: digest

Revision

openapi: 3.0.1
info:
  title: Test
  version: "2.0"
servers:
- url: http://localhost:8080
tags:
- name: Tests
  description: Test tag.
paths:
  /api/atlas/v2/changeOfResponseArrayFieldTest:
    get:
      tags:
      - Tests
      summary: This is a test
      description: Test description.
      operationId: getTest
      parameters:
      - name: new
        in: query
        description: Test param
        schema:
          type: string
      responses:
        "200":
          description: OK
          content:
            application/vnd.atlas.2023-01-01+json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/ChangeOfResponseArrayFieldTestView'
              x-xgen-version: 2023-01-01
      security:
      - DigestAuth: []
components:
  schemas:
    ChangeOfResponseArrayFieldTestView:
      type: object
      properties:
        newField:
          type: integer
          description: A nested view
          format: int32
  securitySchemes:
    DigestAuth:
      type: http
      scheme: digest

Produces no breaking change

oasdiff -base ChangeOfResponseArrayFieldTest-base.yaml  -revision ChangeOfResponseArrayFieldTest-revision.yaml  -check-breaking
# no result

But produces a correct diff

paths:
    modified:
        /api/atlas/v2/changeOfResponseArrayFieldTest:
            operations:
                modified:
                    GET:
                        responses:
                            modified:
                                "200":
                                    content:
                                        mediaTypeModified:
                                            application/vnd.atlas.2023-01-01+json:
                                                schema:
                                                    items:
                                                        properties:
                                                            added:
                                                                - newField
                                                            deleted:
                                                                - oldField
endpoints:
    modified:
        ?   method: GET
            path: /api/atlas/v2/changeOfResponseArrayFieldTest
        :   responses:
                modified:
                    "200":
                        content:
                            mediaTypeModified:
                                application/vnd.atlas.2023-01-01+json:
                                    schema:
                                        items:
                                            properties:
                                                added:
                                                    - newField
                                                deleted:
                                                    - oldField
components:
    schemas:
        modified:
            ChangeOfResponseArrayFieldTestView:
                properties:
                    added:
                        - newField
                    deleted:
                        - oldField

Expected behavior
I expect a breaking change report

Desktop (please complete the following information):

  • OS: macOS 13.4
@gssbzn gssbzn added the bug Something isn't working label Jun 1, 2023
@reuvenharrison
Copy link
Collaborator

Hi @gssbzn ,
This is not considered a breaking-change because the deleted property, 'oldField' isn't defined as required, therefor it is optional and the client should not rely on it being there.
Please let me know if I am missing something.
Reuven

@gssbzn
Copy link
Contributor Author

gssbzn commented Jun 3, 2023

Sorry I was busy yesterday and could go back to this

This is not considered a breaking-change because the deleted property, 'oldField' isn't defined as required

This is find if we are being strict on the required for response but I should've probably stick to my original test which was a change of type

base:

openapi: 3.0.1
info:
  title: Test
  version: "2.0"
servers:
- url: http://localhost:8080
tags:
- name: Tests
  description: Test tag.
paths:
  /api/atlas/v2/changeOfResponseArrayFieldTest:
    get:
      tags:
      - Tests
      summary: This is a test
      description: Test description.
      operationId: getTest
      parameters:
      - name: new
        in: query
        description: Test param
        schema:
          type: string
      responses:
        "200":
          description: OK
          content:
            application/vnd.atlas.2023-01-01+json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/ChangeOfResponseArrayFieldTestView'
components:
  schemas:
    ChangeOfResponseArrayFieldTestView:
      type: object
      properties:
        testField:
          type: string
          description: A nested view

revision:

openapi: 3.0.1
info:
  title: Test
  version: "2.0"
servers:
- url: http://localhost:8080
tags:
- name: Tests
  description: Test tag.
paths:
  /api/atlas/v2/changeOfResponseArrayFieldTest:
    get:
      tags:
      - Tests
      summary: This is a test
      description: Test description.
      operationId: getTest
      parameters:
      - name: new
        in: query
        description: Test param
        schema:
          type: string
      responses:
        "200":
          description: OK
          content:
            application/vnd.atlas.2023-01-01+json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/ChangeOfResponseArrayFieldTestView'
components:
  schemas:
    ChangeOfResponseArrayFieldTestView:
      type: object
      properties:
        testField:
          type: integer
          description: A nested view
          format: int32

is not flagged by

oasdiff -base ChangeOfResponseArrayFieldTest-base.yaml  -revision ChangeOfResponseArrayFieldTest-revision.yaml  -check-breaking

@reuvenharrison reuvenharrison reopened this Jun 3, 2023
@reuvenharrison reuvenharrison changed the title oasdiff fails to detect a breaking chnage for elements of an array oasdiff fails to detect a breaking chnage for type change Jun 3, 2023
@reuvenharrison reuvenharrison linked a pull request Jun 5, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants