Skip to content

Commit

Permalink
remove --exclude-elements from breaking and changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
Reuven committed Apr 7, 2024
1 parent 0f8591f commit d0bf498
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 2 deletions.
20 changes: 20 additions & 0 deletions diff/diff_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -904,6 +904,26 @@ func TestDiff_Extensions(t *testing.T) {
require.Equal(t, "http://api.example.com/v1/example/callback", dd[1].OldValue)
}

func TestDiff_ExtensionsExcluded(t *testing.T) {
loader := openapi3.NewLoader()

s1, err := loader.LoadFromFile("../data/extensions/base.yaml")
require.NoError(t, err)

s2, err := loader.LoadFromFile("../data/extensions/revision.yaml")
require.NoError(t, err)

d, _, err := diff.GetWithOperationsSourcesMap(diff.NewConfig().WithExcludeExtensions(),
&load.SpecInfo{
Spec: s1,
},
&load.SpecInfo{
Spec: s2,
})
require.NoError(t, err)
require.Empty(t, d)
}

func TestDiff_ExtensionsInvalid(t *testing.T) {
loader := openapi3.NewLoader()

Expand Down
2 changes: 0 additions & 2 deletions internal/cmd_flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,10 @@ import (
"github.com/spf13/cobra"
"github.com/tufin/oasdiff/checker"
"github.com/tufin/oasdiff/checker/localizations"
"github.com/tufin/oasdiff/diff"
)

func addCommonDiffFlags(cmd *cobra.Command, flags Flags) {
cmd.PersistentFlags().BoolVarP(flags.refComposed(), "composed", "c", false, "work in 'composed' mode, compare paths in all specs matching base and revision globs")
enumWithOptions(cmd, newEnumSliceValue(diff.ExcludeDiffOptions, nil, flags.refExcludeElements()), "exclude-elements", "e", "comma-separated list of elements to exclude")
cmd.PersistentFlags().StringVarP(flags.refMatchPath(), "match-path", "p", "", "include only paths that match this regular expression")
cmd.PersistentFlags().StringVarP(flags.refFilterExtension(), "filter-extension", "", "", "exclude paths and operations with an OpenAPI Extension matching this regular expression")
cmd.PersistentFlags().IntVarP(flags.refCircularReferenceCounter(), "max-circular-dep", "", 5, "maximum allowed number of circular dependencies between objects in OpenAPI specs")
Expand Down
1 change: 1 addition & 0 deletions internal/diff.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ func getDiffCmd() *cobra.Command {
}

addCommonDiffFlags(&cmd, &flags)
enumWithOptions(&cmd, newEnumSliceValue(diff.ExcludeDiffOptions, nil, flags.refExcludeElements()), "exclude-elements", "e", "comma-separated list of elements to exclude")
enumWithOptions(&cmd, newEnumValue(formatters.SupportedFormatsByContentType(formatters.OutputDiff), string(formatters.FormatYAML), &flags.format), "format", "f", "output format")
cmd.PersistentFlags().BoolVarP(&flags.failOnDiff, "fail-on-diff", "o", false, "exit with return code 1 when any change is found")

Expand Down
1 change: 1 addition & 0 deletions internal/summary.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ func getSummaryCmd() *cobra.Command {
}

addCommonDiffFlags(&cmd, &flags)
enumWithOptions(&cmd, newEnumSliceValue(diff.ExcludeDiffOptions, nil, flags.refExcludeElements()), "exclude-elements", "e", "comma-separated list of elements to exclude")
enumWithOptions(&cmd, newEnumValue(formatters.SupportedFormatsByContentType(formatters.OutputSummary), string(formatters.FormatYAML), &flags.format), "format", "f", "output format")
cmd.PersistentFlags().BoolVarP(&flags.failOnDiff, "fail-on-diff", "", false, "exit with return code 1 when any change is found")

Expand Down

0 comments on commit d0bf498

Please sign in to comment.