Moved what-changed PropertyChanges to a pointer in all models.

No breaking changes, gofmt seems to have gone a little nuts for some reason, but this is an internal change that moves everything to a pointer, for better reflection use down the chain.
This commit is contained in:
Dave Shanley
2022-11-23 12:57:10 -05:00
parent 726134f00e
commit 0e0b99225d
33 changed files with 4339 additions and 4333 deletions

View File

@@ -10,7 +10,7 @@ import (
// CallbackChanges represents all changes made between two Callback OpenAPI objects. // CallbackChanges represents all changes made between two Callback OpenAPI objects.
type CallbackChanges struct { type CallbackChanges struct {
PropertyChanges *PropertyChanges
ExpressionChanges map[string]*PathItemChanges `json:"expressions,omitempty" yaml:"expressions,omitempty"` ExpressionChanges map[string]*PathItemChanges `json:"expressions,omitempty" yaml:"expressions,omitempty"`
ExtensionChanges *ExtensionChanges `json:"extensions,omitempty" yaml:"extensions,omitempty"` ExtensionChanges *ExtensionChanges `json:"extensions,omitempty" yaml:"extensions,omitempty"`
} }
@@ -92,7 +92,7 @@ func CompareCallback(l, r *v3.Callback) *CallbackChanges {
} }
cc.ExpressionChanges = expChanges cc.ExpressionChanges = expChanges
cc.ExtensionChanges = CompareExtensions(l.Extensions, r.Extensions) cc.ExtensionChanges = CompareExtensions(l.Extensions, r.Extensions)
cc.Changes = changes cc.PropertyChanges = NewPropertyChanges(changes)
if cc.TotalChanges() <= 0 { if cc.TotalChanges() <= 0 {
return nil return nil
} }

View File

@@ -109,6 +109,10 @@ func (p PropertyChanges) TotalBreakingChanges() int {
return CountBreakingChanges(p.Changes) return CountBreakingChanges(p.Changes)
} }
func NewPropertyChanges(changes []*Change) *PropertyChanges {
return &PropertyChanges{Changes: changes}
}
// SortByChangeType will order changes by the types of change they represent, // SortByChangeType will order changes by the types of change they represent,
// This is a destructive action and will permanently re-order Changes. // This is a destructive action and will permanently re-order Changes.
//func (p PropertyChanges[T]) SortByChangeType() { //func (p PropertyChanges[T]) SortByChangeType() {

View File

@@ -35,7 +35,7 @@ import (
// modifications are not checked, these checks occur in-place by implementing objects as they are autp-resolved // modifications are not checked, these checks occur in-place by implementing objects as they are autp-resolved
// when the model is built. // when the model is built.
type ComponentsChanges struct { type ComponentsChanges struct {
PropertyChanges *PropertyChanges
SchemaChanges map[string]*SchemaChanges `json:"schemas,omitempty" yaml:"schemas,omitempty"` SchemaChanges map[string]*SchemaChanges `json:"schemas,omitempty" yaml:"schemas,omitempty"`
SecuritySchemeChanges map[string]*SecuritySchemeChanges `json:"securitySchemes,omitempty" yaml:"securitySchemes,omitempty"` SecuritySchemeChanges map[string]*SecuritySchemeChanges `json:"securitySchemes,omitempty" yaml:"securitySchemes,omitempty"`
ExtensionChanges *ExtensionChanges `json:"extensions,omitempty" yaml:"extensions,omitempty"` ExtensionChanges *ExtensionChanges `json:"extensions,omitempty" yaml:"extensions,omitempty"`
@@ -203,7 +203,7 @@ func CompareComponents(l, r any) *ComponentsChanges {
} }
} }
cc.Changes = changes cc.PropertyChanges = NewPropertyChanges(changes)
if cc.TotalChanges() <= 0 { if cc.TotalChanges() <= 0 {
return nil return nil
} }

View File

