Added what-changed documentation to methods and structs.

Signed-off-by: Dave Shanley <dave@quobix.com>
This commit is contained in:
Dave Shanley
2022-11-21 10:44:04 -05:00
parent 3ad8ec3d43
commit 62d580e671
15 changed files with 95 additions and 22 deletions

View File

@@ -8,11 +8,13 @@ import (
"github.com/pb33f/libopenapi/datamodel/low/v3"
)
// ServerChanges represents changes found between two OpenAPI Server Objects
type ServerChanges struct {
PropertyChanges
ServerVariableChanges map[string]*ServerVariableChanges `json:"serverVariables,omitempty" yaml:"serverVariables,omitempty"`
}
// TotalChanges returns total changes found between two OpenAPI Server Objects
func (s *ServerChanges) TotalChanges() int {
c := s.PropertyChanges.TotalChanges()
for k := range s.ServerVariableChanges {
@@ -21,6 +23,7 @@ func (s *ServerChanges) TotalChanges() int {
return c
}
// TotalBreakingChanges returns the total number of breaking changes found between two OpenAPI Server objects.
func (s *ServerChanges) TotalBreakingChanges() int {
c := s.PropertyChanges.TotalBreakingChanges()
for k := range s.ServerVariableChanges {
@@ -29,6 +32,8 @@ func (s *ServerChanges) TotalBreakingChanges() int {
return c
}
// CompareServers compares two OpenAPI Server objects for any changes. If anything is found, returns a pointer
// to a ServerChanges instance, or returns nil if nothing is found.
func CompareServers(l, r *v3.Server) *ServerChanges {
if low.AreEqual(l, r) {
return nil