Skip to content

Commit

Permalink
use ctor
Browse files Browse the repository at this point in the history
  • Loading branch information
Reuven committed Jul 3, 2024
1 parent 17392a3 commit 64849bf
Show file tree
Hide file tree
Showing 20 changed files with 371 additions and 373 deletions.
40 changes: 20 additions & 20 deletions checker/check_response_mediatype_updated.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package checker

import (
"github.com/tufin/oasdiff/diff"
"github.com/tufin/oasdiff/load"
)

const (
Expand All @@ -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
Expand All @@ -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,
))
}
}
}
Expand Down
40 changes: 20 additions & 20 deletions checker/check_response_optional_property_updated.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand All @@ -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
Expand Down Expand Up @@ -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,
Expand All @@ -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,
))
})
}
}
Expand Down
40 changes: 20 additions & 20 deletions checker/check_response_optional_property_write_only_read_only.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package checker

import (
"github.com/tufin/oasdiff/diff"
"github.com/tufin/oasdiff/load"
"golang.org/x/exp/slices"
)

Expand All @@ -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
Expand Down Expand Up @@ -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(
Expand All @@ -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,
))
})
}
}
Expand Down
21 changes: 10 additions & 11 deletions checker/check_response_pattern_added_or_changed.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package checker

import (
"github.com/tufin/oasdiff/diff"
"github.com/tufin/oasdiff/load"
)

const (
Expand All @@ -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
Expand Down Expand Up @@ -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,
))
})
}
}
Expand Down
79 changes: 41 additions & 38 deletions checker/check_response_property_any_of_updated.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package checker

import (
"github.com/tufin/oasdiff/diff"
"github.com/tufin/oasdiff/load"
)

const (
Expand All @@ -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 {
Expand All @@ -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(
Expand All @@ -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,
))
}
})
}
Expand Down
Loading

0 comments on commit 64849bf

Please sign in to comment.