@@ -10,7 +10,7 @@ import (
// ContactChanges Represent changes to a Contact object that is a child of Info, part of an OpenAPI document. // ContactChanges Represent changes to a Contact object that is a child of Info, part of an OpenAPI document.
type ContactChanges struct { type ContactChanges struct {
PropertyChanges *PropertyChanges
} }
// TotalChanges represents the total number of changes that have occurred to a Contact object // TotalChanges represents the total number of changes that have occurred to a Contact object
@@ -68,7 +68,7 @@ func CompareContact(l, r *base.Contact) *ContactChanges {
CheckProperties(props) CheckProperties(props)
dc := new(ContactChanges) dc := new(ContactChanges)
dc.Changes = changes dc.PropertyChanges = NewPropertyChanges(changes)
if dc.TotalChanges() <= 0 { if dc.TotalChanges() <= 0 {
return nil return nil
} }

View File

@@ -10,7 +10,7 @@ import (
// DiscriminatorChanges represents changes made to a Discriminator OpenAPI object // DiscriminatorChanges represents changes made to a Discriminator OpenAPI object
type DiscriminatorChanges struct { type DiscriminatorChanges struct {
PropertyChanges *PropertyChanges
MappingChanges []*Change `json:"mappings,omitempty" yaml:"mappings,omitempty"` MappingChanges []*Change `json:"mappings,omitempty" yaml:"mappings,omitempty"`
} }
@@ -76,7 +76,7 @@ func CompareDiscriminator(l, r *base.Discriminator) *DiscriminatorChanges {
} }
} }
dc.Changes = changes dc.PropertyChanges = NewPropertyChanges(changes)
dc.MappingChanges = mappingChanges dc.MappingChanges = mappingChanges
if dc.TotalChanges() <= 0 { if dc.TotalChanges() <= 0 {
return nil return nil

View File

@@ -20,7 +20,7 @@ import (
// DocumentChanges represents all the changes made to an OpenAPI document. // DocumentChanges represents all the changes made to an OpenAPI document.
type DocumentChanges struct { type DocumentChanges struct {
PropertyChanges *PropertyChanges
InfoChanges *InfoChanges `json:"info,omitempty" yaml:"info,omitempty"` InfoChanges *InfoChanges `json:"info,omitempty" yaml:"info,omitempty"`
PathsChanges *PathsChanges `json:"paths,omitempty" yaml:"paths,omitempty"` PathsChanges *PathsChanges `json:"paths,omitempty" yaml:"paths,omitempty"`
TagChanges []*TagChanges `json:"tags,omitempty" yaml:"tags,omitempty"` TagChanges []*TagChanges `json:"tags,omitempty" yaml:"tags,omitempty"`
@@ -160,6 +160,7 @@ func CompareDocuments(l, r any) *DocumentChanges {
// placing it under a parent, like they did with OpenAPI. This means picking through each definition // placing it under a parent, like they did with OpenAPI. This means picking through each definition
// creating a new set of changes and then morphing them into a single changes object. // creating a new set of changes and then morphing them into a single changes object.
cc := new(ComponentsChanges) cc := new(ComponentsChanges)
cc.PropertyChanges = new(PropertyChanges)
if n := CompareComponents(lDoc.Definitions.Value, rDoc.Definitions.Value); n != nil { if n := CompareComponents(lDoc.Definitions.Value, rDoc.Definitions.Value); n != nil {
cc.SchemaChanges = n.SchemaChanges cc.SchemaChanges = n.SchemaChanges
} }
@@ -167,7 +168,7 @@ func CompareDocuments(l, r any) *DocumentChanges {
cc.SecuritySchemeChanges = n.SecuritySchemeChanges cc.SecuritySchemeChanges = n.SecuritySchemeChanges
} }
if n := CompareComponents(lDoc.Parameters.Value, rDoc.Parameters.Value); n != nil { if n := CompareComponents(lDoc.Parameters.Value, rDoc.Parameters.Value); n != nil {
cc.Changes = append(cc.Changes, n.Changes...) cc.PropertyChanges.Changes = append(cc.PropertyChanges.Changes, n.Changes...)
} }
if n := CompareComponents(lDoc.Responses.Value, rDoc.Responses.Value); n != nil { if n := CompareComponents(lDoc.Responses.Value, rDoc.Responses.Value); n != nil {
cc.Changes = append(cc.Changes, n.Changes...) cc.Changes = append(cc.Changes, n.Changes...)
@@ -238,7 +239,7 @@ func CompareDocuments(l, r any) *DocumentChanges {
} }
CheckProperties(props) CheckProperties(props)
dc.Changes = changes dc.PropertyChanges = NewPropertyChanges(changes)
if dc.TotalChanges() <= 0 { if dc.TotalChanges() <= 0 {
return nil return nil
} }

View File

@@ -9,7 +9,7 @@ import (
// EncodingChanges represent all the changes made to an Encoding object // EncodingChanges represent all the changes made to an Encoding object
type EncodingChanges struct { type EncodingChanges struct {
PropertyChanges *PropertyChanges
HeaderChanges map[string]*HeaderChanges `json:"headers,omitempty" yaml:"headers,omitempty"` HeaderChanges map[string]*HeaderChanges `json:"headers,omitempty" yaml:"headers,omitempty"`
} }
@@ -81,7 +81,7 @@ func CompareEncoding(l, r *v3.Encoding) *EncodingChanges {
// headers // headers
ec.HeaderChanges = CheckMapForChanges(l.Headers.Value, r.Headers.Value, &changes, v3.HeadersLabel, CompareHeadersV3) ec.HeaderChanges = CheckMapForChanges(l.Headers.Value, r.Headers.Value, &changes, v3.HeadersLabel, CompareHeadersV3)
ec.Changes = changes ec.PropertyChanges = NewPropertyChanges(changes)
if ec.TotalChanges() <= 0 { if ec.TotalChanges() <= 0 {
return nil return nil
} }

View File

@@ -14,7 +14,7 @@ import (
// ExampleChanges represent changes to an Example object, part of an OpenAPI specification. // ExampleChanges represent changes to an Example object, part of an OpenAPI specification.
type ExampleChanges struct { type ExampleChanges struct {
PropertyChanges *PropertyChanges
ExtensionChanges *ExtensionChanges `json:"extensions,omitempty" yaml:"extensions,omitempty"` ExtensionChanges *ExtensionChanges `json:"extensions,omitempty" yaml:"extensions,omitempty"`
} }
@@ -174,7 +174,7 @@ func CompareExamples(l, r *base.Example) *ExampleChanges {
// check extensions // check extensions
ec.ExtensionChanges = CheckExtensions(l, r) ec.ExtensionChanges = CheckExtensions(l, r)
ec.Changes = changes ec.PropertyChanges = NewPropertyChanges(changes)
if ec.TotalChanges() <= 0 { if ec.TotalChanges() <= 0 {
return nil return nil
} }

View File

@@ -10,7 +10,7 @@ import (
// ExamplesChanges represents changes made between Swagger Examples objects (Not OpenAPI 3). // ExamplesChanges represents changes made between Swagger Examples objects (Not OpenAPI 3).
type ExamplesChanges struct { type ExamplesChanges struct {
PropertyChanges *PropertyChanges
} }
// TotalChanges represents the total number of changes made between Example instances. // TotalChanges represents the total number of changes made between Example instances.
@@ -73,7 +73,7 @@ func CompareExamplesV2(l, r *v2.Examples) *ExamplesChanges {
} }
ex := new(ExamplesChanges) ex := new(ExamplesChanges)
ex.Changes = changes ex.PropertyChanges = NewPropertyChanges(changes)
if ex.TotalChanges() <= 0 { if ex.TotalChanges() <= 0 {
return nil return nil
} }

View File

@@ -10,7 +10,7 @@ import (
// ExtensionChanges represents any changes to custom extensions defined for an OpenAPI object. // ExtensionChanges represents any changes to custom extensions defined for an OpenAPI object.
type ExtensionChanges struct { type ExtensionChanges struct {
PropertyChanges *PropertyChanges
} }
// TotalChanges returns the total number of object extensions that were made. // TotalChanges returns the total number of object extensions that were made.
@@ -71,7 +71,7 @@ func CompareExtensions(l, r map[low.KeyReference[string]]low.ValueReference[any]
} }
} }
ex := new(ExtensionChanges) ex := new(ExtensionChanges)
ex.Changes = changes ex.PropertyChanges = NewPropertyChanges(changes)
if ex.TotalChanges() <= 0 { if ex.TotalChanges() <= 0 {
return nil return nil
} }

View File

@@ -10,7 +10,7 @@ import (
// ExternalDocChanges represents changes made to any ExternalDoc object from an OpenAPI document. // ExternalDocChanges represents changes made to any ExternalDoc object from an OpenAPI document.
type ExternalDocChanges struct { type ExternalDocChanges struct {
PropertyChanges *PropertyChanges
ExtensionChanges *ExtensionChanges `json:"extensions,omitempty" yaml:"extensions,omitempty"` ExtensionChanges *ExtensionChanges `json:"extensions,omitempty" yaml:"extensions,omitempty"`
} }
@@ -61,7 +61,7 @@ func CompareExternalDocs(l, r *base.ExternalDoc) *ExternalDocChanges {
CheckProperties(props) CheckProperties(props)
dc := new(ExternalDocChanges) dc := new(ExternalDocChanges)
dc.Changes = changes dc.PropertyChanges = NewPropertyChanges(changes)
// check extensions // check extensions
dc.ExtensionChanges = CheckExtensions(l, r) dc.ExtensionChanges = CheckExtensions(l, r)

View File

@@ -13,7 +13,7 @@ import (
// HeaderChanges represents changes made between two Header objects. Supports both Swagger and OpenAPI header // HeaderChanges represents changes made between two Header objects. Supports both Swagger and OpenAPI header
// objects, V2 only property Items is broken out into its own. // objects, V2 only property Items is broken out into its own.
type HeaderChanges struct { type HeaderChanges struct {
PropertyChanges *PropertyChanges
SchemaChanges *SchemaChanges `json:"schemas,omitempty" yaml:"schemas,omitempty"` SchemaChanges *SchemaChanges `json:"schemas,omitempty" yaml:"schemas,omitempty"`
ExamplesChanges map[string]*ExampleChanges `json:"examples,omitempty" yaml:"examples,omitempty"` ExamplesChanges map[string]*ExampleChanges `json:"examples,omitempty" yaml:"examples,omitempty"`
ContentChanges map[string]*MediaTypeChanges `json:"content,omitempty" yaml:"content,omitempty"` ContentChanges map[string]*MediaTypeChanges `json:"content,omitempty" yaml:"content,omitempty"`
@@ -253,6 +253,6 @@ func CompareHeaders(l, r any) *HeaderChanges {
} }
CheckProperties(props) CheckProperties(props)
hc.Changes = changes hc.PropertyChanges = NewPropertyChanges(changes)
return hc return hc
} }

View File

@@ -10,7 +10,7 @@ import (
// InfoChanges represents the number of changes to an Info object. Part of an OpenAPI document // InfoChanges represents the number of changes to an Info object. Part of an OpenAPI document
type InfoChanges struct { type InfoChanges struct {
PropertyChanges *PropertyChanges
ContactChanges *ContactChanges `json:"contact,omitempty" yaml:"contact,omitempty"` ContactChanges *ContactChanges `json:"contact,omitempty" yaml:"contact,omitempty"`
LicenseChanges *LicenseChanges `json:"license,omitempty" yaml:"license,omitempty"` LicenseChanges *LicenseChanges `json:"license,omitempty" yaml:"license,omitempty"`
} }
@@ -116,7 +116,7 @@ func CompareInfo(l, r *base.Info) *InfoChanges {
l.License.ValueNode, nil, false, r.License.Value, nil) l.License.ValueNode, nil, false, r.License.Value, nil)
} }
} }
i.Changes = changes i.PropertyChanges = NewPropertyChanges(changes)
if i.TotalChanges() <= 0 { if i.TotalChanges() <= 0 {
return nil return nil
} }

View File

@@ -11,7 +11,7 @@ import (
// ItemsChanges represent changes found between a left (original) and right (modified) object. Items is only // ItemsChanges represent changes found between a left (original) and right (modified) object. Items is only
// used by Swagger documents. // used by Swagger documents.
type ItemsChanges struct { type ItemsChanges struct {
PropertyChanges *PropertyChanges
ItemsChanges *ItemsChanges `json:"items,omitempty" yaml:"items,omitempty"` ItemsChanges *ItemsChanges `json:"items,omitempty" yaml:"items,omitempty"`
} }
@@ -70,7 +70,7 @@ func CompareItems(l, r *v2.Items) *ItemsChanges {
l.Items.GetValueNode(), nil, true, l.Items.GetValue(), l.Items.GetValueNode(), nil, true, l.Items.GetValue(),
nil) nil)
} }
ic.Changes = changes ic.PropertyChanges = NewPropertyChanges(changes)
if ic.TotalChanges() <= 0 { if ic.TotalChanges() <= 0 {
return nil return nil
} }

View File

@@ -10,7 +10,7 @@ import (
// LicenseChanges represent changes to a License object that is a child of Info object. Part of an OpenAPI document // LicenseChanges represent changes to a License object that is a child of Info object. Part of an OpenAPI document
type LicenseChanges struct { type LicenseChanges struct {
PropertyChanges *PropertyChanges
} }
// TotalChanges represents the total number of changes made to a License instance. // TotalChanges represents the total number of changes made to a License instance.
@@ -57,7 +57,7 @@ func CompareLicense(l, r *base.License) *LicenseChanges {
CheckProperties(props) CheckProperties(props)
lc := new(LicenseChanges) lc := new(LicenseChanges)
lc.Changes = changes lc.PropertyChanges = NewPropertyChanges(changes)
if lc.TotalChanges() <= 0 { if lc.TotalChanges() <= 0 {
return nil return nil
} }

View File

@@ -10,7 +10,7 @@ import (
// LinkChanges represent changes made between two OpenAPI Link Objects. // LinkChanges represent changes made between two OpenAPI Link Objects.
type LinkChanges struct { type LinkChanges struct {
PropertyChanges *PropertyChanges
ExtensionChanges *ExtensionChanges `json:"extensions,omitempty" yaml:"extensions,omitempty"` ExtensionChanges *ExtensionChanges `json:"extensions,omitempty" yaml:"extensions,omitempty"`
ServerChanges *ServerChanges `json:"server,omitempty" yaml:"server,omitempty"` ServerChanges *ServerChanges `json:"server,omitempty" yaml:"server,omitempty"`
} }
@@ -142,6 +142,6 @@ func CompareLinks(l, r *v3.Link) *LinkChanges {
} }
} }
lc.Changes = changes lc.PropertyChanges = NewPropertyChanges(changes)
return lc return lc
} }

View File

@@ -13,7 +13,7 @@ import (
// MediaTypeChanges represent changes made between two OpenAPI MediaType instances. // MediaTypeChanges represent changes made between two OpenAPI MediaType instances.
type MediaTypeChanges struct { type MediaTypeChanges struct {
PropertyChanges *PropertyChanges
SchemaChanges *SchemaChanges `json:"schemas,omitempty" yaml:"schemas,omitempty"` SchemaChanges *SchemaChanges `json:"schemas,omitempty" yaml:"schemas,omitempty"`
ExtensionChanges *ExtensionChanges `json:"extensions,omitempty" yaml:"extensions,omitempty"` ExtensionChanges *ExtensionChanges `json:"extensions,omitempty" yaml:"extensions,omitempty"`
ExampleChanges map[string]*ExampleChanges `json:"examples,omitempty" yaml:"examples,omitempty"` ExampleChanges map[string]*ExampleChanges `json:"examples,omitempty" yaml:"examples,omitempty"`
@@ -130,7 +130,7 @@ func CompareMediaTypes(l, r *v3.MediaType) *MediaTypeChanges {
&changes, v3.EncodingLabel, CompareEncoding) &changes, v3.EncodingLabel, CompareEncoding)
mc.ExtensionChanges = CompareExtensions(l.Extensions, r.Extensions) mc.ExtensionChanges = CompareExtensions(l.Extensions, r.Extensions)
mc.Changes = changes mc.PropertyChanges = NewPropertyChanges(changes)
if mc.TotalChanges() <= 0 { if mc.TotalChanges() <= 0 {
return nil return nil

View File

@@ -10,7 +10,7 @@ import (
// OAuthFlowsChanges represents changes found between two OpenAPI OAuthFlows objects. // OAuthFlowsChanges represents changes found between two OpenAPI OAuthFlows objects.
type OAuthFlowsChanges struct { type OAuthFlowsChanges struct {
PropertyChanges *PropertyChanges
ImplicitChanges *OAuthFlowChanges `json:"implicit,omitempty" yaml:"implicit,omitempty"` ImplicitChanges *OAuthFlowChanges `json:"implicit,omitempty" yaml:"implicit,omitempty"`
PasswordChanges *OAuthFlowChanges `json:"password,omitempty" yaml:"password,omitempty"` PasswordChanges *OAuthFlowChanges `json:"password,omitempty" yaml:"password,omitempty"`
ClientCredentialsChanges *OAuthFlowChanges `json:"clientCredentials,omitempty" yaml:"clientCredentials,omitempty"` ClientCredentialsChanges *OAuthFlowChanges `json:"clientCredentials,omitempty" yaml:"clientCredentials,omitempty"`
@@ -127,13 +127,13 @@ func CompareOAuthFlows(l, r *v3.OAuthFlows) *OAuthFlowsChanges {
nil, r.AuthorizationCode.Value) nil, r.AuthorizationCode.Value)
} }
oa.ExtensionChanges = CompareExtensions(l.Extensions, r.Extensions) oa.ExtensionChanges = CompareExtensions(l.Extensions, r.Extensions)
oa.Changes = changes oa.PropertyChanges = NewPropertyChanges(changes)
return oa return oa
} }
// OAuthFlowChanges represents an OpenAPI OAuthFlow object. // OAuthFlowChanges represents an OpenAPI OAuthFlow object.
type OAuthFlowChanges struct { type OAuthFlowChanges struct {
PropertyChanges *PropertyChanges
ExtensionChanges *ExtensionChanges `json:"extensions,omitempty" yaml:"extensions,omitempty"` ExtensionChanges *ExtensionChanges `json:"extensions,omitempty" yaml:"extensions,omitempty"`
} }
@@ -219,7 +219,7 @@ func CompareOAuthFlow(l, r *v3.OAuthFlow) *OAuthFlowChanges {
} }
} }
oa := new(OAuthFlowChanges) oa := new(OAuthFlowChanges)
oa.Changes = changes oa.PropertyChanges = NewPropertyChanges(changes)
oa.ExtensionChanges = CompareExtensions(l.Extensions, r.Extensions) oa.ExtensionChanges = CompareExtensions(l.Extensions, r.Extensions)
return oa return oa
} }

