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

Breaking change not detected when type changes for dictionary value object #601

Closed
shahakL opened this issue Sep 1, 2024 · 2 comments · Fixed by #603
Closed

Breaking change not detected when type changes for dictionary value object #601

shahakL opened this issue Sep 1, 2024 · 2 comments · Fixed by #603
Labels
enhancement New feature or request

Comments

@shahakL
Copy link

shahakL commented Sep 1, 2024

Describe the bug
Comparing the following 2 OpenAPI schemas:

{
  "components": {
    "schemas": {
      "Schema1": {
        "properties": {
          "property1": {
            "title": "Value",
            "type": "integer"
          }
        },
        "type": "object"
      },
      "Schema2": {
        "properties": {
          "composite-property": {
            "additionalProperties": {
              "$ref": "#/components/schemas/Schema1"
            },
            "title": "Composite",
            "type": "object"
          }
        },
        "type": "object"
      }
    }
  },
  "paths": {
    "/value": {
      "get": {
        "operationId": "get_value",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Schema2"
                }
              }
            },
            "description": "Successful Response"
          }
        }
      }
    }
  }
}

And:

{
  "components": {
    "schemas": {
      "Schema1": {
        "properties": {
          "property1": {
            "title": "Value",
            "type": "string"
          }
        },
        "type": "object"
      },
      "Schema2": {
        "properties": {
          "composite-property": {
            "additionalProperties": {
              "$ref": "#/components/schemas/Schema1"
            },
            "title": "Composite",
            "type": "object"
          }
        },
        "type": "object"
      }
    }
  },
  "paths": {
    "/value": {
      "get": {
        "operationId": "get_value",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Schema2"
                }
              }
            },
            "description": "Successful Response"
          }
        }
      }
    }
  }
}

The only change is for the inner object Schema1, where its property changed from integer to string. This should be considered a breaking change, however oasdiff ignores the change completely.
When changing the return schema from Schema2 to Schema1, the change is detected and reported as breaking as it should.

To Reproduce
Steps to reproduce the behavior:

  1. Copy the 2 OpenAPI schemas above to files spec1.json and spec2.json
  2. oasdiff breaking spec1.json spec2.json
  3. Output is empty

Expected behavior
Correct output should be the same when changing the response schema to schema1:

error   [response-property-type-changed] at spec2.json
        in API GET /value
                the 'property1' response's property type/format changed from 'string'/'' to 'integer'/'' for status '200'

Desktop (please complete the following information):

  • OS: macos 14.6.1
  • oasdiff version 1.10.23
@shahakL shahakL added the bug Something isn't working label Sep 1, 2024
@reuvenharrison
Copy link
Collaborator

This is due to additionalProperties which is used in Schema2.
Oasdiff doesn't currently support breaking changes for additionalProperties.

I am going to change this issue type from a bug to an enhancement to remind myself or another kind contributor to add support for additionalProperties.

@reuvenharrison reuvenharrison added enhancement New feature or request and removed bug Something isn't working labels Sep 5, 2024
@reuvenharrison reuvenharrison linked a pull request Sep 5, 2024 that will close this issue
@shahakL
Copy link
Author

shahakL commented Sep 5, 2024

Thank you @reuvenharrison !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants