Tufin / oasdiff

OpenAPI Diff and Breaking Changes
https://www.oasdiff.com
Apache License 2.0
739 stars 62 forks source link

delta #473

Closed reuvenharrison closed 9 months ago

reuvenharrison commented 9 months ago

This branch implements a new delta function for OpenAPI spec. The delta function returns a numeric value between 0 and 1 representing the distance between base and revision specs. For any spec, a: delta(a, a) = 0 For any two specs, a and b, with no common elements: delta(a, b) = 1

Delta is symmetric by default: For any two specs, a and b: delta(a, b) = delta(b, a)

Delta can also be asymmetric so that it only considers elements of base that are deleted in revision but not elements of base that are added in revision. For any two specs, a and b: asymmetricDelta(a, b) + asymmetricDelta(b, a) = 1

In order to implement delta, we need to traverse the diff tree. We will implement this until all elements are covered.

Each diff element that is supported by delta must have a new Unchanged member that allows delta to know how many items were unchanged. Note that the new Unchanged member will also appear in the oasdiff diff output when diff is not empty. We will implement this gradually until all elements are covered.

To test delta: oasdiff delta data/simple4.yaml data/simple3.yaml

To test asymmetric delta: oasdiff delta data/simple4.yaml data/simple3.yaml --asymmetric

To see the new Unchanged fields: oasdiff diff data/simple4.yaml data/simple3.yaml

codecov-commenter commented 9 months ago

Codecov Report

Attention: 20 lines in your changes are missing coverage. Please review.

Comparison is base (a8392c1) 83.75% compared to head (c7e9aaf) 83.85%.

Files Patch % Lines
delta/endpoints.go 79.31% 4 Missing and 2 partials :warning:
delta/parameters.go 90.62% 2 Missing and 1 partial :warning:
delta/schema.go 57.14% 2 Missing and 1 partial :warning:
internal/delta.go 91.89% 2 Missing and 1 partial :warning:
internal/changelog_flags.go 0.00% 2 Missing :warning:
internal/diff_flags.go 0.00% 2 Missing :warning:
delta/delta.go 95.00% 1 Missing :warning:

:exclamation: Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #473 +/- ## ========================================== + Coverage 83.75% 83.85% +0.10% ========================================== Files 217 225 +8 Lines 12593 12799 +206 ========================================== + Hits 10547 10733 +186 - Misses 1668 1683 +15 - Partials 378 383 +5 ``` | [Flag](https://app.codecov.io/gh/Tufin/oasdiff/pull/473/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Tufin) | Coverage Δ | | |---|---|---| | [unittests](https://app.codecov.io/gh/Tufin/oasdiff/pull/473/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Tufin) | `83.85% <90.99%> (+0.10%)` | :arrow_up: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Tufin#carryforward-flags-in-the-pull-request-comment) to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.