mirror of
https://github.com/LukeHagar/libopenapi.git
synced 2025-12-10 04:20:24 +00:00
Bumped low level v2 examples test coverage
This commit is contained in:
@@ -9,6 +9,7 @@ import (
|
||||
"github.com/pb33f/libopenapi/datamodel/low"
|
||||
"github.com/pb33f/libopenapi/index"
|
||||
"gopkg.in/yaml.v3"
|
||||
"sort"
|
||||
"strings"
|
||||
)
|
||||
|
||||
@@ -77,8 +78,15 @@ func (e *Examples) Build(root *yaml.Node, _ *index.SpecIndex) error {
|
||||
// Hash will return a consistent SHA256 Hash of the Examples object
|
||||
func (e *Examples) Hash() [32]byte {
|
||||
var f []string
|
||||
keys := make([]string, len(e.Values))
|
||||
z := 0
|
||||
for k := range e.Values {
|
||||
f = append(f, fmt.Sprint(e.Values[k].Value))
|
||||
keys[z] = k.Value
|
||||
z++
|
||||
}
|
||||
sort.Strings(keys)
|
||||
for k := range keys {
|
||||
f = append(f, fmt.Sprintf("%v", e.FindExample(keys[k]).Value))
|
||||
}
|
||||
return sha256.Sum256([]byte(strings.Join(f, "|")))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user