-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Reuven
committed
Jan 18, 2024
1 parent
9361ae3
commit a623b3b
Showing
13 changed files
with
215 additions
and
89 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,5 +10,5 @@ paths: | |
description: OK | ||
post: | ||
responses: | ||
200: | ||
201: | ||
description: OK |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
info: | ||
title: Tufin | ||
version: 1.0.0 | ||
openapi: 3.0.3 | ||
paths: | ||
/api/test: | ||
get: | ||
parameters: | ||
- name: a | ||
in: query | ||
responses: | ||
200: | ||
description: OK | ||
post: | ||
responses: | ||
201: | ||
description: OK |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package delta | ||
|
||
import ( | ||
"github.com/tufin/oasdiff/diff" | ||
) | ||
|
||
const coefficient = 0.5 | ||
|
||
func Get(asymmetric bool, diffReport *diff.Diff) float64 { | ||
if diffReport.Empty() { | ||
return 0 | ||
} | ||
|
||
delta := getEndpointsDelta(asymmetric, diffReport.EndpointsDiff) | ||
|
||
return delta | ||
} | ||
|
||
func ratio(asymmetric bool, added int, deleted int, modifiedDelta float64, all int) float64 { | ||
if asymmetric { | ||
added = 0 | ||
} | ||
|
||
return (float64(added+deleted) + modifiedDelta) / float64(all) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package delta | ||
|
||
import ( | ||
"github.com/tufin/oasdiff/diff" | ||
) | ||
|
||
func getEndpointsDelta(asymmetric bool, d *diff.EndpointsDiff) float64 { | ||
if d.Empty() { | ||
return 0 | ||
} | ||
|
||
added := len(d.Added) | ||
deleted := len(d.Deleted) | ||
modified := len(d.Modified) | ||
unchanged := len(d.Unchanged) | ||
all := added + deleted + modified + unchanged | ||
|
||
modifiedDelta := coefficient * getModifiedEndpointsDelta(asymmetric, d.Modified) | ||
|
||
return ratio(asymmetric, added, deleted, modifiedDelta, all) | ||
} | ||
|
||
func getModifiedEndpointsDelta(asymmetric bool, d diff.ModifiedEndpoints) float64 { | ||
result := 0.0 | ||
for _, methodDiff := range d { | ||
result += getModifiedEndpointDelta(asymmetric, methodDiff) | ||
} | ||
return result | ||
} | ||
|
||
func getModifiedEndpointDelta(asymmetric bool, d *diff.MethodDiff) float64 { | ||
if d.Empty() { | ||
return 0 | ||
} | ||
|
||
// TODO: consider additional elements of MethodDiff | ||
delta := getParametersDelta(asymmetric, d.ParametersDiff) | ||
|
||
return delta | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package delta | ||
|
||
import ( | ||
"github.com/tufin/oasdiff/diff" | ||
) | ||
|
||
func getParametersDelta(asymmetric bool, d *diff.ParametersDiffByLocation) float64 { | ||
if d.Empty() { | ||
return 0 | ||
} | ||
|
||
added := d.Added.Len() | ||
deleted := d.Deleted.Len() | ||
modified := d.Modified.Len() | ||
unchanged := d.Unchanged.Len() | ||
all := added + deleted + modified + unchanged | ||
|
||
// TODO: drill down into modified | ||
modifiedDelta := coefficient * float64(modified) | ||
|
||
return ratio(asymmetric, added, deleted, modifiedDelta, all) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.