forked from Jonathan-Rosenberg/oasdiff
-
Notifications
You must be signed in to change notification settings - Fork 1
/
config.go
81 lines (67 loc) · 2.06 KB
/
config.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
package diff
import (
"github.com/treeverse/oasdiff/utils"
)
// Config includes various settings to control the diff
type Config struct {
IncludeExtensions utils.StringSet
PathFilter string
FilterExtension string
PathPrefixBase string
PathPrefixRevision string
PathStripPrefixBase string
PathStripPrefixRevision string
ExcludeElements utils.StringSet
IncludePathParams bool
}
const (
ExcludeExamplesOption = "examples"
ExcludeDescriptionOption = "description"
ExcludeEndpointsOption = "endpoints"
ExcludeTitleOption = "title"
ExcludeSummaryOption = "summary"
)
var ExcludeDiffOptions = []string{
ExcludeExamplesOption,
ExcludeDescriptionOption,
ExcludeEndpointsOption,
ExcludeTitleOption,
ExcludeSummaryOption,
}
// NewConfig returns a default configuration
func NewConfig() *Config {
return &Config{
IncludeExtensions: utils.StringSet{},
ExcludeElements: utils.StringSet{},
}
}
func (config *Config) WithExcludeElements(excludeElements []string) *Config {
config.ExcludeElements = utils.StringList(excludeElements).ToStringSet()
return config
}
func (config *Config) IsExcludeExamples() bool {
return config.ExcludeElements.Contains(ExcludeExamplesOption)
}
func (config *Config) IsExcludeDescription() bool {
return config.ExcludeElements.Contains(ExcludeDescriptionOption)
}
func (config *Config) IsExcludeEndpoints() bool {
return config.ExcludeElements.Contains(ExcludeEndpointsOption)
}
func (config *Config) IsExcludeTitle() bool {
return config.ExcludeElements.Contains(ExcludeTitleOption)
}
func (config *Config) IsExcludeSummary() bool {
return config.ExcludeElements.Contains(ExcludeSummaryOption)
}
const (
SunsetExtension = "x-sunset"
XStabilityLevelExtension = "x-stability-level"
XExtensibleEnumExtension = "x-extensible-enum"
)
func (config *Config) WithCheckBreaking() *Config {
config.IncludeExtensions.Add(XStabilityLevelExtension)
config.IncludeExtensions.Add(SunsetExtension)
config.IncludeExtensions.Add(XExtensibleEnumExtension)
return config
}