Skip to content

[bug] support of breaking changes for "anyOf" #212

Closed
@TenOs

Description

@TenOs

So I've been tested openapi-diff to see if we can use it in our CI/CD pipeline to prevent any breaking changes from happening.
After running a few tests I've noticed that it doesn't seem to support anyOf correctly.

See the two openapi files attached. Basically the endpoint returns a response which either ResponseA or ResponseB. New file removes a required property from ResponseA and openapi-diff doesn't catch the breaking change.
old.yaml

openapi: 3.0.2
info:
  title: test API
  version: 0.1.0
paths:
  /test:
    get:
      summary: Test
      operationId: test_test_get
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                title: Response Test Test Get
                anyOf:
                  - $ref: '#/components/schemas/ResponseA'
                  - $ref: '#/components/schemas/ResponseB'
components:
  schemas:
    ResponseA:
      title: ResponseA
      required:
        - attr_a_1
        - attr_a_2
      type: object
      properties:
        attr_a_1:
          title: Attr A 1
          type: string
        attr_a_2:
          title: Attr A 2
          type: string
    ResponseB:
      title: ResponseB
      required:
        - attr_b
      type: object
      properties:
        attr_b:
          title: Attr B
          type: string

new.yaml

openapi: 3.0.2
info:
  title: test API
  version: 0.1.0
paths:
  /test:
    get:
      summary: Test
      operationId: test_test_get
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                title: Response Test Test Get
                anyOf:
                  - $ref: '#/components/schemas/ResponseA'
                  - $ref: '#/components/schemas/ResponseB'
components:
  schemas:
    ResponseA:
      title: ResponseA
      required:
        - attr_a_1
      type: object
      properties:
        attr_a_1:
          title: Attr A 1
          type: string
    ResponseB:
      title: ResponseB
      required:
        - attr_b
      type: object
      properties:
        attr_b:
          title: Attr B
          type: string

Result

No differences. Specifications are equivalents

This is a very simple test scenario, but I've tested the same one with a change like this in:

  • request
  • response
  • nested property on request
  • nested property on response

for all of them it wasn't detecting any breaking changes....

I've tested these using docker openapitools/openapi-diff:latest.

Metadata

Metadata

Assignees

Type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions