-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(feature) Add optional checker for tag removal (#208)
* Add optional checker for tag removal * Add tests for tag addition * Split errors per tag * remove redundant check --------- Co-authored-by: Reuven <[email protected]>
- Loading branch information
Showing
9 changed files
with
138 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package checker | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/tufin/oasdiff/diff" | ||
) | ||
|
||
const ( | ||
apiTagRemovedCheckId = "api-tag-removed" | ||
) | ||
|
||
func APITagRemovedCheck(diffReport *diff.Diff, operationsSources *diff.OperationsSourcesMap, config BackwardCompatibilityCheckConfig) []BackwardCompatibilityError { | ||
result := make([]BackwardCompatibilityError, 0) | ||
if diffReport.PathsDiff == nil { | ||
return result | ||
} | ||
|
||
for path, pathItem := range diffReport.PathsDiff.Modified { | ||
if pathItem.OperationsDiff == nil { | ||
continue | ||
} | ||
|
||
for operation, operationItem := range pathItem.OperationsDiff.Modified { | ||
op := pathItem.Base.Operations()[operation] | ||
source := (*operationsSources)[op] | ||
|
||
if operationItem.TagsDiff == nil { | ||
continue | ||
} | ||
|
||
for _, tag := range operationItem.TagsDiff.Deleted { | ||
result = append(result, BackwardCompatibilityError{ | ||
Id: apiTagRemovedCheckId, | ||
Level: ERR, | ||
Text: fmt.Sprintf(config.i18n(apiTagRemovedCheckId), ColorizedValue(tag)), | ||
Operation: operation, | ||
Path: path, | ||
Source: source, | ||
}) | ||
|
||
} | ||
} | ||
} | ||
return result | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.