diff --git a/checker/check_response_mediatype_updated.go b/checker/check_response_mediatype_updated.go index 86043c9f..1114c005 100644 --- a/checker/check_response_mediatype_updated.go +++ b/checker/check_response_mediatype_updated.go @@ -2,7 +2,6 @@ package checker import ( "github.com/tufin/oasdiff/diff" - "github.com/tufin/oasdiff/load" ) const ( @@ -26,7 +25,6 @@ func ResponseMediaTypeUpdatedCheck(diffReport *diff.Diff, operationsSources *dif if operationItem.ResponsesDiff.Modified == nil { continue } - source := (*operationsSources)[operationItem.Revision] for responseStatus, responsesDiff := range operationItem.ResponsesDiff.Modified { if responsesDiff.ContentDiff == nil { continue @@ -35,26 +33,28 @@ func ResponseMediaTypeUpdatedCheck(diffReport *diff.Diff, operationsSources *dif continue } for _, mediaType := range responsesDiff.ContentDiff.MediaTypeDeleted { - result = append(result, ApiChange{ - Id: ResponseMediaTypeRemovedId, - Level: ERR, - Args: []any{mediaType, responseStatus}, - Operation: operation, - OperationId: operationItem.Revision.OperationID, - Path: path, - Source: load.NewSource(source), - }) + result = append(result, NewApiChange( + ResponseMediaTypeRemovedId, + ERR, + []any{mediaType, responseStatus}, + "", + operationsSources, + operationItem.Revision, + operation, + path, + )) } for _, mediaType := range responsesDiff.ContentDiff.MediaTypeAdded { - result = append(result, ApiChange{ - Id: ResponseMediaTypeAddedId, - Level: INFO, - Args: []any{mediaType, responseStatus}, - Operation: operation, - OperationId: operationItem.Revision.OperationID, - Path: path, - Source: load.NewSource(source), - }) + result = append(result, NewApiChange( + ResponseMediaTypeAddedId, + INFO, + []any{mediaType, responseStatus}, + "", + operationsSources, + operationItem.Revision, + operation, + path, + )) } } } diff --git a/checker/check_response_optional_property_updated.go b/checker/check_response_optional_property_updated.go index 74960cae..f94a1707 100644 --- a/checker/check_response_optional_property_updated.go +++ b/checker/check_response_optional_property_updated.go @@ -3,7 +3,6 @@ package checker import ( "github.com/getkin/kin-openapi/openapi3" "github.com/tufin/oasdiff/diff" - "github.com/tufin/oasdiff/load" "golang.org/x/exp/slices" ) @@ -24,7 +23,6 @@ func ResponseOptionalPropertyUpdatedCheck(diffReport *diff.Diff, operationsSourc continue } for operation, operationItem := range pathItem.OperationsDiff.Modified { - source := (*operationsSources)[operationItem.Revision] if operationItem.ResponsesDiff == nil { continue @@ -52,15 +50,16 @@ func ResponseOptionalPropertyUpdatedCheck(diffReport *diff.Diff, operationsSourc return } - result = append(result, ApiChange{ - Id: id, - Level: level, - Args: []any{propertyFullName(propertyPath, propertyName), responseStatus}, - Operation: operation, - OperationId: operationItem.Revision.OperationID, - Path: path, - Source: load.NewSource(source), - }) + result = append(result, NewApiChange( + id, + level, + []any{propertyFullName(propertyPath, propertyName), responseStatus}, + "", + operationsSources, + operationItem.Revision, + operation, + path, + )) }) CheckAddedPropertiesDiff( mediaTypeDiff.SchemaDiff, @@ -75,15 +74,16 @@ func ResponseOptionalPropertyUpdatedCheck(diffReport *diff.Diff, operationsSourc return } - result = append(result, ApiChange{ - Id: id, - Level: INFO, - Args: []any{propertyFullName(propertyPath, propertyName), responseStatus}, - Operation: operation, - OperationId: operationItem.Revision.OperationID, - Path: path, - Source: load.NewSource(source), - }) + result = append(result, NewApiChange( + id, + INFO, + []any{propertyFullName(propertyPath, propertyName), responseStatus}, + "", + operationsSources, + operationItem.Revision, + operation, + path, + )) }) } } diff --git a/checker/check_response_optional_property_write_only_read_only.go b/checker/check_response_optional_property_write_only_read_only.go index be126ccb..d7547bb7 100644 --- a/checker/check_response_optional_property_write_only_read_only.go +++ b/checker/check_response_optional_property_write_only_read_only.go @@ -2,7 +2,6 @@ package checker import ( "github.com/tufin/oasdiff/diff" - "github.com/tufin/oasdiff/load" "golang.org/x/exp/slices" ) @@ -23,7 +22,6 @@ func ResponseOptionalPropertyWriteOnlyReadOnlyCheck(diffReport *diff.Diff, opera continue } for operation, operationItem := range pathItem.OperationsDiff.Modified { - source := (*operationsSources)[operationItem.Revision] if operationItem.ResponsesDiff == nil { continue @@ -63,15 +61,16 @@ func ResponseOptionalPropertyWriteOnlyReadOnlyCheck(diffReport *diff.Diff, opera id = ResponseOptionalPropertyBecameWriteOnlyId } - result = append(result, ApiChange{ - Id: id, - Level: INFO, - Args: []any{propertyFullName(propertyPath, propertyName), responseStatus}, - Operation: operation, - OperationId: operationItem.Revision.OperationID, - Path: path, - Source: load.NewSource(source), - }) + result = append(result, NewApiChange( + id, + INFO, + []any{propertyFullName(propertyPath, propertyName), responseStatus}, + "", + operationsSources, + operationItem.Revision, + operation, + path, + )) }) CheckModifiedPropertiesDiff( @@ -96,15 +95,16 @@ func ResponseOptionalPropertyWriteOnlyReadOnlyCheck(diffReport *diff.Diff, opera id = ResponseOptionalPropertyBecameReadOnlyId } - result = append(result, ApiChange{ - Id: id, - Level: INFO, - Args: []any{propertyFullName(propertyPath, propertyName), responseStatus}, - Operation: operation, - OperationId: operationItem.Revision.OperationID, - Path: path, - Source: load.NewSource(source), - }) + result = append(result, NewApiChange( + id, + INFO, + []any{propertyFullName(propertyPath, propertyName), responseStatus}, + "", + operationsSources, + operationItem.Revision, + operation, + path, + )) }) } } diff --git a/checker/check_response_pattern_added_or_changed.go b/checker/check_response_pattern_added_or_changed.go index f34a9a24..00293760 100644 --- a/checker/check_response_pattern_added_or_changed.go +++ b/checker/check_response_pattern_added_or_changed.go @@ -2,7 +2,6 @@ package checker import ( "github.com/tufin/oasdiff/diff" - "github.com/tufin/oasdiff/load" ) const ( @@ -21,7 +20,6 @@ func ResponsePatternAddedOrChangedCheck(diffReport *diff.Diff, operationsSources continue } for operation, operationItem := range pathItem.OperationsDiff.Modified { - source := (*operationsSources)[operationItem.Revision] if operationItem.ResponsesDiff == nil { continue @@ -59,15 +57,16 @@ func ResponsePatternAddedOrChangedCheck(diffReport *diff.Diff, operationsSources args = []any{propName, patternDiff.To, responseStatus} } - result = append(result, ApiChange{ - Id: id, - Level: INFO, - Args: args, - Operation: operation, - OperationId: operationItem.Revision.OperationID, - Path: path, - Source: load.NewSource(source), - }) + result = append(result, NewApiChange( + id, + INFO, + args, + "", + operationsSources, + operationItem.Revision, + operation, + path, + )) }) } } diff --git a/checker/check_response_property_any_of_updated.go b/checker/check_response_property_any_of_updated.go index 8222bcec..6bf8bb36 100644 --- a/checker/check_response_property_any_of_updated.go +++ b/checker/check_response_property_any_of_updated.go @@ -2,7 +2,6 @@ package checker import ( "github.com/tufin/oasdiff/diff" - "github.com/tufin/oasdiff/load" ) const ( @@ -27,7 +26,6 @@ func ResponsePropertyAnyOfUpdatedCheck(diffReport *diff.Diff, operationsSources if operationItem.ResponsesDiff == nil || operationItem.ResponsesDiff.Modified == nil { continue } - source := (*operationsSources)[operationItem.Revision] for responseStatus, responsesDiff := range operationItem.ResponsesDiff.Modified { if responsesDiff.ContentDiff == nil || responsesDiff.ContentDiff.MediaTypeModified == nil { @@ -41,27 +39,30 @@ func ResponsePropertyAnyOfUpdatedCheck(diffReport *diff.Diff, operationsSources } if mediaTypeDiff.SchemaDiff.AnyOfDiff != nil && len(mediaTypeDiff.SchemaDiff.AnyOfDiff.Added) > 0 { - result = append(result, ApiChange{ - Id: ResponseBodyAnyOfAddedId, - Level: INFO, - Args: []any{mediaTypeDiff.SchemaDiff.AnyOfDiff.Added.String(), responseStatus}, - Operation: operation, - OperationId: operationItem.Revision.OperationID, - Path: path, - Source: load.NewSource(source), - }) + + result = append(result, NewApiChange( + ResponseBodyAnyOfAddedId, + INFO, + []any{mediaTypeDiff.SchemaDiff.AnyOfDiff.Added.String(), responseStatus}, + "", + operationsSources, + operationItem.Revision, + operation, + path, + )) } if mediaTypeDiff.SchemaDiff.AnyOfDiff != nil && len(mediaTypeDiff.SchemaDiff.AnyOfDiff.Deleted) > 0 { - result = append(result, ApiChange{ - Id: ResponseBodyAnyOfRemovedId, - Level: INFO, - Args: []any{mediaTypeDiff.SchemaDiff.AnyOfDiff.Deleted.String(), responseStatus}, - Operation: operation, - OperationId: operationItem.Revision.OperationID, - Path: path, - Source: load.NewSource(source), - }) + result = append(result, NewApiChange( + ResponseBodyAnyOfRemovedId, + INFO, + []any{mediaTypeDiff.SchemaDiff.AnyOfDiff.Deleted.String(), responseStatus}, + "", + operationsSources, + operationItem.Revision, + operation, + path, + )) } CheckModifiedPropertiesDiff( @@ -73,28 +74,30 @@ func ResponsePropertyAnyOfUpdatedCheck(diffReport *diff.Diff, operationsSources if len(propertyDiff.AnyOfDiff.Added) > 0 { - result = append(result, ApiChange{ - Id: ResponsePropertyAnyOfAddedId, - Level: INFO, - Args: []any{propertyDiff.AnyOfDiff.Added.String(), propertyFullName(propertyPath, propertyName), responseStatus}, - Operation: operation, - OperationId: operationItem.Revision.OperationID, - Path: path, - Source: load.NewSource(source), - }) + result = append(result, NewApiChange( + ResponsePropertyAnyOfAddedId, + INFO, + []any{propertyDiff.AnyOfDiff.Added.String(), propertyFullName(propertyPath, propertyName), responseStatus}, + "", + operationsSources, + operationItem.Revision, + operation, + path, + )) } if len(propertyDiff.AnyOfDiff.Deleted) > 0 { - result = append(result, ApiChange{ - Id: ResponsePropertyAnyOfRemovedId, - Level: INFO, - Args: []any{propertyDiff.AnyOfDiff.Deleted.String(), propertyFullName(propertyPath, propertyName), responseStatus}, - Operation: operation, - OperationId: operationItem.Revision.OperationID, - Path: path, - Source: load.NewSource(source), - }) + result = append(result, NewApiChange( + ResponsePropertyAnyOfRemovedId, + INFO, + []any{propertyDiff.AnyOfDiff.Deleted.String(), propertyFullName(propertyPath, propertyName), responseStatus}, + "", + operationsSources, + operationItem.Revision, + operation, + path, + )) } }) } diff --git a/checker/check_response_property_became_nuallable.go b/checker/check_response_property_became_nuallable.go index a6aaa1d8..71be93bf 100644 --- a/checker/check_response_property_became_nuallable.go +++ b/checker/check_response_property_became_nuallable.go @@ -2,7 +2,6 @@ package checker import ( "github.com/tufin/oasdiff/diff" - "github.com/tufin/oasdiff/load" ) const ( @@ -20,7 +19,6 @@ func ResponsePropertyBecameNullableCheck(diffReport *diff.Diff, operationsSource continue } for operation, operationItem := range pathItem.OperationsDiff.Modified { - source := (*operationsSources)[operationItem.Revision] if operationItem.ResponsesDiff == nil { continue @@ -39,14 +37,16 @@ func ResponsePropertyBecameNullableCheck(diffReport *diff.Diff, operationsSource } if mediaTypeDiff.SchemaDiff.NullableDiff != nil && mediaTypeDiff.SchemaDiff.NullableDiff.To == true { - result = append(result, ApiChange{ - Id: ResponseBodyBecameNullableId, - Level: ERR, - Operation: operation, - OperationId: operationItem.Revision.OperationID, - Path: path, - Source: load.NewSource(source), - }) + result = append(result, NewApiChange( + ResponseBodyBecameNullableId, + ERR, + nil, + "", + operationsSources, + operationItem.Revision, + operation, + path, + )) } CheckModifiedPropertiesDiff( @@ -60,15 +60,16 @@ func ResponsePropertyBecameNullableCheck(diffReport *diff.Diff, operationsSource return } - result = append(result, ApiChange{ - Id: ResponsePropertyBecameNullableId, - Level: ERR, - Args: []any{propertyFullName(propertyPath, propertyName), responseStatus}, - Operation: operation, - OperationId: operationItem.Revision.OperationID, - Path: path, - Source: load.NewSource(source), - }) + result = append(result, NewApiChange( + ResponsePropertyBecameNullableId, + ERR, + []any{propertyFullName(propertyPath, propertyName), responseStatus}, + "", + operationsSources, + operationItem.Revision, + operation, + path, + )) }) } } diff --git a/checker/check_response_property_became_optional.go b/checker/check_response_property_became_optional.go index 55cb9d27..0a3fd8d6 100644 --- a/checker/check_response_property_became_optional.go +++ b/checker/check_response_property_became_optional.go @@ -2,7 +2,6 @@ package checker import ( "github.com/tufin/oasdiff/diff" - "github.com/tufin/oasdiff/load" ) const ( @@ -20,7 +19,6 @@ func ResponsePropertyBecameOptionalCheck(diffReport *diff.Diff, operationsSource continue } for operation, operationItem := range pathItem.OperationsDiff.Modified { - source := (*operationsSources)[operationItem.Revision] if operationItem.ResponsesDiff == nil { continue @@ -51,15 +49,16 @@ func ResponsePropertyBecameOptionalCheck(diffReport *diff.Diff, operationsSource level = INFO } - result = append(result, ApiChange{ - Id: id, - Level: level, - Args: []any{changedRequiredPropertyName, responseStatus}, - Operation: operation, - OperationId: operationItem.Revision.OperationID, - Path: path, - Source: load.NewSource(source), - }) + result = append(result, NewApiChange( + id, + level, + []any{changedRequiredPropertyName, responseStatus}, + "", + operationsSources, + operationItem.Revision, + operation, + path, + )) } } diff --git a/checker/check_response_property_became_required.go b/checker/check_response_property_became_required.go index cf791119..12f9e906 100644 --- a/checker/check_response_property_became_required.go +++ b/checker/check_response_property_became_required.go @@ -2,7 +2,6 @@ package checker import ( "github.com/tufin/oasdiff/diff" - "github.com/tufin/oasdiff/load" ) const ( @@ -20,7 +19,6 @@ func ResponsePropertyBecameRequiredCheck(diffReport *diff.Diff, operationsSource continue } for operation, operationItem := range pathItem.OperationsDiff.Modified { - source := (*operationsSources)[operationItem.Revision] if operationItem.ResponsesDiff == nil { continue @@ -53,15 +51,16 @@ func ResponsePropertyBecameRequiredCheck(diffReport *diff.Diff, operationsSource id = ResponseWriteOnlyPropertyBecameRequiredId } - result = append(result, ApiChange{ - Id: id, - Level: INFO, - Args: []any{changedRequiredPropertyName, responseStatus}, - Operation: operation, - OperationId: operationItem.Revision.OperationID, - Path: path, - Source: load.NewSource(source), - }) + result = append(result, NewApiChange( + id, + INFO, + []any{propertyFullName("", changedRequiredPropertyName), responseStatus}, + "", + operationsSources, + operationItem.Revision, + operation, + path, + )) } } @@ -86,15 +85,16 @@ func ResponsePropertyBecameRequiredCheck(diffReport *diff.Diff, operationsSource id = ResponseWriteOnlyPropertyBecameRequiredId } - result = append(result, ApiChange{ - Id: id, - Level: INFO, - Args: []any{propertyFullName(propertyPath, propertyFullName(propertyName, changedRequiredPropertyName)), responseStatus}, - Operation: operation, - OperationId: operationItem.Revision.OperationID, - Path: path, - Source: load.NewSource(source), - }) + result = append(result, NewApiChange( + id, + INFO, + []any{propertyFullName(propertyPath, propertyFullName(propertyName, changedRequiredPropertyName)), responseStatus}, + "", + operationsSources, + operationItem.Revision, + operation, + path, + )) } }) } diff --git a/checker/check_response_property_default_value_changed.go b/checker/check_response_property_default_value_changed.go index 7b372297..e671161a 100644 --- a/checker/check_response_property_default_value_changed.go +++ b/checker/check_response_property_default_value_changed.go @@ -2,7 +2,6 @@ package checker import ( "github.com/tufin/oasdiff/diff" - "github.com/tufin/oasdiff/load" ) const ( @@ -24,21 +23,21 @@ func ResponsePropertyDefaultValueChangedCheck(diffReport *diff.Diff, operationsS continue } for operation, operationItem := range pathItem.OperationsDiff.Modified { - source := (*operationsSources)[operationItem.Revision] if operationItem.ResponsesDiff == nil || operationItem.ResponsesDiff.Modified == nil { continue } appendResultItem := func(messageId string, a ...any) { - result = append(result, ApiChange{ - Id: messageId, - Level: INFO, - Args: a, - Operation: operation, - OperationId: operationItem.Revision.OperationID, - Path: path, - Source: load.NewSource(source), - }) + result = append(result, NewApiChange( + messageId, + INFO, + a, + "", + operationsSources, + operationItem.Revision, + operation, + path, + )) } for responseStatus, responseDiff := range operationItem.ResponsesDiff.Modified { diff --git a/checker/check_response_property_enum_value_added.go b/checker/check_response_property_enum_value_added.go index bb53d9af..30f5a263 100644 --- a/checker/check_response_property_enum_value_added.go +++ b/checker/check_response_property_enum_value_added.go @@ -2,7 +2,6 @@ package checker import ( "github.com/tufin/oasdiff/diff" - "github.com/tufin/oasdiff/load" ) const ( @@ -23,7 +22,6 @@ func ResponsePropertyEnumValueAddedCheck(diffReport *diff.Diff, operationsSource if operationItem.ResponsesDiff == nil || operationItem.ResponsesDiff.Modified == nil { continue } - source := (*operationsSources)[operationItem.Revision] for responseStatus, responseDiff := range operationItem.ResponsesDiff.Modified { if responseDiff == nil || responseDiff.ContentDiff == nil || @@ -52,16 +50,16 @@ func ResponsePropertyEnumValueAddedCheck(diffReport *diff.Diff, operationsSource } for _, enumVal := range enumDiff.Added { - result = append(result, ApiChange{ - Id: id, - Level: level, - Args: []any{enumVal, propertyFullName(propertyPath, propertyName), responseStatus}, - Comment: comment, - Operation: operation, - OperationId: operationItem.Revision.OperationID, - Path: path, - Source: load.NewSource(source), - }) + result = append(result, NewApiChange( + id, + level, + []any{enumVal, propertyFullName(propertyPath, propertyName), responseStatus}, + comment, + operationsSources, + operationItem.Revision, + operation, + path, + )) } }) } diff --git a/checker/check_response_property_enum_value_removed.go b/checker/check_response_property_enum_value_removed.go index b5568272..66547617 100644 --- a/checker/check_response_property_enum_value_removed.go +++ b/checker/check_response_property_enum_value_removed.go @@ -2,7 +2,6 @@ package checker import ( "github.com/tufin/oasdiff/diff" - "github.com/tufin/oasdiff/load" ) const ( @@ -23,7 +22,6 @@ func ResponseParameterEnumValueRemovedCheck(diffReport *diff.Diff, operationsSou continue } - source := (*operationsSources)[operationItem.Revision] for responseStatus, responseDiff := range operationItem.ResponsesDiff.Modified { if responseDiff == nil || responseDiff.ContentDiff == nil || @@ -40,15 +38,16 @@ func ResponseParameterEnumValueRemovedCheck(diffReport *diff.Diff, operationsSou } for _, enumVal := range enumDiff.Deleted { - result = append(result, ApiChange{ - Id: ResponsePropertyEnumValueRemovedId, - Level: config.getLogLevel(ResponsePropertyEnumValueRemovedId, INFO), - Args: []any{enumVal, propertyFullName(propertyPath, propertyName), responseStatus}, - Operation: operation, - OperationId: operationItem.Revision.OperationID, - Path: path, - Source: load.NewSource(source), - }) + result = append(result, NewApiChange( + ResponsePropertyEnumValueRemovedId, + config.getLogLevel(ResponsePropertyEnumValueRemovedId, INFO), + []any{enumVal, propertyFullName(propertyPath, propertyName), responseStatus}, + "", + operationsSources, + operationItem.Revision, + operation, + path, + )) } }) } diff --git a/checker/check_response_property_max_increased.go b/checker/check_response_property_max_increased.go index dae86ebd..8afb5098 100644 --- a/checker/check_response_property_max_increased.go +++ b/checker/check_response_property_max_increased.go @@ -2,7 +2,6 @@ package checker import ( "github.com/tufin/oasdiff/diff" - "github.com/tufin/oasdiff/load" ) const ( @@ -23,7 +22,6 @@ func ResponsePropertyMaxIncreasedCheck(diffReport *diff.Diff, operationsSources if operationItem.ResponsesDiff == nil || operationItem.ResponsesDiff.Modified == nil { continue } - source := (*operationsSources)[operationItem.Revision] for responseStatus, responseDiff := range operationItem.ResponsesDiff.Modified { if responseDiff == nil || responseDiff.ContentDiff == nil || @@ -37,15 +35,16 @@ func ResponsePropertyMaxIncreasedCheck(diffReport *diff.Diff, operationsSources if maxDiff.From != nil && maxDiff.To != nil { if IsIncreasedValue(maxDiff) { - result = append(result, ApiChange{ - Id: ResponseBodyMaxIncreasedId, - Level: ERR, - Args: []any{maxDiff.From, maxDiff.To}, - Operation: operation, - OperationId: operationItem.Revision.OperationID, - Path: path, - Source: load.NewSource(source), - }) + result = append(result, NewApiChange( + ResponseBodyMaxIncreasedId, + ERR, + []any{maxDiff.From, maxDiff.To}, + "", + operationsSources, + operationItem.Revision, + operation, + path, + )) } } } @@ -69,15 +68,16 @@ func ResponsePropertyMaxIncreasedCheck(diffReport *diff.Diff, operationsSources return } - result = append(result, ApiChange{ - Id: ResponsePropertyMaxIncreasedId, - Level: ERR, - Args: []any{propertyFullName(propertyPath, propertyName), maxDiff.From, maxDiff.To, responseStatus}, - Operation: operation, - OperationId: operationItem.Revision.OperationID, - Path: path, - Source: load.NewSource(source), - }) + result = append(result, NewApiChange( + ResponsePropertyMaxIncreasedId, + ERR, + []any{propertyFullName(propertyPath, propertyName), maxDiff.From, maxDiff.To, responseStatus}, + "", + operationsSources, + operationItem.Revision, + operation, + path, + )) }) } diff --git a/checker/check_response_property_max_length_increased.go b/checker/check_response_property_max_length_increased.go index 6608f75b..ce5e9dc6 100644 --- a/checker/check_response_property_max_length_increased.go +++ b/checker/check_response_property_max_length_increased.go @@ -2,7 +2,6 @@ package checker import ( "github.com/tufin/oasdiff/diff" - "github.com/tufin/oasdiff/load" ) const ( @@ -23,7 +22,6 @@ func ResponsePropertyMaxLengthIncreasedCheck(diffReport *diff.Diff, operationsSo if operationItem.ResponsesDiff == nil || operationItem.ResponsesDiff.Modified == nil { continue } - source := (*operationsSources)[operationItem.Revision] for responseStatus, responseDiff := range operationItem.ResponsesDiff.Modified { if responseDiff == nil || responseDiff.ContentDiff == nil || @@ -37,15 +35,16 @@ func ResponsePropertyMaxLengthIncreasedCheck(diffReport *diff.Diff, operationsSo if maxLengthDiff.From != nil && maxLengthDiff.To != nil { if IsIncreasedValue(maxLengthDiff) { - result = append(result, ApiChange{ - Id: ResponseBodyMaxLengthIncreasedId, - Level: ERR, - Args: []any{maxLengthDiff.From, maxLengthDiff.To}, - Operation: operation, - OperationId: operationItem.Revision.OperationID, - Path: path, - Source: load.NewSource(source), - }) + result = append(result, NewApiChange( + ResponseBodyMaxLengthIncreasedId, + ERR, + []any{maxLengthDiff.From, maxLengthDiff.To}, + "", + operationsSources, + operationItem.Revision, + operation, + path, + )) } } } @@ -69,15 +68,16 @@ func ResponsePropertyMaxLengthIncreasedCheck(diffReport *diff.Diff, operationsSo return } - result = append(result, ApiChange{ - Id: ResponsePropertyMaxLengthIncreasedId, - Level: ERR, - Args: []any{propertyFullName(propertyPath, propertyName), maxLengthDiff.From, maxLengthDiff.To, responseStatus}, - Operation: operation, - OperationId: operationItem.Revision.OperationID, - Path: path, - Source: load.NewSource(source), - }) + result = append(result, NewApiChange( + ResponsePropertyMaxLengthIncreasedId, + ERR, + []any{propertyFullName(propertyPath, propertyName), maxLengthDiff.From, maxLengthDiff.To, responseStatus}, + "", + operationsSources, + operationItem.Revision, + operation, + path, + )) }) } } diff --git a/checker/check_response_property_max_length_unset.go b/checker/check_response_property_max_length_unset.go index 8569541d..b2b4feea 100644 --- a/checker/check_response_property_max_length_unset.go +++ b/checker/check_response_property_max_length_unset.go @@ -2,7 +2,6 @@ package checker import ( "github.com/tufin/oasdiff/diff" - "github.com/tufin/oasdiff/load" ) const ( @@ -23,7 +22,6 @@ func ResponsePropertyMaxLengthUnsetCheck(diffReport *diff.Diff, operationsSource if operationItem.ResponsesDiff == nil || operationItem.ResponsesDiff.Modified == nil { continue } - source := (*operationsSources)[operationItem.Revision] for responseStatus, responseDiff := range operationItem.ResponsesDiff.Modified { if responseDiff == nil || responseDiff.ContentDiff == nil || @@ -36,15 +34,16 @@ func ResponsePropertyMaxLengthUnsetCheck(diffReport *diff.Diff, operationsSource maxLengthDiff := mediaTypeDiff.SchemaDiff.MaxLengthDiff if maxLengthDiff.From != nil && maxLengthDiff.To == nil { - result = append(result, ApiChange{ - Id: ResponseBodyMaxLengthUnsetId, - Level: ERR, - Args: []any{maxLengthDiff.From}, - Operation: operation, - OperationId: operationItem.Revision.OperationID, - Path: path, - Source: load.NewSource(source), - }) + result = append(result, NewApiChange( + ResponseBodyMaxLengthUnsetId, + ERR, + []any{maxLengthDiff.From}, + "", + operationsSources, + operationItem.Revision, + operation, + path, + )) } } @@ -63,15 +62,16 @@ func ResponsePropertyMaxLengthUnsetCheck(diffReport *diff.Diff, operationsSource return } - result = append(result, ApiChange{ - Id: ResponsePropertyMaxLengthUnsetId, - Level: ERR, - Args: []any{propertyFullName(propertyPath, propertyName), maxLengthDiff.From, responseStatus}, - Operation: operation, - OperationId: operationItem.Revision.OperationID, - Path: path, - Source: load.NewSource(source), - }) + result = append(result, NewApiChange( + ResponsePropertyMaxLengthUnsetId, + ERR, + []any{propertyFullName(propertyPath, propertyName), maxLengthDiff.From, responseStatus}, + "", + operationsSources, + operationItem.Revision, + operation, + path, + )) }) } } diff --git a/checker/check_response_property_min_decreased.go b/checker/check_response_property_min_decreased.go index 7be83ad3..cff0b317 100644 --- a/checker/check_response_property_min_decreased.go +++ b/checker/check_response_property_min_decreased.go @@ -2,7 +2,6 @@ package checker import ( "github.com/tufin/oasdiff/diff" - "github.com/tufin/oasdiff/load" ) const ( @@ -23,7 +22,6 @@ func ResponsePropertyMinDecreasedCheck(diffReport *diff.Diff, operationsSources if operationItem.ResponsesDiff == nil || operationItem.ResponsesDiff.Modified == nil { continue } - source := (*operationsSources)[operationItem.Revision] for responseStatus, responseDiff := range operationItem.ResponsesDiff.Modified { if responseDiff == nil || responseDiff.ContentDiff == nil || @@ -37,15 +35,16 @@ func ResponsePropertyMinDecreasedCheck(diffReport *diff.Diff, operationsSources if minDiff.From != nil && minDiff.To != nil { if IsDecreasedValue(minDiff) { - result = append(result, ApiChange{ - Id: ResponseBodyMinDecreasedId, - Level: ERR, - Args: []any{minDiff.From, minDiff.To}, - Operation: operation, - OperationId: operationItem.Revision.OperationID, - Path: path, - Source: load.NewSource(source), - }) + result = append(result, NewApiChange( + ResponseBodyMinDecreasedId, + ERR, + []any{minDiff.From, minDiff.To}, + "", + operationsSources, + operationItem.Revision, + operation, + path, + )) } } } @@ -69,15 +68,16 @@ func ResponsePropertyMinDecreasedCheck(diffReport *diff.Diff, operationsSources return } - result = append(result, ApiChange{ - Id: ResponsePropertyMinDecreasedId, - Level: ERR, - Args: []any{propertyFullName(propertyPath, propertyName), minDiff.From, minDiff.To, responseStatus}, - Operation: operation, - OperationId: operationItem.Revision.OperationID, - Path: path, - Source: load.NewSource(source), - }) + result = append(result, NewApiChange( + ResponsePropertyMinDecreasedId, + ERR, + []any{propertyFullName(propertyPath, propertyName), minDiff.From, minDiff.To, responseStatus}, + "", + operationsSources, + operationItem.Revision, + operation, + path, + )) }) } } diff --git a/checker/check_response_property_min_items_decreased.go b/checker/check_response_property_min_items_decreased.go index 4e238500..682f4774 100644 --- a/checker/check_response_property_min_items_decreased.go +++ b/checker/check_response_property_min_items_decreased.go @@ -2,7 +2,6 @@ package checker import ( "github.com/tufin/oasdiff/diff" - "github.com/tufin/oasdiff/load" ) const ( @@ -23,7 +22,6 @@ func ResponsePropertyMinItemsDecreasedCheck(diffReport *diff.Diff, operationsSou if operationItem.ResponsesDiff == nil || operationItem.ResponsesDiff.Modified == nil { continue } - source := (*operationsSources)[operationItem.Revision] for responseStatus, responseDiff := range operationItem.ResponsesDiff.Modified { if responseDiff == nil || responseDiff.ContentDiff == nil || @@ -37,15 +35,16 @@ func ResponsePropertyMinItemsDecreasedCheck(diffReport *diff.Diff, operationsSou if minItemsDiff.From != nil && minItemsDiff.To != nil { if IsDecreasedValue(minItemsDiff) { - result = append(result, ApiChange{ - Id: ResponseBodyMinItemsDecreasedId, - Level: ERR, - Args: []any{minItemsDiff.From, minItemsDiff.To}, - Operation: operation, - OperationId: operationItem.Revision.OperationID, - Path: path, - Source: load.NewSource(source), - }) + result = append(result, NewApiChange( + ResponseBodyMinItemsDecreasedId, + ERR, + []any{minItemsDiff.From, minItemsDiff.To}, + "", + operationsSources, + operationItem.Revision, + operation, + path, + )) } } } @@ -69,15 +68,16 @@ func ResponsePropertyMinItemsDecreasedCheck(diffReport *diff.Diff, operationsSou return } - result = append(result, ApiChange{ - Id: ResponsePropertyMinItemsDecreasedId, - Level: ERR, - Args: []any{propertyFullName(propertyPath, propertyName), minItemsDiff.From, minItemsDiff.To, responseStatus}, - Operation: operation, - OperationId: operationItem.Revision.OperationID, - Path: path, - Source: load.NewSource(source), - }) + result = append(result, NewApiChange( + ResponsePropertyMinItemsDecreasedId, + ERR, + []any{propertyFullName(propertyPath, propertyName), minItemsDiff.From, minItemsDiff.To, responseStatus}, + "", + operationsSources, + operationItem.Revision, + operation, + path, + )) }) } } diff --git a/checker/check_response_property_min_items_unset.go b/checker/check_response_property_min_items_unset.go index 80b5e97e..af7d8b37 100644 --- a/checker/check_response_property_min_items_unset.go +++ b/checker/check_response_property_min_items_unset.go @@ -2,7 +2,6 @@ package checker import ( "github.com/tufin/oasdiff/diff" - "github.com/tufin/oasdiff/load" ) const ( @@ -23,7 +22,6 @@ func ResponsePropertyMinItemsUnsetCheck(diffReport *diff.Diff, operationsSources if operationItem.ResponsesDiff == nil || operationItem.ResponsesDiff.Modified == nil { continue } - source := (*operationsSources)[operationItem.Revision] for responseStatus, responseDiff := range operationItem.ResponsesDiff.Modified { if responseDiff == nil || responseDiff.ContentDiff == nil || @@ -36,15 +34,16 @@ func ResponsePropertyMinItemsUnsetCheck(diffReport *diff.Diff, operationsSources minItemsDiff := mediaTypeDiff.SchemaDiff.MinItemsDiff if minItemsDiff.From != nil && minItemsDiff.To == nil { - result = append(result, ApiChange{ - Id: ResponseBodyMinItemsUnsetId, - Level: ERR, - Args: []any{minItemsDiff.From}, - Operation: operation, - OperationId: operationItem.Revision.OperationID, - Path: path, - Source: load.NewSource(source), - }) + result = append(result, NewApiChange( + ResponseBodyMinItemsUnsetId, + ERR, + []any{minItemsDiff.From}, + "", + operationsSources, + operationItem.Revision, + operation, + path, + )) } } @@ -63,15 +62,16 @@ func ResponsePropertyMinItemsUnsetCheck(diffReport *diff.Diff, operationsSources return } - result = append(result, ApiChange{ - Id: ResponsePropertyMinItemsUnsetId, - Level: ERR, - Args: []any{propertyFullName(propertyPath, propertyName), minItemsDiff.From, responseStatus}, - Operation: operation, - OperationId: operationItem.Revision.OperationID, - Path: path, - Source: load.NewSource(source), - }) + result = append(result, NewApiChange( + ResponsePropertyMinItemsUnsetId, + ERR, + []any{propertyFullName(propertyPath, propertyName), minItemsDiff.From, responseStatus}, + "", + operationsSources, + operationItem.Revision, + operation, + path, + )) }) } diff --git a/checker/check_response_property_min_length_decreased.go b/checker/check_response_property_min_length_decreased.go index 89cf92f7..faf59808 100644 --- a/checker/check_response_property_min_length_decreased.go +++ b/checker/check_response_property_min_length_decreased.go @@ -2,7 +2,6 @@ package checker import ( "github.com/tufin/oasdiff/diff" - "github.com/tufin/oasdiff/load" ) const ( @@ -23,7 +22,6 @@ func ResponsePropertyMinLengthDecreasedCheck(diffReport *diff.Diff, operationsSo if operationItem.ResponsesDiff == nil || operationItem.ResponsesDiff.Modified == nil { continue } - source := (*operationsSources)[operationItem.Revision] for responseStatus, responseDiff := range operationItem.ResponsesDiff.Modified { if responseDiff == nil || responseDiff.ContentDiff == nil || @@ -37,15 +35,16 @@ func ResponsePropertyMinLengthDecreasedCheck(diffReport *diff.Diff, operationsSo if minLengthDiff.From != nil && minLengthDiff.To != nil { if IsDecreasedValue(minLengthDiff) { - result = append(result, ApiChange{ - Id: ResponseBodyMinLengthDecreasedId, - Level: ERR, - Args: []any{minLengthDiff.From, minLengthDiff.To}, - Operation: operation, - OperationId: operationItem.Revision.OperationID, - Path: path, - Source: load.NewSource(source), - }) + result = append(result, NewApiChange( + ResponseBodyMinLengthDecreasedId, + ERR, + []any{minLengthDiff.From, minLengthDiff.To}, + "", + operationsSources, + operationItem.Revision, + operation, + path, + )) } } } @@ -69,15 +68,16 @@ func ResponsePropertyMinLengthDecreasedCheck(diffReport *diff.Diff, operationsSo return } - result = append(result, ApiChange{ - Id: ResponsePropertyMinLengthDecreasedId, - Level: ERR, - Args: []any{propertyFullName(propertyPath, propertyName), minLengthDiff.From, minLengthDiff.To, responseStatus}, - Operation: operation, - OperationId: operationItem.Revision.OperationID, - Path: path, - Source: load.NewSource(source), - }) + result = append(result, NewApiChange( + ResponsePropertyMinLengthDecreasedId, + ERR, + []any{propertyFullName(propertyPath, propertyName), minLengthDiff.From, minLengthDiff.To, responseStatus}, + "", + operationsSources, + operationItem.Revision, + operation, + path, + )) }) } } diff --git a/checker/check_response_property_type_changed.go b/checker/check_response_property_type_changed.go index c6e26caa..8c1374a7 100644 --- a/checker/check_response_property_type_changed.go +++ b/checker/check_response_property_type_changed.go @@ -2,7 +2,6 @@ package checker import ( "github.com/tufin/oasdiff/diff" - "github.com/tufin/oasdiff/load" ) const ( @@ -20,7 +19,6 @@ func ResponsePropertyTypeChangedCheck(diffReport *diff.Diff, operationsSources * continue } for operation, operationItem := range pathItem.OperationsDiff.Modified { - source := (*operationsSources)[operationItem.Revision] if operationItem.ResponsesDiff == nil || operationItem.ResponsesDiff.Modified == nil { continue } @@ -39,15 +37,16 @@ func ResponsePropertyTypeChangedCheck(diffReport *diff.Diff, operationsSources * formatDiff := schemaDiff.FormatDiff if breakingTypeFormatChangedInResponseProperty(typeDiff, formatDiff, mediaType, schemaDiff) { - result = append(result, ApiChange{ - Id: ResponseBodyTypeChangedId, - Level: ERR, - Args: []any{getBaseType(schemaDiff), getBaseFormat(schemaDiff), getRevisionType(schemaDiff), getRevisionFormat(schemaDiff), responseStatus}, - Operation: operation, - OperationId: operationItem.Revision.OperationID, - Path: path, - Source: load.NewSource(source), - }) + result = append(result, NewApiChange( + ResponseBodyTypeChangedId, + ERR, + []any{getBaseType(schemaDiff), getBaseFormat(schemaDiff), getRevisionType(schemaDiff), getRevisionFormat(schemaDiff), responseStatus}, + "", + operationsSources, + operationItem.Revision, + operation, + path, + )) } } @@ -64,15 +63,16 @@ func ResponsePropertyTypeChangedCheck(diffReport *diff.Diff, operationsSources * if breakingTypeFormatChangedInResponseProperty(typeDiff, formatDiff, mediaType, schemaDiff) { - result = append(result, ApiChange{ - Id: ResponsePropertyTypeChangedId, - Level: ERR, - Args: []any{propertyFullName(propertyPath, propertyName), getBaseType(schemaDiff), getBaseFormat(schemaDiff), getRevisionType(schemaDiff), getRevisionFormat(schemaDiff), responseStatus}, - Operation: operation, - OperationId: operationItem.Revision.OperationID, - Path: path, - Source: load.NewSource(source), - }) + result = append(result, NewApiChange( + ResponsePropertyTypeChangedId, + ERR, + []any{propertyFullName(propertyPath, propertyName), getBaseType(schemaDiff), getBaseFormat(schemaDiff), getRevisionType(schemaDiff), getRevisionFormat(schemaDiff), responseStatus}, + "", + operationsSources, + operationItem.Revision, + operation, + path, + )) } }) } diff --git a/checker/check_response_required_property_updated.go b/checker/check_response_required_property_updated.go index 7accecbb..13a1c50f 100644 --- a/checker/check_response_required_property_updated.go +++ b/checker/check_response_required_property_updated.go @@ -3,7 +3,6 @@ package checker import ( "github.com/getkin/kin-openapi/openapi3" "github.com/tufin/oasdiff/diff" - "github.com/tufin/oasdiff/load" "golang.org/x/exp/slices" ) @@ -24,7 +23,6 @@ func ResponseRequiredPropertyUpdatedCheck(diffReport *diff.Diff, operationsSourc continue } for operation, operationItem := range pathItem.OperationsDiff.Modified { - source := (*operationsSources)[operationItem.Revision] if operationItem.ResponsesDiff == nil { continue @@ -52,15 +50,16 @@ func ResponseRequiredPropertyUpdatedCheck(diffReport *diff.Diff, operationsSourc return } - result = append(result, ApiChange{ - Id: id, - Level: level, - Args: []any{propertyFullName(propertyPath, propertyName), responseStatus}, - Operation: operation, - OperationId: operationItem.Revision.OperationID, - Path: path, - Source: load.NewSource(source), - }) + result = append(result, NewApiChange( + id, + level, + []any{propertyFullName(propertyPath, propertyName), responseStatus}, + "", + operationsSources, + operationItem.Revision, + operation, + path, + )) }) CheckAddedPropertiesDiff( mediaTypeDiff.SchemaDiff, @@ -74,15 +73,16 @@ func ResponseRequiredPropertyUpdatedCheck(diffReport *diff.Diff, operationsSourc return } - result = append(result, ApiChange{ - Id: id, - Level: INFO, - Args: []any{propertyFullName(propertyPath, propertyName), responseStatus}, - Operation: operation, - OperationId: operationItem.Revision.OperationID, - Path: path, - Source: load.NewSource(source), - }) + result = append(result, NewApiChange( + id, + INFO, + []any{propertyFullName(propertyPath, propertyName), responseStatus}, + "", + operationsSources, + operationItem.Revision, + operation, + path, + )) }) } }