mirror of
https://github.com/LukeHagar/libopenapi.git
synced 2025-12-09 12:37:49 +00:00
chore: update to use iterators on orderedmaps
This commit is contained in:
committed by
quobix
parent
c3eb16d4e4
commit
161a41f73b
@@ -94,9 +94,9 @@ func (p *Paths) Build(ctx context.Context, keyNode, root *yaml.Node, idx *index.
|
||||
|
||||
p.PathItems = pathsMap
|
||||
|
||||
for pm := pathsMap.First(); pm != nil; pm = pm.Next() {
|
||||
for k, v := range pathsMap.FromOldest() {
|
||||
// add path as node to path item, not this path object.
|
||||
pm.Value().Value.Nodes.Store(pm.Key().KeyNode.Line, pm.Key().KeyNode)
|
||||
v.Value.Nodes.Store(k.KeyNode.Line, k.KeyNode)
|
||||
}
|
||||
|
||||
return nil
|
||||
@@ -105,9 +105,7 @@ func (p *Paths) Build(ctx context.Context, keyNode, root *yaml.Node, idx *index.
|
||||
// Hash will return a consistent SHA256 Hash of the PathItem object
|
||||
func (p *Paths) Hash() [32]byte {
|
||||
var f []string
|
||||
for pair := orderedmap.First(orderedmap.SortAlpha(p.PathItems)); pair != nil; pair = pair.Next() {
|
||||
f = append(f, fmt.Sprintf("%s-%s", pair.Key().Value, low.GenerateHashString(pair.Value().Value)))
|
||||
}
|
||||
f = low.AppendMapHashes(f, p.PathItems)
|
||||
f = append(f, low.HashExtensions(p.Extensions)...)
|
||||
return sha256.Sum256([]byte(strings.Join(f, "|")))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user