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

delta #473

Merged
merged 20 commits into from
Jan 26, 2024
Merged

delta #473

merged 20 commits into from
Jan 26, 2024

Conversation

reuvenharrison
Copy link
Collaborator

@reuvenharrison reuvenharrison commented Jan 14, 2024

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
Copy link

codecov-commenter commented Jan 14, 2024

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 ⚠️
delta/parameters.go 90.62% 2 Missing and 1 partial ⚠️
delta/schema.go 57.14% 2 Missing and 1 partial ⚠️
internal/delta.go 91.89% 2 Missing and 1 partial ⚠️
internal/changelog_flags.go 0.00% 2 Missing ⚠️
internal/diff_flags.go 0.00% 2 Missing ⚠️
delta/delta.go 95.00% 1 Missing ⚠️

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

Additional details and impacted files
@@            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 Coverage Δ
unittests 83.85% <90.99%> (+0.10%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@reuvenharrison reuvenharrison merged commit 64535de into main Jan 26, 2024
9 checks passed
@reuvenharrison reuvenharrison deleted the delta branch January 26, 2024 17:18
effoeffi added a commit to oasdiff/oasdiff that referenced this pull request Feb 1, 2024
* add flag to control colorful output (Tufin#433)

* Bump github.com/oasdiff/go-common from 0.2.27 to 0.2.28 (Tufin#444)

* color-flag completion (Tufin#447)

* Bump cloud.google.com/go from 0.110.10 to 0.111.0 (Tufin#448)

* prevent---color-with-non-text-formats (Tufin#449)

* upgrade-to-kin-openapi-v0.122.0 (Tufin#450)

* diff-add-exclude-elements-options (Tufin#454)

* remove-hardcoded-quotes (Tufin#455)

* Correct int messages (Tufin#456)

* fix test (Tufin#457)

* add qr code (Tufin#458)

* typo

* github-annotations-with-api (Tufin#452)

* add source file to github (Tufin#459)

* Change sample sunset date to self-explain that it's YYYY-MM-DD format (Tufin#460)

* github-avoid-http-files (Tufin#462)

* Update ALLOF.md

* flatten command - fix wrong Title and Description values (Tufin#464)

* flatten command - prune oneOf field on circular references (Tufin#466)

* lower-min-go-ver (Tufin#471)

* update Breaking Changes to Enum Values

* Bump cloud.google.com/go from 0.111.0 to 0.112.0 (Tufin#472)

* delta (Tufin#473)

* add property name to the response's type/format change message (Tufin#477)

* documentation (Tufin#478)

* Update DELTA.md (Tufin#480)

---------

Co-authored-by: Reuven Harrison <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: effoeffi <[email protected]>
Co-authored-by: Maciej Lewiński <[email protected]>
Co-authored-by: Omer E <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants