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.
type CallbackChanges struct {
PropertyChanges
*PropertyChanges
ExpressionChanges map[string]*PathItemChanges `json:"expressions,omitempty" yaml:"expressions,omitempty"`
ExtensionChanges *ExtensionChanges `json:"extensions,omitempty" yaml:"extensions,omitempty"`
}
@@ -92,7 +92,7 @@ func CompareCallback(l, r *v3.Callback) *CallbackChanges {
}
cc.ExpressionChanges = expChanges
cc.ExtensionChanges = CompareExtensions(l.Extensions, r.Extensions)
cc.Changes = changes
cc.PropertyChanges = NewPropertyChanges(changes)
if cc.TotalChanges() <= 0 {
return nil
}

View File

@@ -109,6 +109,10 @@ func (p PropertyChanges) TotalBreakingChanges() int {
return CountBreakingChanges(p.Changes)
}
func NewPropertyChanges(changes []*Change) *PropertyChanges {
return &PropertyChanges{Changes: changes}
}
// SortByChangeType will order changes by the types of change they represent,
// This is a destructive action and will permanently re-order Changes.
//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
// when the model is built.
type ComponentsChanges struct {
PropertyChanges
*PropertyChanges
SchemaChanges map[string]*SchemaChanges `json:"schemas,omitempty" yaml:"schemas,omitempty"`
SecuritySchemeChanges map[string]*SecuritySchemeChanges `json:"securitySchemes,omitempty" yaml:"securitySchemes,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 {
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.
type ContactChanges struct {
PropertyChanges
*PropertyChanges
}
// 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)
dc := new(ContactChanges)
dc.Changes = changes
dc.PropertyChanges = NewPropertyChanges(changes)
if dc.TotalChanges() <= 0 {
return nil
}

View File

@@ -10,7 +10,7 @@ import (
// DiscriminatorChanges represents changes made to a Discriminator OpenAPI object
type DiscriminatorChanges struct {
PropertyChanges
*PropertyChanges
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
if dc.TotalChanges() <= 0 {
return nil

View File

@@ -20,7 +20,7 @@ import (
// DocumentChanges represents all the changes made to an OpenAPI document.
type DocumentChanges struct {
PropertyChanges
*PropertyChanges
InfoChanges *InfoChanges `json:"info,omitempty" yaml:"info,omitempty"`
PathsChanges *PathsChanges `json:"paths,omitempty" yaml:"paths,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
// creating a new set of changes and then morphing them into a single changes object.
cc := new(ComponentsChanges)
cc.PropertyChanges = new(PropertyChanges)
if n := CompareComponents(lDoc.Definitions.Value, rDoc.Definitions.Value); n != nil {
cc.SchemaChanges = n.SchemaChanges
}
@@ -167,7 +168,7 @@ func CompareDocuments(l, r any) *DocumentChanges {
cc.SecuritySchemeChanges = n.SecuritySchemeChanges
}
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 {
cc.Changes = append(cc.Changes, n.Changes...)
@@ -238,7 +239,7 @@ func CompareDocuments(l, r any) *DocumentChanges {
}
CheckProperties(props)
dc.Changes = changes
dc.PropertyChanges = NewPropertyChanges(changes)
if dc.TotalChanges() <= 0 {
return nil
}

View File

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

View File

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

View File

@@ -10,7 +10,7 @@ import (
// ExamplesChanges represents changes made between Swagger Examples objects (Not OpenAPI 3).
type ExamplesChanges struct {
PropertyChanges
*PropertyChanges
}
// 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.Changes = changes
ex.PropertyChanges = NewPropertyChanges(changes)
if ex.TotalChanges() <= 0 {
return nil
}

View File

@@ -10,7 +10,7 @@ import (
// ExtensionChanges represents any changes to custom extensions defined for an OpenAPI object.
type ExtensionChanges struct {
PropertyChanges
*PropertyChanges
}
// 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.Changes = changes
ex.PropertyChanges = NewPropertyChanges(changes)
if ex.TotalChanges() <= 0 {
return nil
}

View File

@@ -10,7 +10,7 @@ import (
// ExternalDocChanges represents changes made to any ExternalDoc object from an OpenAPI document.
type ExternalDocChanges struct {
PropertyChanges
*PropertyChanges
ExtensionChanges *ExtensionChanges `json:"extensions,omitempty" yaml:"extensions,omitempty"`
}
@@ -61,7 +61,7 @@ func CompareExternalDocs(l, r *base.ExternalDoc) *ExternalDocChanges {
CheckProperties(props)
dc := new(ExternalDocChanges)
dc.Changes = changes
dc.PropertyChanges = NewPropertyChanges(changes)
// check extensions
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
// objects, V2 only property Items is broken out into its own.
type HeaderChanges struct {
PropertyChanges
*PropertyChanges
SchemaChanges *SchemaChanges `json:"schemas,omitempty" yaml:"schemas,omitempty"`
ExamplesChanges map[string]*ExampleChanges `json:"examples,omitempty" yaml:"examples,omitempty"`
ContentChanges map[string]*MediaTypeChanges `json:"content,omitempty" yaml:"content,omitempty"`
@@ -253,6 +253,6 @@ func CompareHeaders(l, r any) *HeaderChanges {
}
CheckProperties(props)
hc.Changes = changes
hc.PropertyChanges = NewPropertyChanges(changes)
return hc
}

View File

@@ -10,7 +10,7 @@ import (
// InfoChanges represents the number of changes to an Info object. Part of an OpenAPI document
type InfoChanges struct {
PropertyChanges
*PropertyChanges
ContactChanges *ContactChanges `json:"contact,omitempty" yaml:"contact,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)
}
}
i.Changes = changes
i.PropertyChanges = NewPropertyChanges(changes)
if i.TotalChanges() <= 0 {
return nil
}

View File

@@ -11,7 +11,7 @@ import (
// ItemsChanges represent changes found between a left (original) and right (modified) object. Items is only
// used by Swagger documents.
type ItemsChanges struct {
PropertyChanges
*PropertyChanges
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(),
nil)
}
ic.Changes = changes
ic.PropertyChanges = NewPropertyChanges(changes)
if ic.TotalChanges() <= 0 {
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
type LicenseChanges struct {
PropertyChanges
*PropertyChanges
}
// 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)
lc := new(LicenseChanges)
lc.Changes = changes
lc.PropertyChanges = NewPropertyChanges(changes)
if lc.TotalChanges() <= 0 {
return nil
}

View File

@@ -10,7 +10,7 @@ import (
// LinkChanges represent changes made between two OpenAPI Link Objects.
type LinkChanges struct {
PropertyChanges
*PropertyChanges
ExtensionChanges *ExtensionChanges `json:"extensions,omitempty" yaml:"extensions,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
}

View File

@@ -13,7 +13,7 @@ import (
// MediaTypeChanges represent changes made between two OpenAPI MediaType instances.
type MediaTypeChanges struct {
PropertyChanges
*PropertyChanges
SchemaChanges *SchemaChanges `json:"schemas,omitempty" yaml:"schemas,omitempty"`
ExtensionChanges *ExtensionChanges `json:"extensions,omitempty" yaml:"extensions,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)
mc.ExtensionChanges = CompareExtensions(l.Extensions, r.Extensions)
mc.Changes = changes
mc.PropertyChanges = NewPropertyChanges(changes)
if mc.TotalChanges() <= 0 {
return nil

View File

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

View File

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

View File

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

View File

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

View File

@@ -13,7 +13,7 @@ import (
// PathsChanges represents changes found between two Swagger or OpenAPI Paths Objects.
type PathsChanges struct {
PropertyChanges
*PropertyChanges
PathItemsChanges map[string]*PathItemChanges `json:"pathItems,omitempty" yaml:"pathItems,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.Changes = changes
pc.PropertyChanges = NewPropertyChanges(changes)
return pc
}

View File

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

View File

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

View File

@@ -12,7 +12,7 @@ import (
// ResponsesChanges represents changes made between two Swagger or OpenAPI Responses objects.
type ResponsesChanges struct {
PropertyChanges
*PropertyChanges
ResponseChanges map[string]*ResponseChanges `json:"response,omitempty" yaml:"response,omitempty"`
DefaultChanges *ResponseChanges `json:"default,omitempty" yaml:"default,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
}

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
// PropertyChanges.Changes, and not in the AnyOfChanges property.
type SchemaChanges struct {
PropertyChanges
*PropertyChanges
DiscriminatorChanges *DiscriminatorChanges `json:"discriminator,omitempty" yaml:"discriminator,omitempty"`
AllOfChanges []*SchemaChanges `json:"allOf,omitempty" yaml:"allOf,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 {
CreateChange(&changes, ObjectAdded, v3.SchemaLabel,
nil, nil, true, nil, r)
sc.Changes = changes
sc.PropertyChanges = NewPropertyChanges(changes)
}
// Removed
if l != nil && r == nil {
CreateChange(&changes, ObjectRemoved, v3.SchemaLabel,
nil, nil, true, l, nil)
sc.Changes = changes
sc.PropertyChanges = NewPropertyChanges(changes)
}
if l != nil && r != nil {
@@ -162,7 +162,7 @@ func CompareSchemas(l, r *base.SchemaProxy) *SchemaChanges {
CreateChange(&changes, Modified, v3.RefLabel,
l.GetValueNode().Content[1], r.GetValueNode().Content[1], true, l.GetSchemaReference(),
r.GetSchemaReference())
sc.Changes = changes
sc.PropertyChanges = NewPropertyChanges(changes)
return sc
}
}
@@ -171,7 +171,7 @@ func CompareSchemas(l, r *base.SchemaProxy) *SchemaChanges {
if !l.IsSchemaReference() && r.IsSchemaReference() {
CreateChange(&changes, Modified, v3.RefLabel,
l.GetValueNode(), r.GetValueNode().Content[1], true, l, r.GetSchemaReference())
sc.Changes = changes
sc.PropertyChanges = NewPropertyChanges(changes)
return sc // we're done here
}
@@ -179,7 +179,7 @@ func CompareSchemas(l, r *base.SchemaProxy) *SchemaChanges {
if l.IsSchemaReference() && !r.IsSchemaReference() {
CreateChange(&changes, Modified, v3.RefLabel,
l.GetValueNode().Content[1], r.GetValueNode(), true, l.GetSchemaReference(), r)
sc.Changes = changes
sc.PropertyChanges = NewPropertyChanges(changes)
return sc // done, nothing else to do.
}
@@ -232,7 +232,9 @@ func CompareSchemas(l, r *base.SchemaProxy) *SchemaChanges {
}
// done
if changes != nil {
sc.Changes = changes
sc.PropertyChanges = NewPropertyChanges(changes)
} else {
sc.PropertyChanges = NewPropertyChanges(nil)
}
return sc
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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