View File

@@ -16,7 +16,7 @@ import (
// OperationChanges represent changes made between two Swagger or OpenAPI Operation objects. // OperationChanges represent changes made between two Swagger or OpenAPI Operation objects.
type OperationChanges struct { type OperationChanges struct {
PropertyChanges *PropertyChanges
ExternalDocChanges *ExternalDocChanges `json:"externalDoc,omitempty" yaml:"externalDoc,omitempty"` ExternalDocChanges *ExternalDocChanges `json:"externalDoc,omitempty" yaml:"externalDoc,omitempty"`
ParameterChanges []*ParameterChanges `json:"parameters,omitempty" yaml:"parameters,omitempty"` ParameterChanges []*ParameterChanges `json:"parameters,omitempty" yaml:"parameters,omitempty"`
ResponsesChanges *ResponsesChanges `json:"responses,omitempty" yaml:"responses,omitempty"` ResponsesChanges *ResponsesChanges `json:"responses,omitempty" yaml:"responses,omitempty"`
@@ -84,7 +84,6 @@ func (o *OperationChanges) TotalBreakingChanges() int {
for k := range o.ServerChanges { for k := range o.ServerChanges {
c += o.ServerChanges[k].TotalBreakingChanges() c += o.ServerChanges[k].TotalBreakingChanges()
} }
// todo: add callbacks in here.
return c return c
} }
@@ -377,7 +376,7 @@ func CompareOperations(l, r any) *OperationChanges {
// todo: callbacks // todo: callbacks
} }
CheckProperties(props) CheckProperties(props)
oc.Changes = changes oc.PropertyChanges = NewPropertyChanges(changes)
return oc return oc
} }
@@ -425,7 +424,7 @@ func checkServers(lServers, rServers low.NodeReference[[]low.ValueReference[*v3.
lv[k].ValueNode, nil, true, lv[k].Value.URL.Value, lv[k].ValueNode, nil, true, lv[k].Value.URL.Value,
nil) nil)
sc := new(ServerChanges) sc := new(ServerChanges)
sc.Changes = changes sc.PropertyChanges = NewPropertyChanges(changes)
serverChanges = append(serverChanges, sc) serverChanges = append(serverChanges, sc)
} }
@@ -441,7 +440,7 @@ func checkServers(lServers, rServers low.NodeReference[[]low.ValueReference[*v3.
rv[k].Value.URL.Value) rv[k].Value.URL.Value)
sc := new(ServerChanges) sc := new(ServerChanges)
sc.Changes = changes sc.PropertyChanges = NewPropertyChanges(changes)
serverChanges = append(serverChanges, sc) serverChanges = append(serverChanges, sc)
} }
@@ -459,7 +458,7 @@ func checkServers(lServers, rServers low.NodeReference[[]low.ValueReference[*v3.
nil, rServers.ValueNode, false, nil, nil, rServers.ValueNode, false, nil,
rServers.Value) rServers.Value)
} }
sc.Changes = changes sc.PropertyChanges = NewPropertyChanges(changes)
if len(changes) > 0 { if len(changes) > 0 {
serverChanges = append(serverChanges, sc) serverChanges = append(serverChanges, sc)
} }

