mirror of
https://github.com/LukeHagar/libopenapi.git
synced 2025-12-09 04:20:17 +00:00
A few small bugfixes discovered from online users of openapi-changes
someone caused a panic, exposed an untested bug. Signed-off-by: quobix <dave@quobix.com>
This commit is contained in:
@@ -823,6 +823,9 @@ func AreEqual(l, r Hashable) bool {
|
|||||||
if l == nil || r == nil {
|
if l == nil || r == nil {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
if reflect.ValueOf(l).IsNil() || reflect.ValueOf(r).IsNil() {
|
||||||
|
return false
|
||||||
|
}
|
||||||
return l.Hash() == r.Hash()
|
return l.Hash() == r.Hash()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -154,7 +154,7 @@ func (p *Paths) Build(ctx context.Context, _, root *yaml.Node, idx *index.SpecIn
|
|||||||
err := path.Build(ctx, cNode, pNode, idx)
|
err := path.Build(ctx, cNode, pNode, idx)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if idx.GetLogger() != nil {
|
if idx != nil && idx.GetLogger() != nil {
|
||||||
idx.GetLogger().Error(fmt.Sprintf("error building path item '%s'", err.Error()))
|
idx.GetLogger().Error(fmt.Sprintf("error building path item '%s'", err.Error()))
|
||||||
}
|
}
|
||||||
//return buildResult{}, err
|
//return buildResult{}, err
|
||||||
|
|||||||
@@ -146,11 +146,16 @@ func ComparePaths(l, r any) *PathsChanges {
|
|||||||
|
|
||||||
lKeys := make(map[string]low.ValueReference[*v3.PathItem])
|
lKeys := make(map[string]low.ValueReference[*v3.PathItem])
|
||||||
rKeys := make(map[string]low.ValueReference[*v3.PathItem])
|
rKeys := make(map[string]low.ValueReference[*v3.PathItem])
|
||||||
for k := range lPath.PathItems {
|
|
||||||
lKeys[k.Value] = lPath.PathItems[k]
|
if lPath != nil {
|
||||||
|
for k := range lPath.PathItems {
|
||||||
|
lKeys[k.Value] = lPath.PathItems[k]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
for k := range rPath.PathItems {
|
if rPath != nil {
|
||||||
rKeys[k.Value] = rPath.PathItems[k]
|
for k := range rPath.PathItems {
|
||||||
|
rKeys[k.Value] = rPath.PathItems[k]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// run every comparison in a thread.
|
// run every comparison in a thread.
|
||||||
@@ -199,7 +204,15 @@ func ComparePaths(l, r any) *PathsChanges {
|
|||||||
pc.PathItemsChanges = pathChanges
|
pc.PathItemsChanges = pathChanges
|
||||||
}
|
}
|
||||||
|
|
||||||
pc.ExtensionChanges = CompareExtensions(lPath.Extensions, rPath.Extensions)
|
var lExt, rExt map[low.KeyReference[string]]low.ValueReference[any]
|
||||||
|
if lPath != nil {
|
||||||
|
lExt = lPath.Extensions
|
||||||
|
}
|
||||||
|
if rPath != nil {
|
||||||
|
rExt = rPath.Extensions
|
||||||
|
}
|
||||||
|
|
||||||
|
pc.ExtensionChanges = CompareExtensions(lExt, rExt)
|
||||||
}
|
}
|
||||||
pc.PropertyChanges = NewPropertyChanges(changes)
|
pc.PropertyChanges = NewPropertyChanges(changes)
|
||||||
return pc
|
return pc
|
||||||
|
|||||||
Reference in New Issue
Block a user