Skip to content

Commit

Permalink
fix params len (#496)
Browse files Browse the repository at this point in the history
Co-authored-by: Reuven <rh@tufin.com>
  • Loading branch information
reuvenharrison and Reuven authored Feb 26, 2024
1 parent 83694d9 commit 5f540f2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
9 changes: 5 additions & 4 deletions DELTA.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
## Delta - a distance function for OpenAPI Spec 3 [Beta]
Delta calculates a numeric value between 0 and 1 representing the distance between base and revision specs:
Delta calculates a numeric value between 0 and 1 representing the distance between base and revision specs.
For example:
```
oasdiff delta base.yaml revision.yaml
```


### The distance between identical specs is 0
The minimum distance, 0, respresnts the distance between specifications with identical endpoints.
For example the distance between any spec to itself is 0:
For example, the distance between any spec to itself is 0:
```
oasdiff delta spec.yaml spec.yaml
```
Expand All @@ -22,15 +23,15 @@ oasdiff delta empty-spec.yaml non-empty-spec.yaml

### Symmetric mode
By default, delta is symmetric and takes into account both elements of base that are deleted in revision and elements of base that are added in revision.
For example, these two commands return the same distance:
For example, the symmetric distance between any two specs is the same regardless of the order of the given specs:
```
oasdiff delta base.yaml revision.yaml
oasdiff delta revision.yaml base.yaml
```

### Asymmetric mode
It is also possible to calculate an asymmetric distance which takes into account elements of base that were deleted in revision but ignores elements that are missing in base and were added in revision.
The sum of the following distances is always 1:
For examples, for any two specs the sum of the asymmetric distances is their symmetric distance:
```
oasdiff delta base.yaml revision.yaml --asymmetric
oasdiff delta revision.yaml base.yaml --asymmetric
Expand Down
2 changes: 1 addition & 1 deletion delta/parameters.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func getParametersDelta(asymmetric bool, d *diff.ParametersDiffByLocation) *Weig
}

func getModifiedParametersDelta(asymmetric bool, d diff.ParamDiffByLocation) float64 {
weightedDeltas := make([]*WeightedDelta, len(d))
weightedDeltas := make([]*WeightedDelta, d.Len())
i := 0
for _, paramsDiff := range d {
for _, parameterDiff := range paramsDiff {
Expand Down

0 comments on commit 5f540f2

Please sign in to comment.