View File

@@ -14,7 +14,7 @@ import (
// ParameterChanges represents changes found between Swagger or OpenAPI Parameter objects. // ParameterChanges represents changes found between Swagger or OpenAPI Parameter objects.
type ParameterChanges struct { type ParameterChanges struct {
PropertyChanges *PropertyChanges
SchemaChanges *SchemaChanges `json:"schemas,omitempty" yaml:"schemas,omitempty"` SchemaChanges *SchemaChanges `json:"schemas,omitempty" yaml:"schemas,omitempty"`
ExtensionChanges *ExtensionChanges `json:"extensions,omitempty" yaml:"extensions,omitempty"` ExtensionChanges *ExtensionChanges `json:"extensions,omitempty" yaml:"extensions,omitempty"`
@@ -304,7 +304,7 @@ func CompareParameters(l, r any) *ParameterChanges {
rSchema) rSchema)
} }
pc.Changes = changes pc.PropertyChanges = NewPropertyChanges(changes)
pc.ExtensionChanges = CompareExtensions(lext, rext) pc.ExtensionChanges = CompareExtensions(lext, rext)
if pc.TotalChanges() <= 0 { if pc.TotalChanges() <= 0 {
return nil return nil

View File

@@ -12,7 +12,7 @@ import (
// PathItemChanges represents changes found between to Swagger or OpenAPI PathItem object. // PathItemChanges represents changes found between to Swagger or OpenAPI PathItem object.
type PathItemChanges struct { type PathItemChanges struct {
PropertyChanges *PropertyChanges
GetChanges *OperationChanges `json:"get,omitempty" yaml:"get,omitempty"` GetChanges *OperationChanges `json:"get,omitempty" yaml:"get,omitempty"`
PutChanges *OperationChanges `json:"put,omitempty" yaml:"put,omitempty"` PutChanges *OperationChanges `json:"put,omitempty" yaml:"put,omitempty"`
PostChanges *OperationChanges `json:"post,omitempty" yaml:"post,omitempty"` PostChanges *OperationChanges `json:"post,omitempty" yaml:"post,omitempty"`
@@ -173,7 +173,7 @@ func ComparePathItems(l, r any) *PathItemChanges {
} }
CheckProperties(props) CheckProperties(props)
pc.Changes = changes pc.PropertyChanges = NewPropertyChanges(changes)
return pc return pc
} }

View File

@@ -13,7 +13,7 @@ import (
// PathsChanges represents changes found between two Swagger or OpenAPI Paths Objects. // PathsChanges represents changes found between two Swagger or OpenAPI Paths Objects.
type PathsChanges struct { type PathsChanges struct {
PropertyChanges *PropertyChanges
PathItemsChanges map[string]*PathItemChanges `json:"pathItems,omitempty" yaml:"pathItems,omitempty"` PathItemsChanges map[string]*PathItemChanges `json:"pathItems,omitempty" yaml:"pathItems,omitempty"`
ExtensionChanges *ExtensionChanges `json:"extensions,omitempty" yaml:"extensions,omitempty"` ExtensionChanges *ExtensionChanges `json:"extensions,omitempty" yaml:"extensions,omitempty"`
} }
@@ -188,6 +188,6 @@ func ComparePaths(l, r any) *PathsChanges {
pc.ExtensionChanges = CompareExtensions(lPath.Extensions, rPath.Extensions) pc.ExtensionChanges = CompareExtensions(lPath.Extensions, rPath.Extensions)
} }
pc.Changes = changes pc.PropertyChanges = NewPropertyChanges(changes)
return pc return pc
} }

