mirror of
https://github.com/LukeHagar/libopenapi.git
synced 2025-12-09 20:47:44 +00:00
Building out schema comparison mechanism
Which has led to a new wider hashing capability for the low level API. hashing makes it very easy to determine changes quickly, without having to run comparisons to discover changes, could really speed things up moving forward.
This commit is contained in:
@@ -4,9 +4,11 @@
|
||||
package base
|
||||
|
||||
import (
|
||||
"crypto/sha256"
|
||||
"github.com/pb33f/libopenapi/datamodel/low"
|
||||
"github.com/pb33f/libopenapi/index"
|
||||
"gopkg.in/yaml.v3"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// ExternalDoc represents a low-level External Documentation object as defined by OpenAPI 2 and 3
|
||||
@@ -38,3 +40,12 @@ func (ex *ExternalDoc) GetExtensions() map[low.KeyReference[string]]low.ValueRef
|
||||
}
|
||||
return ex.Extensions
|
||||
}
|
||||
|
||||
func (ex *ExternalDoc) Hash() [32]byte {
|
||||
// calculate a hash from every property.
|
||||
d := []string{
|
||||
ex.Description.Value,
|
||||
ex.URL.Value,
|
||||
}
|
||||
return sha256.Sum256([]byte(strings.Join(d, "|")))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user