Couple of small fixes for what-changed.

No breaking changes, errors and model are returned now (allows errors and model through). And a small fix to the paths hashing mechanism to ensure identical paths with different names are checked.
This commit is contained in:
Dave Shanley
2023-01-18 07:00:46 -05:00
parent cc5b7e73d9
commit f8ae5759d0
2 changed files with 3 additions and 9 deletions

View File

@@ -153,7 +153,7 @@ func (p *Paths) Hash() [32]byte {
}
sort.Strings(l)
for k := range l {
f = append(f, low.GenerateHashString(keys[l[k]].Value))
f = append(f, fmt.Sprintf("%s-%s",l[k], low.GenerateHashString(keys[l[k]].Value)))
}
ekeys := make([]string, len(p.Extensions))
z = 0

View File

@@ -182,10 +182,7 @@ func CompareDocuments(original, updated Document) (*model.DocumentChanges, []err
if len(errs) > 0 {
errors = errs
}
if len(errors) > 0 {
return nil, errors
}
return what_changed.CompareOpenAPIDocuments(v3ModelLeft.Model.GoLow(), v3ModelRight.Model.GoLow()), nil
return what_changed.CompareOpenAPIDocuments(v3ModelLeft.Model.GoLow(), v3ModelRight.Model.GoLow()), errors
}
if original.GetSpecInfo().SpecType == utils.OpenApi2 && updated.GetSpecInfo().SpecType == utils.OpenApi2 {
v2ModelLeft, errs := original.BuildV2Model()
@@ -196,10 +193,7 @@ func CompareDocuments(original, updated Document) (*model.DocumentChanges, []err
if len(errs) > 0 {
errors = errs
}
if len(errors) > 0 {
return nil, errors
}
return what_changed.CompareSwaggerDocuments(v2ModelLeft.Model.GoLow(), v2ModelRight.Model.GoLow()), nil
return what_changed.CompareSwaggerDocuments(v2ModelLeft.Model.GoLow(), v2ModelRight.Model.GoLow()), errors
}
return nil, nil
}