View File

@@ -10,7 +10,7 @@ import (
// RequestBodyChanges represents changes made between two OpenAPI RequestBody Objects // RequestBodyChanges represents changes made between two OpenAPI RequestBody Objects
type RequestBodyChanges struct { type RequestBodyChanges struct {
PropertyChanges *PropertyChanges
ContentChanges map[string]*MediaTypeChanges `json:"content,omitempty" yaml:"content,omitempty"` ContentChanges map[string]*MediaTypeChanges `json:"content,omitempty" yaml:"content,omitempty"`
ExtensionChanges *ExtensionChanges `json:"extensions,omitempty" yaml:"extensions,omitempty"` ExtensionChanges *ExtensionChanges `json:"extensions,omitempty" yaml:"extensions,omitempty"`
} }
@@ -74,7 +74,7 @@ func CompareRequestBodies(l, r *v3.RequestBody) *RequestBodyChanges {
rbc.ContentChanges = CheckMapForChanges(l.Content.Value, r.Content.Value, rbc.ContentChanges = CheckMapForChanges(l.Content.Value, r.Content.Value,
&changes, v3.ContentLabel, CompareMediaTypes) &changes, v3.ContentLabel, CompareMediaTypes)
rbc.ExtensionChanges = CompareExtensions(l.Extensions, r.Extensions) rbc.ExtensionChanges = CompareExtensions(l.Extensions, r.Extensions)
rbc.Changes = changes rbc.PropertyChanges = NewPropertyChanges(changes)
return rbc return rbc
} }

