Skip to content

Commit

Permalink
documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
Reuven committed Jan 30, 2024
1 parent 8b6e8c9 commit 103f5d2
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 1 deletion.
49 changes: 49 additions & 0 deletions DELTA.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
## Delta - a distance function for OpenAPI Spec 3
Delta calculates a numeric value between 0 and 1 representing the distance between base and revision specs:
```
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:
```
oasdiff delta spec.yaml spec.yaml
```

### The distance between disjoint specs is 1
The maximum distance, 1, respresnts the distance between specifications with no common endpoints.
For example, the distance between a spec with no endpoints and another spec with one or more endpoints is 1:
```
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:
```
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:
```
oasdiff delta base.yaml revision.yaml --asymmetric
oasdiff delta revision.yaml base.yaml --asymmetric
```

### Feature status: Beta
Delta currently considers:
- Endpoints (path+method)
- Parameters
- Schema
- Type
- Responses

Other elementes of OpenAPI spec are ignored.
Please submit an issue for issues and feature requests.

1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ docker run --rm -t tufin/oasdiff changelog https://raw.githubusercontent.com/Tuf
- [Excluding endpoints](#excluding-specific-endpoints)
- [Extending breaking changes with custom checks](CUSTOMIZING-CHECKS.md)
- Localization: display breaking changes and changelog messages in English or Russian ([please contribute support for your language](https://github.com/Tufin/oasdiff/issues/383))
- [Measure a numeric distance between a pair of specifications](DELTA.md)


## Install with Go
Expand Down
1 change: 1 addition & 0 deletions delta/delta.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (

const coefficient = 0.5

// Get returns a numeric value between 0 and 1 representing the distance between base and revision specs
func Get(asymmetric bool, diffReport *diff.Diff) float64 {
if diffReport.Empty() {
return 0
Expand Down
2 changes: 1 addition & 1 deletion delta/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Delta considers both elements of base that are deleted in revision and elements
For any two specs, a and b: delta(a, b) = delta(b, a)
Asymmetric mode:
Delta only considers elements of base that are deleted in revision but not elements of base that are added in revision.
Delta only considers elements of base that are deleted in revision but not elements that are missing in base and were added in revision.
For any two specs, a and b: Delta(a, b) + Delta(b, a) = 1
*/
package delta

0 comments on commit 103f5d2

Please sign in to comment.