diff options
author | 2017-12-18 11:50:56 -0600 | |
---|---|---|
committer | 2017-12-18 11:50:56 -0600 | |
commit | 4dd40a292c773aad5eee761940840de64ba9090a (patch) | |
tree | e7b872bed228fdf06b4ea91db60bf9b7cc8fec2a /vendor/github.com/go-openapi/analysis/flatten.go | |
parent | ba4e77672c9f7b53a8c2f6e197d3f12ede1e46cd (diff) | |
download | coredns-4dd40a292c773aad5eee761940840de64ba9090a.tar.gz coredns-4dd40a292c773aad5eee761940840de64ba9090a.tar.zst coredns-4dd40a292c773aad5eee761940840de64ba9090a.zip |
Update apache/thrift to 0.11.0 and remove pinning (#1317)
The `apache/thrift` recently released a new version of `0.11.0`
several days ago. This release is compatible with other packages
and as such, there is no need to pinning the `apache/thrift`
to `master` anymore in Gopkg.toml.
This fix removes the pinning of `apache/thrift` in Gopkg.toml,
and updates all dependencies of coredns.
Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
Diffstat (limited to 'vendor/github.com/go-openapi/analysis/flatten.go')
-rw-r--r-- | vendor/github.com/go-openapi/analysis/flatten.go | 56 |
1 files changed, 50 insertions, 6 deletions
diff --git a/vendor/github.com/go-openapi/analysis/flatten.go b/vendor/github.com/go-openapi/analysis/flatten.go index 23d7242f4..703a0aa89 100644 --- a/vendor/github.com/go-openapi/analysis/flatten.go +++ b/vendor/github.com/go-openapi/analysis/flatten.go @@ -4,7 +4,9 @@ import ( "fmt" "log" "net/http" + "os" "path" + "path/filepath" "sort" "strings" @@ -17,6 +19,8 @@ import ( // FlattenOpts configuration for flattening a swagger specification. type FlattenOpts struct { + // If Expand is true, we skip flattening the spec and expand it instead + Expand bool Spec *Spec BasePath string @@ -42,8 +46,16 @@ func (f *FlattenOpts) Swagger() *swspec.Swagger { // Move every inline schema to be a definition with an auto-generated name in a depth-first fashion. // Rewritten schemas get a vendor extension x-go-gen-location so we know in which package they need to be rendered. func Flatten(opts FlattenOpts) error { + // Make sure opts.BasePath is an absolute path + if !filepath.IsAbs(opts.BasePath) { + cwd, _ := os.Getwd() + opts.BasePath = filepath.Join(cwd, opts.BasePath) + } // recursively expand responses, parameters, path items and items - err := swspec.ExpandSpec(opts.Swagger(), opts.ExpandOpts(true)) + err := swspec.ExpandSpec(opts.Swagger(), &swspec.ExpandOptions{ + RelativeBase: opts.BasePath, + SkipSchemas: !opts.Expand, + }) if err != nil { return err } @@ -68,7 +80,6 @@ func Flatten(opts FlattenOpts) error { func nameInlinedSchemas(opts *FlattenOpts) error { namer := &inlineSchemaNamer{Spec: opts.Swagger(), Operations: opRefsByRef(gatherOperations(opts.Spec, nil))} depthFirst := sortDepthFirst(opts.Spec.allSchemas) - for _, key := range depthFirst { sch := opts.Spec.allSchemas[key] if sch.Schema != nil && sch.Schema.Ref.String() == "" && !sch.TopLevel { // inline schema @@ -200,9 +211,18 @@ func uniqifyName(definitions swspec.Definitions, name string) string { return name } - if _, ok := definitions[name]; !ok { + unq := true + for k := range definitions { + if strings.ToLower(k) == strings.ToLower(name) { + unq = false + break + } + } + + if unq { return name } + name += "OAIGen" var idx int unique := name @@ -301,9 +321,27 @@ func (s splitKey) DefinitionName() string { return s[1] } +func (s splitKey) isKeyName(i int) bool { + if i <= 0 { + return false + } + count := 0 + for idx := i - 1; idx > 0; idx-- { + if s[idx] != "properties" { + break + } + count++ + } + + if count%2 != 0 { + return true + } + return false +} + func (s splitKey) BuildName(segments []string, startIndex int, aschema *AnalyzedSchema) string { - for _, part := range s[startIndex:] { - if _, ignored := ignoredKeys[part]; !ignored { + for i, part := range s[startIndex:] { + if _, ignored := ignoredKeys[part]; !ignored || s.isKeyName(startIndex+i) { if part == "items" || part == "additionalItems" { if aschema.IsTuple || aschema.IsTupleWithExtra { segments = append(segments, "tuple") @@ -540,7 +578,13 @@ func importExternalReferences(opts *FlattenOpts) error { log.Printf("importing external schema for [%s] from %s", strings.Join(entry.Keys, ", "), refStr) } // resolve to actual schema - sch, err := swspec.ResolveRefWithBase(opts.Swagger(), &entry.Ref, opts.ExpandOpts(false)) + sch := new(swspec.Schema) + sch.Ref = entry.Ref + expandOpts := swspec.ExpandOptions{ + RelativeBase: opts.BasePath, + SkipSchemas: false, + } + err := swspec.ExpandSchemaWithBasePath(sch, nil, &expandOpts) if err != nil { return err } |