View File

@@ -12,7 +12,7 @@ import (
// ResponseChanges represents changes found between two Swagger or OpenAPI Response objects. // ResponseChanges represents changes found between two Swagger or OpenAPI Response objects.
type ResponseChanges struct { type ResponseChanges struct {
PropertyChanges *PropertyChanges
ExtensionChanges *ExtensionChanges `json:"extensions,omitempty" yaml:"extensions,omitempty"` ExtensionChanges *ExtensionChanges `json:"extensions,omitempty" yaml:"extensions,omitempty"`
HeadersChanges map[string]*HeaderChanges `json:"headers,omitempty" yaml:"headers,omitempty"` HeadersChanges map[string]*HeaderChanges `json:"headers,omitempty" yaml:"headers,omitempty"`
@@ -167,7 +167,7 @@ func CompareResponse(l, r any) *ResponseChanges {
} }
CheckProperties(props) CheckProperties(props)
rc.Changes = changes rc.PropertyChanges = NewPropertyChanges(changes)
if rc.TotalChanges() <= 0 { if rc.TotalChanges() <= 0 {
return nil return nil
} }

View File

@@ -12,7 +12,7 @@ import (
// ResponsesChanges represents changes made between two Swagger or OpenAPI Responses objects. // ResponsesChanges represents changes made between two Swagger or OpenAPI Responses objects.
type ResponsesChanges struct { type ResponsesChanges struct {
PropertyChanges *PropertyChanges
ResponseChanges map[string]*ResponseChanges `json:"response,omitempty" yaml:"response,omitempty"` ResponseChanges map[string]*ResponseChanges `json:"response,omitempty" yaml:"response,omitempty"`
DefaultChanges *ResponseChanges `json:"default,omitempty" yaml:"default,omitempty"` DefaultChanges *ResponseChanges `json:"default,omitempty" yaml:"default,omitempty"`
ExtensionChanges *ExtensionChanges `json:"extensions,omitempty" yaml:"extensions,omitempty"` ExtensionChanges *ExtensionChanges `json:"extensions,omitempty" yaml:"extensions,omitempty"`
@@ -119,6 +119,6 @@ func CompareResponses(l, r any) *ResponsesChanges {
} }
rc.Changes = changes rc.PropertyChanges = NewPropertyChanges(changes)
return rc return rc
} }

View File

@@ -21,7 +21,7 @@ import (
// changes, and not the child for example, adding a new schema to `anyOf` will create a new change result in // changes, and not the child for example, adding a new schema to `anyOf` will create a new change result in
// PropertyChanges.Changes, and not in the AnyOfChanges property. // PropertyChanges.Changes, and not in the AnyOfChanges property.
type SchemaChanges struct { type SchemaChanges struct {
PropertyChanges *PropertyChanges
DiscriminatorChanges *DiscriminatorChanges `json:"discriminator,omitempty" yaml:"discriminator,omitempty"` DiscriminatorChanges *DiscriminatorChanges `json:"discriminator,omitempty" yaml:"discriminator,omitempty"`
AllOfChanges []*SchemaChanges `json:"allOf,omitempty" yaml:"allOf,omitempty"` AllOfChanges []*SchemaChanges `json:"allOf,omitempty" yaml:"allOf,omitempty"`
AnyOfChanges []*SchemaChanges `json:"anyOf,omitempty" yaml:"anyOf,omitempty"` AnyOfChanges []*SchemaChanges `json:"anyOf,omitempty" yaml:"anyOf,omitempty"`
@@ -139,14 +139,14 @@ func CompareSchemas(l, r *base.SchemaProxy) *SchemaChanges {
if l == nil && r != nil { if l == nil && r != nil {
CreateChange(&changes, ObjectAdded, v3.SchemaLabel, CreateChange(&changes, ObjectAdded, v3.SchemaLabel,
nil, nil, true, nil, r) nil, nil, true, nil, r)
sc.Changes = changes sc.PropertyChanges = NewPropertyChanges(changes)
} }
// Removed // Removed
if l != nil && r == nil { if l != nil && r == nil {
CreateChange(&changes, ObjectRemoved, v3.SchemaLabel, CreateChange(&changes, ObjectRemoved, v3.SchemaLabel,
nil, nil, true, l, nil) nil, nil, true, l, nil)
sc.Changes = changes sc.PropertyChanges = NewPropertyChanges(changes)
} }
if l != nil && r != nil { if l != nil && r != nil {
@@ -162,7 +162,7 @@ func CompareSchemas(l, r *base.SchemaProxy) *SchemaChanges {
CreateChange(&changes, Modified, v3.RefLabel, CreateChange(&changes, Modified, v3.RefLabel,
l.GetValueNode().Content[1], r.GetValueNode().Content[1], true, l.GetSchemaReference(), l.GetValueNode().Content[1], r.GetValueNode().Content[1], true, l.GetSchemaReference(),
r.GetSchemaReference()) r.GetSchemaReference())
sc.Changes = changes sc.PropertyChanges = NewPropertyChanges(changes)
return sc return sc
} }
} }
@@ -171,7 +171,7 @@ func CompareSchemas(l, r *base.SchemaProxy) *SchemaChanges {
if !l.IsSchemaReference() && r.IsSchemaReference() { if !l.IsSchemaReference() && r.IsSchemaReference() {
CreateChange(&changes, Modified, v3.RefLabel, CreateChange(&changes, Modified, v3.RefLabel,
l.GetValueNode(), r.GetValueNode().Content[1], true, l, r.GetSchemaReference()) l.GetValueNode(), r.GetValueNode().Content[1], true, l, r.GetSchemaReference())
sc.Changes = changes sc.PropertyChanges = NewPropertyChanges(changes)
return sc // we're done here return sc // we're done here
} }
@@ -179,7 +179,7 @@ func CompareSchemas(l, r *base.SchemaProxy) *SchemaChanges {
if l.IsSchemaReference() && !r.IsSchemaReference() { if l.IsSchemaReference() && !r.IsSchemaReference() {
CreateChange(&changes, Modified, v3.RefLabel, CreateChange(&changes, Modified, v3.RefLabel,
l.GetValueNode().Content[1], r.GetValueNode(), true, l.GetSchemaReference(), r) l.GetValueNode().Content[1], r.GetValueNode(), true, l.GetSchemaReference(), r)
sc.Changes = changes sc.PropertyChanges = NewPropertyChanges(changes)
return sc // done, nothing else to do. return sc // done, nothing else to do.
} }
@@ -232,7 +232,9 @@ func CompareSchemas(l, r *base.SchemaProxy) *SchemaChanges {
} }
// done // done
if changes != nil { if changes != nil {
sc.Changes = changes sc.PropertyChanges = NewPropertyChanges(changes)
} else {
sc.PropertyChanges = NewPropertyChanges(nil)
} }
return sc return sc
} }

View File

@@ -11,7 +11,7 @@ import (
// ScopesChanges represents changes between two Swagger Scopes Objects // ScopesChanges represents changes between two Swagger Scopes Objects
type ScopesChanges struct { type ScopesChanges struct {
PropertyChanges *PropertyChanges
ExtensionChanges *ExtensionChanges `json:"extensions,omitempty" yaml:"extensions,omitempty"` ExtensionChanges *ExtensionChanges `json:"extensions,omitempty" yaml:"extensions,omitempty"`
} }
@@ -60,7 +60,7 @@ func CompareScopes(l, r *v2.Scopes) *ScopesChanges {
} }
sc := new(ScopesChanges) sc := new(ScopesChanges)
sc.Changes = changes sc.PropertyChanges = NewPropertyChanges(changes)
sc.ExtensionChanges = CompareExtensions(l.Extensions, r.Extensions) sc.ExtensionChanges = CompareExtensions(l.Extensions, r.Extensions)
return sc return sc
} }

View File

@@ -12,7 +12,7 @@ import (
// SecurityRequirementChanges represents changes found between two SecurityRequirement Objects. // SecurityRequirementChanges represents changes found between two SecurityRequirement Objects.
type SecurityRequirementChanges struct { type SecurityRequirementChanges struct {
PropertyChanges *PropertyChanges
} }
// TotalChanges returns the total number of changes between two SecurityRequirement Objects. // TotalChanges returns the total number of changes between two SecurityRequirement Objects.
@@ -36,7 +36,7 @@ func CompareSecurityRequirement(l, r *base.SecurityRequirement) *SecurityRequire
return nil return nil
} }
checkSecurityRequirement(l.Requirements.Value, r.Requirements.Value, &changes) checkSecurityRequirement(l.Requirements.Value, r.Requirements.Value, &changes)
sc.Changes = changes sc.PropertyChanges = NewPropertyChanges(changes)
return sc return sc
} }

