Clearing up some dead code and adding docs to what-changed

Signed-off-by: Dave Shanley <dave@quobix.com>
This commit is contained in:
Dave Shanley
2022-11-21 09:57:21 -05:00
parent c4b6e68197
commit 3ad8ec3d43
14 changed files with 120 additions and 85 deletions

View File

@@ -8,12 +8,14 @@ import (
"github.com/pb33f/libopenapi/datamodel/low/v3"
)
// CallbackChanges represents all changes made between two Callback OpenAPI objects.
type CallbackChanges struct {
PropertyChanges
ExpressionChanges map[string]*PathItemChanges `json:"expressions,omitempty" yaml:"expressions,omitempty"`
ExtensionChanges *ExtensionChanges `json:"extensions,omitempty" yaml:"extensions,omitempty"`
}
// TotalChanges returns a total count of all changes made between Callback objects
func (c *CallbackChanges) TotalChanges() int {
d := c.PropertyChanges.TotalChanges()
for k := range c.ExpressionChanges {
@@ -25,6 +27,7 @@ func (c *CallbackChanges) TotalChanges() int {
return d
}
// TotalBreakingChanges returns a total count of all changes made between Callback objects
func (c *CallbackChanges) TotalBreakingChanges() int {
d := c.PropertyChanges.TotalBreakingChanges()
for k := range c.ExpressionChanges {
@@ -36,6 +39,8 @@ func (c *CallbackChanges) TotalBreakingChanges() int {
return d
}
// CompareCallback will compare two Callback objects and return a pointer to CallbackChanges with all the things
// that have changed between them.
func CompareCallback(l, r *v3.Callback) *CallbackChanges {
cc := new(CallbackChanges)