View File

@@ -12,7 +12,7 @@ import (
// SecuritySchemeChanges represents changes made between Swagger or OpenAPI SecurityScheme Objects. // SecuritySchemeChanges represents changes made between Swagger or OpenAPI SecurityScheme Objects.
type SecuritySchemeChanges struct { type SecuritySchemeChanges struct {
PropertyChanges *PropertyChanges
ExtensionChanges *ExtensionChanges `json:"extensions,omitempty" yaml:"extensions,omitempty"` ExtensionChanges *ExtensionChanges `json:"extensions,omitempty" yaml:"extensions,omitempty"`
// OpenAPI Version // OpenAPI Version
@@ -160,6 +160,6 @@ func CompareSecuritySchemes(l, r any) *SecuritySchemeChanges {
sc.ExtensionChanges = CompareExtensions(lSS.Extensions, rSS.Extensions) sc.ExtensionChanges = CompareExtensions(lSS.Extensions, rSS.Extensions)
} }
CheckProperties(props) CheckProperties(props)
sc.Changes = changes sc.PropertyChanges = NewPropertyChanges(changes)
return sc return sc
} }

View File

@@ -10,7 +10,7 @@ import (
// ServerChanges represents changes found between two OpenAPI Server Objects // ServerChanges represents changes found between two OpenAPI Server Objects
type ServerChanges struct { type ServerChanges struct {
PropertyChanges *PropertyChanges
ServerVariableChanges map[string]*ServerVariableChanges `json:"serverVariables,omitempty" yaml:"serverVariables,omitempty"` ServerVariableChanges map[string]*ServerVariableChanges `json:"serverVariables,omitempty" yaml:"serverVariables,omitempty"`
} }
@@ -64,7 +64,7 @@ func CompareServers(l, r *v3.Server) *ServerChanges {
CheckProperties(props) CheckProperties(props)
sc := new(ServerChanges) sc := new(ServerChanges)
sc.Changes = changes sc.PropertyChanges = NewPropertyChanges(changes)
sc.ServerVariableChanges = CheckMapForChanges(l.Variables.Value, r.Variables.Value, sc.ServerVariableChanges = CheckMapForChanges(l.Variables.Value, r.Variables.Value,
&changes, v3.VariablesLabel, CompareServerVariables) &changes, v3.VariablesLabel, CompareServerVariables)

View File

@@ -10,7 +10,7 @@ import (
// ServerVariableChanges represents changes found between two OpenAPI ServerVariable Objects // ServerVariableChanges represents changes found between two OpenAPI ServerVariable Objects
type ServerVariableChanges struct { type ServerVariableChanges struct {
PropertyChanges *PropertyChanges
} }
// CompareServerVariables compares a left and right OpenAPI ServerVariable object for changes. // CompareServerVariables compares a left and right OpenAPI ServerVariable object for changes.
@@ -72,6 +72,6 @@ func CompareServerVariables(l, r *v3.ServerVariable) *ServerVariableChanges {
// check everything. // check everything.
CheckProperties(props) CheckProperties(props)
sc := new(ServerVariableChanges) sc := new(ServerVariableChanges)
sc.Changes = changes sc.PropertyChanges = NewPropertyChanges(changes)
return sc return sc
} }

View File

@@ -11,7 +11,7 @@ import (
// TagChanges represents changes made to the Tags object of an OpenAPI document. // TagChanges represents changes made to the Tags object of an OpenAPI document.
type TagChanges struct { type TagChanges struct {
PropertyChanges *PropertyChanges
ExternalDocs *ExternalDocChanges `json:"externalDocs,omitempty" yaml:"externalDocs,omitempty"` ExternalDocs *ExternalDocChanges `json:"externalDocs,omitempty" yaml:"externalDocs,omitempty"`
ExtensionChanges *ExtensionChanges `json:"extensions,omitempty" yaml:"extensions,omitempty"` ExtensionChanges *ExtensionChanges `json:"extensions,omitempty" yaml:"extensions,omitempty"`
} }
@@ -107,7 +107,7 @@ func CompareTags(l, r []low.ValueReference[*base.Tag]) []*TagChanges {
// check extensions // check extensions
tc.ExtensionChanges = CompareExtensions(seenLeft[i].Value.Extensions, seenRight[i].Value.Extensions) tc.ExtensionChanges = CompareExtensions(seenLeft[i].Value.Extensions, seenRight[i].Value.Extensions)
tc.Changes = changes tc.PropertyChanges = NewPropertyChanges(changes)
if tc.TotalChanges() > 0 { if tc.TotalChanges() > 0 {
tagResults = append(tagResults, tc) tagResults = append(tagResults, tc)
} }
@@ -115,7 +115,7 @@ func CompareTags(l, r []low.ValueReference[*base.Tag]) []*TagChanges {
} }
if len(changes) > 0 { if len(changes) > 0 {
tc.Changes = changes tc.PropertyChanges = NewPropertyChanges(changes)
tagResults = append(tagResults, tc) tagResults = append(tagResults, tc)
} }
@@ -128,7 +128,7 @@ func CompareTags(l, r []low.ValueReference[*base.Tag]) []*TagChanges {
CreateChange(&changes, ObjectAdded, i, nil, seenRight[i].GetValueNode(), CreateChange(&changes, ObjectAdded, i, nil, seenRight[i].GetValueNode(),
false, nil, seenRight[i].GetValue()) false, nil, seenRight[i].GetValue())
tc.Changes = changes tc.PropertyChanges = NewPropertyChanges(changes)
tagResults = append(tagResults, tc) tagResults = append(tagResults, tc)
} }

View File

@@ -10,7 +10,7 @@ import (
// XMLChanges represents changes made to the XML object of an OpenAPI document. // XMLChanges represents changes made to the XML object of an OpenAPI document.
type XMLChanges struct { type XMLChanges struct {
PropertyChanges *PropertyChanges
ExtensionChanges *ExtensionChanges `json:"extensions,omitempty" yaml:"extensions,omitempty"` ExtensionChanges *ExtensionChanges `json:"extensions,omitempty" yaml:"extensions,omitempty"`
} }
@@ -96,7 +96,7 @@ func CompareXML(l, r *base.XML) *XMLChanges {
// check extensions // check extensions
xc.ExtensionChanges = CheckExtensions(l, r) xc.ExtensionChanges = CheckExtensions(l, r)
xc.Changes = changes xc.PropertyChanges = NewPropertyChanges(changes)
if xc.TotalChanges() <= 0 { if xc.TotalChanges() <= 0 {
return nil return nil
} }