Bumping k8s dependencies to 1.13
This commit is contained in:
16
vendor/github.com/go-openapi/jsonpointer/.travis.yml
generated
vendored
16
vendor/github.com/go-openapi/jsonpointer/.travis.yml
generated
vendored
@@ -1,15 +1,15 @@
|
||||
language: go
|
||||
after_success:
|
||||
- bash <(curl -s https://codecov.io/bash)
|
||||
go:
|
||||
- "1.8"
|
||||
- "1.9"
|
||||
- "1.10"
|
||||
- '1.9'
|
||||
- 1.10.x
|
||||
- 1.11.x
|
||||
install:
|
||||
- go get -u github.com/stretchr/testify/assert
|
||||
- go get -u github.com/go-openapi/swag
|
||||
script:
|
||||
- go test -v -race -cover -coverprofile=coverage.txt -covermode=atomic ./...
|
||||
after_success:
|
||||
- bash <(curl -s https://codecov.io/bash)
|
||||
language: go
|
||||
notifications:
|
||||
slack:
|
||||
secure: a5VgoiwB1G/AZqzmephPZIhEB9avMlsWSlVnM1dSAtYAwdrQHGTQxAmpOxYIoSPDhWNN5bfZmjd29++UlTwLcHSR+e0kJhH6IfDlsHj/HplNCJ9tyI0zYc7XchtdKgeMxMzBKCzgwFXGSbQGydXTliDNBo0HOzmY3cou/daMFTP60K+offcjS+3LRAYb1EroSRXZqrk1nuF/xDL3792DZUdPMiFR/L/Df6y74D6/QP4sTkTDFQitz4Wy/7jbsfj8dG6qK2zivgV6/l+w4OVjFkxVpPXogDWY10vVXNVynqxfJ7to2d1I9lNCHE2ilBCkWMIPdyJF7hjF8pKW+82yP4EzRh0vu8Xn0HT5MZpQxdRY/YMxNrWaG7SxsoEaO4q5uhgdzAqLYY3TRa7MjIK+7Ur+aqOeTXn6OKwVi0CjvZ6mIU3WUKSwiwkFZMbjRAkSb5CYwMEfGFO/z964xz83qGt6WAtBXNotqCQpTIiKtDHQeLOMfksHImCg6JLhQcWBVxamVgu0G3Pdh8Y6DyPnxraXY95+QDavbjqv7TeYT9T/FNnrkXaTTK0s4iWE5H4ACU0Qvz0wUYgfQrZv0/Hp7V17+rabUwnzYySHCy9SWX/7OV9Cfh31iMp9ZIffr76xmmThtOEqs8TrTtU6BWI3rWwvA9cXQipZTVtL0oswrGw=
|
||||
script:
|
||||
- go test -v -race -cover -coverprofile=coverage.txt -covermode=atomic ./...
|
||||
|
10
vendor/github.com/go-openapi/jsonpointer/go.mod
generated
vendored
Normal file
10
vendor/github.com/go-openapi/jsonpointer/go.mod
generated
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
module github.com/go-openapi/jsonpointer
|
||||
|
||||
require (
|
||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||
github.com/go-openapi/swag v0.17.0
|
||||
github.com/mailru/easyjson v0.0.0-20180823135443-60711f1a8329 // indirect
|
||||
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||
github.com/stretchr/testify v1.2.2
|
||||
gopkg.in/yaml.v2 v2.2.1 // indirect
|
||||
)
|
11
vendor/github.com/go-openapi/jsonpointer/go.sum
generated
vendored
Normal file
11
vendor/github.com/go-openapi/jsonpointer/go.sum
generated
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/go-openapi/swag v0.17.0 h1:7wu+dZ5k83kvUWeAb+WUkFiUhDzwGqzTR/NhWzeo1JU=
|
||||
github.com/go-openapi/swag v0.17.0/go.mod h1:DXUve3Dpr1UfpPtxFw+EFuQ41HhCWZfha5jSVRG7C7I=
|
||||
github.com/mailru/easyjson v0.0.0-20180823135443-60711f1a8329 h1:2gxZ0XQIU/5z3Z3bUBu+FXuk2pFbkN6tcwi/pjyaDic=
|
||||
github.com/mailru/easyjson v0.0.0-20180823135443-60711f1a8329/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w=
|
||||
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
16
vendor/github.com/go-openapi/jsonreference/.travis.yml
generated
vendored
16
vendor/github.com/go-openapi/jsonreference/.travis.yml
generated
vendored
@@ -1,16 +1,16 @@
|
||||
language: go
|
||||
after_success:
|
||||
- bash <(curl -s https://codecov.io/bash)
|
||||
go:
|
||||
- "1.8"
|
||||
- "1.9"
|
||||
- "1.10"
|
||||
- '1.9'
|
||||
- 1.10.x
|
||||
- 1.11.x
|
||||
install:
|
||||
- go get -u github.com/stretchr/testify/assert
|
||||
- go get -u github.com/PuerkitoBio/purell
|
||||
- go get -u github.com/go-openapi/jsonpointer
|
||||
script:
|
||||
- go test -v -race -cover -coverprofile=coverage.txt -covermode=atomic ./...
|
||||
after_success:
|
||||
- bash <(curl -s https://codecov.io/bash)
|
||||
language: go
|
||||
notifications:
|
||||
slack:
|
||||
secure: OpQG/36F7DSF00HLm9WZMhyqFCYYyYTsVDObW226cWiR8PWYiNfLZiSEvIzT1Gx4dDjhigKTIqcLhG34CkL5iNXDjm9Yyo2RYhQPlK8NErNqUEXuBqn4RqYHW48VGhEhOyDd4Ei0E2FN5ZbgpvHgtpkdZ6XDi64r3Ac89isP9aPHXQTuv2Jog6b4/OKKiUTftLcTIst0p4Cp3gqOJWf1wnoj+IadWiECNVQT6zb47IYjtyw6+uV8iUjTzdKcRB6Zc6b4Dq7JAg1Zd7Jfxkql3hlKp4PNlRf9Cy7y5iA3G7MLyg3FcPX5z2kmcyPt2jOTRMBWUJ5zIQpOxizAcN8WsT3WWBL5KbuYK6k0PzujrIDLqdxGpNmjkkMfDBT9cKmZpm2FdW+oZgPFJP+oKmAo4u4KJz/vjiPTXgQlN5bmrLuRMCp+AwC5wkIohTqWZVPE2TK6ZSnMYcg/W39s+RP/9mJoyryAvPSpBOLTI+biCgaUCTOAZxNTWpMFc3tPYntc41WWkdKcooZ9JA5DwfcaVFyTGQ3YXz+HvX6G1z/gW0Q/A4dBi9mj2iE1xm7tRTT+4VQ2AXFvSEI1HJpfPgYnwAtwOD1v3Qm2EUHk9sCdtEDR4wVGEPIVn44GnwFMnGKx9JWppMPYwFu3SVDdHt+E+LOlhZUply11Aa+IVrT2KUQ=
|
||||
script:
|
||||
- go test -v -race -cover -coverprofile=coverage.txt -covermode=atomic ./...
|
||||
|
15
vendor/github.com/go-openapi/jsonreference/go.mod
generated
vendored
Normal file
15
vendor/github.com/go-openapi/jsonreference/go.mod
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
module github.com/go-openapi/jsonreference
|
||||
|
||||
require (
|
||||
github.com/PuerkitoBio/purell v1.1.0
|
||||
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect
|
||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||
github.com/go-openapi/jsonpointer v0.17.0
|
||||
github.com/go-openapi/swag v0.17.0 // indirect
|
||||
github.com/mailru/easyjson v0.0.0-20180823135443-60711f1a8329 // indirect
|
||||
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||
github.com/stretchr/testify v1.2.2
|
||||
golang.org/x/net v0.0.0-20181005035420-146acd28ed58 // indirect
|
||||
golang.org/x/text v0.3.0 // indirect
|
||||
gopkg.in/yaml.v2 v2.2.1 // indirect
|
||||
)
|
20
vendor/github.com/go-openapi/jsonreference/go.sum
generated
vendored
Normal file
20
vendor/github.com/go-openapi/jsonreference/go.sum
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
github.com/PuerkitoBio/purell v1.1.0 h1:rmGxhojJlM0tuKtfdvliR84CFHljx9ag64t2xmVkjK4=
|
||||
github.com/PuerkitoBio/purell v1.1.0/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0=
|
||||
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 h1:d+Bc7a5rLufV/sSk/8dngufqelfh6jnri85riMAaF/M=
|
||||
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/go-openapi/jsonpointer v0.17.0 h1:Bpl2DtZ6k7wKqfFs7e+4P08+M9I3FQgn09a1UsRUQbk=
|
||||
github.com/go-openapi/jsonpointer v0.17.0/go.mod h1:+35s3my2LFTysnkMfxsJBAMHj/DoqoB9knIWoYG/Vk0=
|
||||
github.com/go-openapi/swag v0.17.0 h1:7wu+dZ5k83kvUWeAb+WUkFiUhDzwGqzTR/NhWzeo1JU=
|
||||
github.com/go-openapi/swag v0.17.0/go.mod h1:DXUve3Dpr1UfpPtxFw+EFuQ41HhCWZfha5jSVRG7C7I=
|
||||
github.com/mailru/easyjson v0.0.0-20180823135443-60711f1a8329 h1:2gxZ0XQIU/5z3Z3bUBu+FXuk2pFbkN6tcwi/pjyaDic=
|
||||
github.com/mailru/easyjson v0.0.0-20180823135443-60711f1a8329/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w=
|
||||
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||
golang.org/x/net v0.0.0-20181005035420-146acd28ed58 h1:otZG8yDCO4LVps5+9bxOeNiCvgmOyt96J3roHTYs7oE=
|
||||
golang.org/x/net v0.0.0-20181005035420-146acd28ed58/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
1
vendor/github.com/go-openapi/spec/.golangci.yml
generated
vendored
1
vendor/github.com/go-openapi/spec/.golangci.yml
generated
vendored
@@ -18,3 +18,4 @@ linters:
|
||||
disable:
|
||||
- maligned
|
||||
- unparam
|
||||
- lll
|
||||
|
16
vendor/github.com/go-openapi/spec/.travis.yml
generated
vendored
16
vendor/github.com/go-openapi/spec/.travis.yml
generated
vendored
@@ -1,18 +1,18 @@
|
||||
language: go
|
||||
after_success:
|
||||
- bash <(curl -s https://codecov.io/bash)
|
||||
go:
|
||||
- 1.7
|
||||
- 1.8
|
||||
- 1.9
|
||||
- '1.9'
|
||||
- 1.10.x
|
||||
- 1.11.x
|
||||
install:
|
||||
- go get -u github.com/stretchr/testify
|
||||
- go get -u github.com/go-openapi/swag
|
||||
- go get -u gopkg.in/yaml.v2
|
||||
- go get -u github.com/go-openapi/jsonpointer
|
||||
- go get -u github.com/go-openapi/jsonreference
|
||||
script:
|
||||
- go test -v -race -cover -coverprofile=coverage.txt -covermode=atomic ./...
|
||||
after_success:
|
||||
- bash <(curl -s https://codecov.io/bash)
|
||||
language: go
|
||||
notifications:
|
||||
slack:
|
||||
secure: QUWvCkBBK09GF7YtEvHHVt70JOkdlNBG0nIKu/5qc4/nW5HP8I2w0SEf/XR2je0eED1Qe3L/AfMCWwrEj+IUZc3l4v+ju8X8R3Lomhme0Eb0jd1MTMCuPcBT47YCj0M7RON7vXtbFfm1hFJ/jLe5+9FXz0hpXsR24PJc5ZIi/ogNwkaPqG4BmndzecpSh0vc2FJPZUD9LT0I09REY/vXR0oQAalLkW0asGD5taHZTUZq/kBpsNxaAFrLM23i4mUcf33M5fjLpvx5LRICrX/57XpBrDh2TooBU6Qj3CgoY0uPRYUmSNxbVx1czNzl2JtEpb5yjoxfVPQeg0BvQM00G8LJINISR+ohrjhkZmAqchDupAX+yFrxTtORa78CtnIL6z/aTNlgwwVD8kvL/1pFA/JWYmKDmz93mV/+6wubGzNSQCstzjkFA4/iZEKewKUoRIAi/fxyscP6L/rCpmY/4llZZvrnyTqVbt6URWpopUpH4rwYqreXAtJxJsfBJIeSmUIiDIOMGkCTvyTEW3fWGmGoqWtSHLoaWDyAIGb7azb+KvfpWtEcoPFWfSWU+LGee0A/YsUhBl7ADB9A0CJEuR8q4BPpKpfLwPKSiKSAXL7zDkyjExyhtgqbSl2jS+rKIHOZNL8JkCcTP2MKMVd563C5rC5FMKqu3S9m2b6380E=
|
||||
script:
|
||||
- go test -v -race -cover -coverprofile=coverage.txt -covermode=atomic ./...
|
||||
|
103
vendor/github.com/go-openapi/spec/expander.go
generated
vendored
103
vendor/github.com/go-openapi/spec/expander.go
generated
vendored
@@ -32,9 +32,10 @@ import (
|
||||
|
||||
// ExpandOptions provides options for expand.
|
||||
type ExpandOptions struct {
|
||||
RelativeBase string
|
||||
SkipSchemas bool
|
||||
ContinueOnError bool
|
||||
RelativeBase string
|
||||
SkipSchemas bool
|
||||
ContinueOnError bool
|
||||
AbsoluteCircularRef bool
|
||||
}
|
||||
|
||||
// ResolutionCache a cache for resolving urls
|
||||
@@ -444,7 +445,7 @@ func normalizeFileRef(ref *Ref, relativeBase string) *Ref {
|
||||
return &r
|
||||
}
|
||||
|
||||
debugLog("normalizing %s against %s (%s)", ref.String(), relativeBase, ref.GetURL().String())
|
||||
debugLog("normalizing %s against %s", ref.String(), relativeBase)
|
||||
|
||||
s := normalizePaths(ref.String(), relativeBase)
|
||||
r, _ := NewRef(s)
|
||||
@@ -607,25 +608,35 @@ func shouldStopOnError(err error, opts *ExpandOptions) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// ExpandSchema expands the refs in the schema object with reference to the root object
|
||||
// go-openapi/validate uses this function
|
||||
// notice that it is impossible to reference a json scema in a different file other than root
|
||||
func ExpandSchema(schema *Schema, root interface{}, cache ResolutionCache) error {
|
||||
// Only save the root to a tmp file if it isn't nil.
|
||||
var base string
|
||||
// baseForRoot loads in the cache the root document and produces a fake "root" base path entry
|
||||
// for further $ref resolution
|
||||
func baseForRoot(root interface{}, cache ResolutionCache) string {
|
||||
// cache the root document to resolve $ref's
|
||||
const rootBase = "root"
|
||||
if root != nil {
|
||||
base, _ = absPath("root")
|
||||
base, _ := absPath(rootBase)
|
||||
normalizedBase := normalizeAbsPath(base)
|
||||
debugLog("setting root doc in cache at: %s", normalizedBase)
|
||||
if cache == nil {
|
||||
cache = resCache
|
||||
}
|
||||
cache.Set(normalizeAbsPath(base), root)
|
||||
base = "root"
|
||||
cache.Set(normalizedBase, root)
|
||||
return rootBase
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
// ExpandSchema expands the refs in the schema object with reference to the root object
|
||||
// go-openapi/validate uses this function
|
||||
// notice that it is impossible to reference a json schema in a different file other than root
|
||||
func ExpandSchema(schema *Schema, root interface{}, cache ResolutionCache) error {
|
||||
opts := &ExpandOptions{
|
||||
RelativeBase: base,
|
||||
// when a root is specified, cache the root as an in-memory document for $ref retrieval
|
||||
RelativeBase: baseForRoot(root, cache),
|
||||
SkipSchemas: false,
|
||||
ContinueOnError: false,
|
||||
// when no base path is specified, remaining $ref (circular) are rendered with an absolute path
|
||||
AbsoluteCircularRef: true,
|
||||
}
|
||||
return ExpandSchemaWithBasePath(schema, cache, opts)
|
||||
}
|
||||
@@ -734,6 +745,7 @@ func expandSchema(target Schema, parentRefs []string, resolver *schemaLoader, ba
|
||||
otherwise the basePath should inherit the parent's */
|
||||
// important: ID can be relative path
|
||||
if target.ID != "" {
|
||||
debugLog("schema has ID: %s", target.ID)
|
||||
// handling the case when id is a folder
|
||||
// remember that basePath has to be a file
|
||||
refPath := target.ID
|
||||
@@ -757,11 +769,13 @@ func expandSchema(target Schema, parentRefs []string, resolver *schemaLoader, ba
|
||||
// this means there is a cycle in the recursion tree: return the Ref
|
||||
// - circular refs cannot be expanded. We leave them as ref.
|
||||
// - denormalization means that a new local file ref is set relative to the original basePath
|
||||
debugLog("shortcut circular ref")
|
||||
debugLog("basePath: %s", basePath)
|
||||
debugLog("normalized basePath: %s", normalizedBasePath)
|
||||
debugLog("normalized ref: %s", normalizedRef.String())
|
||||
target.Ref = *denormalizeFileRef(normalizedRef, normalizedBasePath, resolver.context.basePath)
|
||||
debugLog("shortcut circular ref: basePath: %s, normalizedPath: %s, normalized ref: %s",
|
||||
basePath, normalizedBasePath, normalizedRef.String())
|
||||
if !resolver.options.AbsoluteCircularRef {
|
||||
target.Ref = *denormalizeFileRef(normalizedRef, normalizedBasePath, resolver.context.basePath)
|
||||
} else {
|
||||
target.Ref = *normalizedRef
|
||||
}
|
||||
return &target, nil
|
||||
}
|
||||
|
||||
@@ -1015,19 +1029,40 @@ func transitiveResolver(basePath string, ref Ref, resolver *schemaLoader) (*sche
|
||||
return resolver, nil
|
||||
}
|
||||
|
||||
// ExpandResponseWithRoot expands a response based on a root document, not a fetchable document
|
||||
func ExpandResponseWithRoot(response *Response, root interface{}, cache ResolutionCache) error {
|
||||
opts := &ExpandOptions{
|
||||
RelativeBase: baseForRoot(root, cache),
|
||||
SkipSchemas: false,
|
||||
ContinueOnError: false,
|
||||
// when no base path is specified, remaining $ref (circular) are rendered with an absolute path
|
||||
AbsoluteCircularRef: true,
|
||||
}
|
||||
resolver, err := defaultSchemaLoader(root, opts, nil, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return expandResponse(response, resolver, opts.RelativeBase)
|
||||
}
|
||||
|
||||
// ExpandResponse expands a response based on a basepath
|
||||
// This is the exported version of expandResponse
|
||||
// all refs inside response will be resolved relative to basePath
|
||||
func ExpandResponse(response *Response, basePath string) error {
|
||||
var specBasePath string
|
||||
if basePath != "" {
|
||||
specBasePath, _ = absPath(basePath)
|
||||
}
|
||||
opts := &ExpandOptions{
|
||||
RelativeBase: basePath,
|
||||
RelativeBase: specBasePath,
|
||||
}
|
||||
resolver, err := defaultSchemaLoader(nil, opts, nil, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return expandResponse(response, resolver, basePath)
|
||||
return expandResponse(response, resolver, opts.RelativeBase)
|
||||
}
|
||||
|
||||
func derefResponse(response *Response, parentRefs []string, resolver *schemaLoader, basePath string) error {
|
||||
@@ -1058,7 +1093,6 @@ func expandResponse(response *Response, resolver *schemaLoader, basePath string)
|
||||
if response == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
parentRefs := []string{}
|
||||
if err := derefResponse(response, parentRefs, resolver, basePath); shouldStopOnError(err, resolver.options) {
|
||||
return err
|
||||
@@ -1094,19 +1128,40 @@ func expandResponse(response *Response, resolver *schemaLoader, basePath string)
|
||||
return nil
|
||||
}
|
||||
|
||||
// ExpandParameterWithRoot expands a parameter based on a root document, not a fetchable document
|
||||
func ExpandParameterWithRoot(parameter *Parameter, root interface{}, cache ResolutionCache) error {
|
||||
opts := &ExpandOptions{
|
||||
RelativeBase: baseForRoot(root, cache),
|
||||
SkipSchemas: false,
|
||||
ContinueOnError: false,
|
||||
// when no base path is specified, remaining $ref (circular) are rendered with an absolute path
|
||||
AbsoluteCircularRef: true,
|
||||
}
|
||||
resolver, err := defaultSchemaLoader(root, opts, nil, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return expandParameter(parameter, resolver, opts.RelativeBase)
|
||||
}
|
||||
|
||||
// ExpandParameter expands a parameter based on a basepath
|
||||
// This is the exported version of expandParameter
|
||||
// all refs inside parameter will be resolved relative to basePath
|
||||
func ExpandParameter(parameter *Parameter, basePath string) error {
|
||||
var specBasePath string
|
||||
if basePath != "" {
|
||||
specBasePath, _ = absPath(basePath)
|
||||
}
|
||||
opts := &ExpandOptions{
|
||||
RelativeBase: basePath,
|
||||
RelativeBase: specBasePath,
|
||||
}
|
||||
resolver, err := defaultSchemaLoader(nil, opts, nil, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return expandParameter(parameter, resolver, basePath)
|
||||
return expandParameter(parameter, resolver, opts.RelativeBase)
|
||||
}
|
||||
|
||||
func derefParameter(parameter *Parameter, parentRefs []string, resolver *schemaLoader, basePath string) error {
|
||||
|
116
vendor/github.com/go-openapi/spec/expander_test.go
generated
vendored
116
vendor/github.com/go-openapi/spec/expander_test.go
generated
vendored
@@ -32,6 +32,10 @@ import (
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
var (
|
||||
rex = regexp.MustCompile(`"\$ref":\s*"(.+)"`)
|
||||
)
|
||||
|
||||
func jsonDoc(path string) (json.RawMessage, error) {
|
||||
data, err := swag.LoadFromFileOrHTTP(path)
|
||||
if err != nil {
|
||||
@@ -286,6 +290,39 @@ func TestExportedResponseExpansion(t *testing.T) {
|
||||
// assert.Equal(t, expected, resp)
|
||||
}
|
||||
|
||||
func TestExpandResponseAndParamWithRoot(t *testing.T) {
|
||||
specDoc, err := jsonDoc("fixtures/bugs/1614/gitea.json")
|
||||
if !assert.NoError(t, err) {
|
||||
t.FailNow()
|
||||
return
|
||||
}
|
||||
var spec Swagger
|
||||
_ = json.Unmarshal(specDoc, &spec)
|
||||
|
||||
// check responses with $ref
|
||||
resp := spec.Paths.Paths["/admin/users"].Post.Responses.StatusCodeResponses[201]
|
||||
err = ExpandResponseWithRoot(&resp, spec, nil)
|
||||
assert.NoError(t, err)
|
||||
jazon, _ := json.MarshalIndent(resp, "", " ")
|
||||
m := rex.FindAllStringSubmatch(string(jazon), -1)
|
||||
assert.Nil(t, m)
|
||||
|
||||
resp = spec.Paths.Paths["/admin/users"].Post.Responses.StatusCodeResponses[403]
|
||||
err = ExpandResponseWithRoot(&resp, spec, nil)
|
||||
assert.NoError(t, err)
|
||||
jazon, _ = json.MarshalIndent(resp, "", " ")
|
||||
m = rex.FindAllStringSubmatch(string(jazon), -1)
|
||||
assert.Nil(t, m)
|
||||
|
||||
// check param with $ref
|
||||
param := spec.Paths.Paths["/admin/users"].Post.Parameters[0]
|
||||
err = ExpandParameterWithRoot(¶m, spec, nil)
|
||||
assert.NoError(t, err)
|
||||
jazon, _ = json.MarshalIndent(param, "", " ")
|
||||
m = rex.FindAllStringSubmatch(string(jazon), -1)
|
||||
assert.Nil(t, m)
|
||||
}
|
||||
|
||||
func TestIssue3(t *testing.T) {
|
||||
spec := new(Swagger)
|
||||
specDoc, err := jsonDoc("fixtures/expansion/overflow.json")
|
||||
@@ -428,7 +465,6 @@ func Test_MoreCircular(t *testing.T) {
|
||||
|
||||
fixturePath := "fixtures/more_circulars/spec.json"
|
||||
jazon := expandThisOrDieTrying(t, fixturePath)
|
||||
rex := regexp.MustCompile(`"\$ref":\s*"(.+)"`)
|
||||
m := rex.FindAllStringSubmatch(jazon, -1)
|
||||
if assert.NotNil(t, m) {
|
||||
for _, matched := range m {
|
||||
@@ -440,7 +476,6 @@ func Test_MoreCircular(t *testing.T) {
|
||||
|
||||
fixturePath = "fixtures/more_circulars/spec2.json"
|
||||
jazon = expandThisOrDieTrying(t, fixturePath)
|
||||
rex = regexp.MustCompile(`"\$ref":\s*"(.+)"`)
|
||||
m = rex.FindAllStringSubmatch(jazon, -1)
|
||||
if assert.NotNil(t, m) {
|
||||
for _, matched := range m {
|
||||
@@ -452,7 +487,6 @@ func Test_MoreCircular(t *testing.T) {
|
||||
|
||||
fixturePath = "fixtures/more_circulars/spec3.json"
|
||||
jazon = expandThisOrDieTrying(t, fixturePath)
|
||||
rex = regexp.MustCompile(`"\$ref":\s*"(.+)"`)
|
||||
m = rex.FindAllStringSubmatch(jazon, -1)
|
||||
if assert.NotNil(t, m) {
|
||||
for _, matched := range m {
|
||||
@@ -464,7 +498,6 @@ func Test_MoreCircular(t *testing.T) {
|
||||
|
||||
fixturePath = "fixtures/more_circulars/spec4.json"
|
||||
jazon = expandThisOrDieTrying(t, fixturePath)
|
||||
rex = regexp.MustCompile(`"\$ref":\s*"(.+)"`)
|
||||
m = rex.FindAllStringSubmatch(jazon, -1)
|
||||
if assert.NotNil(t, m) {
|
||||
for _, matched := range m {
|
||||
@@ -481,7 +514,6 @@ func Test_Issue957(t *testing.T) {
|
||||
if assert.NotEmpty(t, jazon) {
|
||||
assert.NotContainsf(t, jazon, "fixture-957.json#/",
|
||||
"expected %s to be expanded with stripped circular $ref", fixturePath)
|
||||
rex := regexp.MustCompile(`"\$ref":\s*"(.+)"`)
|
||||
m := rex.FindAllStringSubmatch(jazon, -1)
|
||||
if assert.NotNil(t, m) {
|
||||
for _, matched := range m {
|
||||
@@ -499,7 +531,6 @@ func Test_Bitbucket(t *testing.T) {
|
||||
|
||||
fixturePath := "fixtures/more_circulars/bitbucket.json"
|
||||
jazon := expandThisOrDieTrying(t, fixturePath)
|
||||
rex := regexp.MustCompile(`"\$ref":\s*"(.+)"`)
|
||||
m := rex.FindAllStringSubmatch(jazon, -1)
|
||||
if assert.NotNil(t, m) {
|
||||
for _, matched := range m {
|
||||
@@ -514,7 +545,6 @@ func Test_ExpandJSONSchemaDraft4(t *testing.T) {
|
||||
fixturePath := filepath.Join("schemas", "jsonschema-draft-04.json")
|
||||
jazon := expandThisSchemaOrDieTrying(t, fixturePath)
|
||||
// assert all $ref maches "$ref": "http://json-schema.org/draft-04/something"
|
||||
rex := regexp.MustCompile(`"\$ref":\s*"(.+)"`)
|
||||
m := rex.FindAllStringSubmatch(jazon, -1)
|
||||
if assert.NotNil(t, m) {
|
||||
for _, matched := range m {
|
||||
@@ -529,7 +559,6 @@ func Test_ExpandSwaggerSchema(t *testing.T) {
|
||||
fixturePath := filepath.Join("schemas", "v2", "schema.json")
|
||||
jazon := expandThisSchemaOrDieTrying(t, fixturePath)
|
||||
// assert all $ref maches "$ref": "#/definitions/something"
|
||||
rex := regexp.MustCompile(`"\$ref":\s*"(.+)"`)
|
||||
m := rex.FindAllStringSubmatch(jazon, -1)
|
||||
if assert.NotNil(t, m) {
|
||||
for _, matched := range m {
|
||||
@@ -1412,6 +1441,77 @@ func TestResolveForTransitiveRefs(t *testing.T) {
|
||||
assert.NoError(t, err)
|
||||
}
|
||||
|
||||
const (
|
||||
withoutSchemaID = "removed"
|
||||
withSchemaID = "schema"
|
||||
)
|
||||
|
||||
func TestExpandSchemaWithRoot(t *testing.T) {
|
||||
root := new(Swagger)
|
||||
_ = json.Unmarshal(PetStoreJSONMessage, root)
|
||||
|
||||
// 1. remove ID from root definition
|
||||
origPet := root.Definitions["Pet"]
|
||||
newPet := origPet
|
||||
newPet.ID = ""
|
||||
root.Definitions["Pet"] = newPet
|
||||
expandRootWithID(t, root, withoutSchemaID)
|
||||
|
||||
// 2. put back ID in Pet definition
|
||||
// nested $ref should fail
|
||||
//Debug = true
|
||||
root.Definitions["Pet"] = origPet
|
||||
expandRootWithID(t, root, withSchemaID)
|
||||
}
|
||||
|
||||
func expandRootWithID(t *testing.T, root *Swagger, testcase string) {
|
||||
t.Logf("case: expanding $ref to schema without ID, with nested $ref with %s ID", testcase)
|
||||
sch := &Schema{
|
||||
SchemaProps: SchemaProps{
|
||||
Ref: MustCreateRef("#/definitions/newPet"),
|
||||
},
|
||||
}
|
||||
err := ExpandSchema(sch, root, nil)
|
||||
if testcase == withSchemaID {
|
||||
assert.Errorf(t, err, "expected %s NOT to expand properly because of the ID in the parent schema", sch.Ref.String())
|
||||
} else {
|
||||
assert.NoErrorf(t, err, "expected %s to expand properly", sch.Ref.String())
|
||||
}
|
||||
if Debug {
|
||||
bbb, _ := json.MarshalIndent(sch, "", " ")
|
||||
t.Log(string(bbb))
|
||||
}
|
||||
|
||||
t.Log("case: expanding $ref to schema without nested $ref")
|
||||
sch = &Schema{
|
||||
SchemaProps: SchemaProps{
|
||||
Ref: MustCreateRef("#/definitions/Category"),
|
||||
},
|
||||
}
|
||||
err = ExpandSchema(sch, root, nil)
|
||||
assert.NoErrorf(t, err, "expected %s to expand properly", sch.Ref.String())
|
||||
if Debug {
|
||||
bbb, _ := json.MarshalIndent(sch, "", " ")
|
||||
t.Log(string(bbb))
|
||||
}
|
||||
t.Logf("case: expanding $ref to schema with %s ID and nested $ref", testcase)
|
||||
sch = &Schema{
|
||||
SchemaProps: SchemaProps{
|
||||
Ref: MustCreateRef("#/definitions/Pet"),
|
||||
},
|
||||
}
|
||||
err = ExpandSchema(sch, root, nil)
|
||||
if testcase == withSchemaID {
|
||||
assert.Errorf(t, err, "expected %s NOT to expand properly because of the ID in the parent schema", sch.Ref.String())
|
||||
} else {
|
||||
assert.NoErrorf(t, err, "expected %s to expand properly", sch.Ref.String())
|
||||
}
|
||||
if Debug {
|
||||
bbb, _ := json.MarshalIndent(sch, "", " ")
|
||||
t.Log(string(bbb))
|
||||
}
|
||||
}
|
||||
|
||||
// PetStoreJSONMessage json raw message for Petstore20
|
||||
var PetStoreJSONMessage = json.RawMessage([]byte(PetStore20))
|
||||
|
||||
|
7916
vendor/github.com/go-openapi/spec/fixtures/bugs/1614/gitea.json
generated
vendored
Normal file
7916
vendor/github.com/go-openapi/spec/fixtures/bugs/1614/gitea.json
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
618
vendor/github.com/go-openapi/spec/fixtures/bugs/1621/definitions.yaml
generated
vendored
Normal file
618
vendor/github.com/go-openapi/spec/fixtures/bugs/1621/definitions.yaml
generated
vendored
Normal file
@@ -0,0 +1,618 @@
|
||||
definitions:
|
||||
|
||||
# Generic response model
|
||||
V4GenericResponse:
|
||||
type: object
|
||||
properties:
|
||||
message:
|
||||
type: string
|
||||
description: A human readable message
|
||||
code:
|
||||
type: string
|
||||
description: |
|
||||
A machine readable [response code](https://github.com/giantswarm/api-spec/blob/master/details/RESPONSE_CODES.md) like e. g. `INVALID_CREDENTIALS`
|
||||
|
||||
# Info resposne
|
||||
V4InfoResponse:
|
||||
type: object
|
||||
properties:
|
||||
general:
|
||||
description: General information
|
||||
type: object
|
||||
properties:
|
||||
installation_name:
|
||||
description: Unique name of the installation
|
||||
type: string
|
||||
provider:
|
||||
description: The technical provider used in this installation. Either "kvm", "aws", or "azure".
|
||||
type: string
|
||||
datacenter:
|
||||
description: Identifier of the datacenter or cloud provider region, e. g. "eu-west-1"
|
||||
type: string
|
||||
workers:
|
||||
description: Information related to worker nodes
|
||||
type: object
|
||||
properties:
|
||||
count_per_cluster:
|
||||
description: Number of workers per cluster
|
||||
type: object
|
||||
properties:
|
||||
max:
|
||||
description: Maximum number of worker a cluster can have
|
||||
type: number
|
||||
default:
|
||||
description: Default number of workers in a new cluster will have, if not specifiec otherwise
|
||||
type: number
|
||||
instance_type:
|
||||
description: Instance types to be used for worker nodes. Only available for AWS clusters.
|
||||
type: object
|
||||
properties:
|
||||
options:
|
||||
description: List of available instance types
|
||||
type: array
|
||||
items:
|
||||
type: string
|
||||
default:
|
||||
description: The instance type used in new cluster, if not specified
|
||||
type: string
|
||||
vm_size:
|
||||
description: Azure Virtual Machine size to be used for worker nodes. Only available for Azure clusters.
|
||||
type: object
|
||||
properties:
|
||||
options:
|
||||
description: List of available instance types
|
||||
type: array
|
||||
items:
|
||||
type: string
|
||||
default:
|
||||
description: The instance type used in new cluster, if not specified
|
||||
type: string
|
||||
|
||||
# Request to create a new cluster
|
||||
V4AddClusterRequest:
|
||||
type: object
|
||||
required:
|
||||
- owner
|
||||
description: Request model for creating a new cluster
|
||||
properties:
|
||||
owner:
|
||||
type: string
|
||||
description: Name of the organization owning the cluster
|
||||
name:
|
||||
type: string
|
||||
description: Cluster name
|
||||
release_version:
|
||||
type: string
|
||||
description: |
|
||||
The [release](https://docs.giantswarm.io/api/#tag/releases) version
|
||||
to use in the new cluster
|
||||
kubernetes_version:
|
||||
type: string
|
||||
description: |
|
||||
Kubernetes version number (deprecated). Doesn't have any effect.
|
||||
This attribute is going to be removed in future API versions.
|
||||
workers:
|
||||
type: array
|
||||
items:
|
||||
$ref: '#/definitions/V4NodeDefinition'
|
||||
|
||||
V4ModifyClusterRequest:
|
||||
type: object
|
||||
required: []
|
||||
description: Request body for cluster modification
|
||||
properties:
|
||||
name:
|
||||
type: string
|
||||
description: Name for the cluster
|
||||
owner:
|
||||
type: string
|
||||
description: Name of the organization owning the cluster
|
||||
release_version:
|
||||
type: string
|
||||
description: Release version to use after an upgrade
|
||||
workers:
|
||||
type: array
|
||||
description: Worker node array
|
||||
items:
|
||||
$ref: '#/definitions/V4NodeDefinition'
|
||||
|
||||
# Details on existing cluster
|
||||
V4ClusterDetailsResponse:
|
||||
type: object
|
||||
description: Response model showing details of a cluster
|
||||
properties:
|
||||
id:
|
||||
type: string
|
||||
description: Unique cluster identifier
|
||||
api_endpoint:
|
||||
type: string
|
||||
description: URI of the Kubernetes API endpoint
|
||||
create_date:
|
||||
type: string
|
||||
description: Date/time of cluster creation
|
||||
owner:
|
||||
type: string
|
||||
description: Name of the organization owning the cluster
|
||||
name:
|
||||
type: string
|
||||
description: Cluster name
|
||||
release_version:
|
||||
type: string
|
||||
description: |
|
||||
The [release](https://docs.giantswarm.io/api/#tag/releases) version
|
||||
currently running this cluster.
|
||||
kubernetes_version:
|
||||
type: string
|
||||
description: Deprecated. Will be removed in a future API version.
|
||||
workers:
|
||||
type: array
|
||||
items:
|
||||
$ref: '#/definitions/V4NodeDefinition'
|
||||
kvm:
|
||||
type: object
|
||||
description: Attributes specific to clusters running on KVM (on-prem) installations.
|
||||
properties:
|
||||
port_mappings:
|
||||
type: array
|
||||
description: |
|
||||
Reveals the ports on the host cluster that are mapped to this guest cluster's ingress
|
||||
and which protocol that port supports. Only shown and relevant on our on-prem KVM clusters.
|
||||
items:
|
||||
type: object
|
||||
properties:
|
||||
port:
|
||||
description: |
|
||||
The port on the host cluster that will forward traffic to the guest cluster
|
||||
type: integer
|
||||
protocol:
|
||||
description: |
|
||||
The protocol this port mapping is made for.
|
||||
type: string
|
||||
|
||||
# Definition of a cluster node
|
||||
V4NodeDefinition:
|
||||
type: object
|
||||
properties:
|
||||
aws:
|
||||
type: object
|
||||
description: |
|
||||
Attributes specific to nodes running on Amazon Web Services (AWS)
|
||||
properties:
|
||||
instance_type:
|
||||
type: string
|
||||
description: |
|
||||
EC2 instance type name. Must be the same for all worker nodes
|
||||
of a cluster.
|
||||
azure:
|
||||
type: object
|
||||
description: |
|
||||
Attributes specific to nodes running on Microsoft Azure
|
||||
properties:
|
||||
vm_size:
|
||||
type: string
|
||||
description: |
|
||||
Azure Virtual Machine size. Must be the same for all worker nodes
|
||||
of a cluster.
|
||||
memory:
|
||||
type: object
|
||||
properties:
|
||||
size_gb:
|
||||
type: number
|
||||
description: RAM size in GB. Can be an integer or float.
|
||||
storage:
|
||||
type: object
|
||||
properties:
|
||||
size_gb:
|
||||
type: number
|
||||
description: Node storage size in GB. Can be an integer or float.
|
||||
cpu:
|
||||
type: object
|
||||
properties:
|
||||
cores:
|
||||
type: integer
|
||||
description: Number of CPU cores
|
||||
labels:
|
||||
type: object
|
||||
additionalProperties: true
|
||||
|
||||
# List of key pairs
|
||||
V4GetKeyPairsResponse:
|
||||
type: array
|
||||
description: Array of sparse key pair objects
|
||||
items:
|
||||
type: object
|
||||
properties:
|
||||
id:
|
||||
type: string
|
||||
description: Unique identifier of the key pair
|
||||
description:
|
||||
type: string
|
||||
description: Free text information about the key pair
|
||||
ttl_hours:
|
||||
type: integer
|
||||
description: Expiration time (from creation) in hours
|
||||
create_date:
|
||||
type: string
|
||||
description: Date/time of creation
|
||||
common_name:
|
||||
type: string
|
||||
description: The common name of the certificate subject.
|
||||
certificate_organizations:
|
||||
type: string
|
||||
description: The certificate subject's `organization` fields.
|
||||
|
||||
# Add key pair request
|
||||
V4AddKeyPairRequest:
|
||||
type: object
|
||||
required:
|
||||
- description
|
||||
properties:
|
||||
description:
|
||||
type: string
|
||||
description: Free text information about the key pair
|
||||
ttl_hours:
|
||||
type: integer
|
||||
format: int32
|
||||
description: Expiration time (from creation) in hours
|
||||
cn_prefix:
|
||||
type: string
|
||||
description: The common name prefix of the certificate subject. This only allows characters that are usable in domain names (`a-z`, `0-9`, and `.-`, where `.-` must not occur at either the start or the end).
|
||||
certificate_organizations:
|
||||
type: string
|
||||
description: |
|
||||
This will set the certificate subject's `organization` fields.
|
||||
Use a comma seperated list of values.
|
||||
|
||||
V4AddKeyPairResponse:
|
||||
type: object
|
||||
properties:
|
||||
id:
|
||||
type: string
|
||||
description: Unique identifier of the key pair
|
||||
description:
|
||||
type: string
|
||||
description: Free text information about the key pair
|
||||
ttl_hours:
|
||||
type: integer
|
||||
description: Expiration time (from creation) in hours
|
||||
create_date:
|
||||
type: string
|
||||
description: Date/time of creation
|
||||
certificate_authority_data:
|
||||
type: string
|
||||
description: PEM-encoded CA certificate of the cluster
|
||||
client_key_data:
|
||||
type: string
|
||||
description: PEM-encoded RSA private key
|
||||
client_certificate_data:
|
||||
type: string
|
||||
description: PEM-encoded certificate
|
||||
|
||||
# cluster metrics
|
||||
V4GetClusterMetricsResponse:
|
||||
description: Response for the getClusterMetrics operation
|
||||
type: object
|
||||
properties:
|
||||
workers:
|
||||
description: Group of metrics regarding workers
|
||||
type: array
|
||||
items:
|
||||
$ref: '#/definitions/V4NodeMetrics'
|
||||
|
||||
V4NodeMetrics:
|
||||
type: object
|
||||
properties:
|
||||
id:
|
||||
description: String identifying the node
|
||||
type: string
|
||||
metrics:
|
||||
description: Container object for all metrics available for the node
|
||||
type: object
|
||||
properties:
|
||||
container_count:
|
||||
type: object
|
||||
properties:
|
||||
timestamp:
|
||||
description: Time when the given value has been recorded
|
||||
type: string
|
||||
value:
|
||||
description: The value for the metric. Can be an integer or float.
|
||||
type: number
|
||||
pod_count:
|
||||
type: object
|
||||
properties:
|
||||
timestamp:
|
||||
description: Time when the given value has been recorded
|
||||
type: string
|
||||
value:
|
||||
description: The value for the metric. Can be an integer or float.
|
||||
type: number
|
||||
cpu_used:
|
||||
type: object
|
||||
properties:
|
||||
timestamp:
|
||||
description: Time when the given value has been recorded
|
||||
type: string
|
||||
value:
|
||||
description: The value for the metric. Can be an integer or float.
|
||||
type: number
|
||||
ram_free:
|
||||
type: object
|
||||
properties:
|
||||
timestamp:
|
||||
description: Time when the given value has been recorded
|
||||
type: string
|
||||
value:
|
||||
description: The value for the metric. Can be an integer or float.
|
||||
type: number
|
||||
ram_available:
|
||||
type: object
|
||||
properties:
|
||||
timestamp:
|
||||
description: Time when the given value has been recorded
|
||||
type: string
|
||||
value:
|
||||
description: The value for the metric. Can be an integer or float.
|
||||
type: number
|
||||
ram_cached:
|
||||
type: object
|
||||
properties:
|
||||
timestamp:
|
||||
description: Time when the given value has been recorded
|
||||
type: string
|
||||
value:
|
||||
description: The value for the metric. Can be an integer or float.
|
||||
type: number
|
||||
ram_buffers:
|
||||
type: object
|
||||
properties:
|
||||
timestamp:
|
||||
description: Time when the given value has been recorded
|
||||
type: string
|
||||
value:
|
||||
description: The value for the metric. Can be an integer or float.
|
||||
type: number
|
||||
ram_mapped:
|
||||
type: object
|
||||
properties:
|
||||
timestamp:
|
||||
description: Time when the given value has been recorded
|
||||
type: string
|
||||
value:
|
||||
description: The value for the metric. Can be an integer or float.
|
||||
type: number
|
||||
node_storage_used:
|
||||
type: object
|
||||
properties:
|
||||
timestamp:
|
||||
description: Time when the given value has been recorded
|
||||
type: string
|
||||
value:
|
||||
description: The value for the metric. Can be an integer or float.
|
||||
type: number
|
||||
network_rx:
|
||||
type: object
|
||||
properties:
|
||||
timestamp:
|
||||
description: Time when the given value has been recorded
|
||||
type: string
|
||||
value:
|
||||
description: The value for the metric. Can be an integer or float.
|
||||
type: number
|
||||
network_tx:
|
||||
type: object
|
||||
properties:
|
||||
timestamp:
|
||||
description: Time when the given value has been recorded
|
||||
type: string
|
||||
value:
|
||||
description: The value for the metric. Can be an integer or float.
|
||||
type: number
|
||||
resource_cpu_requests:
|
||||
type: object
|
||||
properties:
|
||||
timestamp:
|
||||
description: Time when the given value has been recorded
|
||||
type: string
|
||||
value:
|
||||
description: The value for the metric. Can be an integer or float.
|
||||
type: number
|
||||
resource_cpu_limits:
|
||||
type: object
|
||||
properties:
|
||||
timestamp:
|
||||
description: Time when the given value has been recorded
|
||||
type: string
|
||||
value:
|
||||
description: The value for the metric. Can be an integer or float.
|
||||
type: number
|
||||
resource_ram_requests:
|
||||
type: object
|
||||
properties:
|
||||
timestamp:
|
||||
description: Time when the given value has been recorded
|
||||
type: string
|
||||
value:
|
||||
description: The value for the metric. Can be an integer or float.
|
||||
type: number
|
||||
resource_ram_limits:
|
||||
type: object
|
||||
properties:
|
||||
timestamp:
|
||||
description: Time when the given value has been recorded
|
||||
type: string
|
||||
value:
|
||||
description: The value for the metric. Can be an integer or float.
|
||||
type: number
|
||||
|
||||
# a complete organization object
|
||||
V4Organization:
|
||||
type: object
|
||||
properties:
|
||||
id:
|
||||
type: string
|
||||
description: Unique name/identifier of the organization
|
||||
members:
|
||||
type: array
|
||||
description: List of members that belong to this organization
|
||||
items:
|
||||
$ref: '#/definitions/V4OrganizationMember'
|
||||
|
||||
# An organization as returned by getOrganizations as an array item
|
||||
V4OrganizationListItem:
|
||||
type: object
|
||||
properties:
|
||||
id:
|
||||
type: string
|
||||
description: Unique name/identifier of the organization
|
||||
|
||||
# A user that belongs to an organization
|
||||
V4OrganizationMember:
|
||||
type: object
|
||||
properties:
|
||||
email:
|
||||
type: string
|
||||
description: Email address of the user
|
||||
|
||||
# One of the users in the array as returned by getUsers
|
||||
V4UserListItem:
|
||||
type: object
|
||||
properties:
|
||||
email:
|
||||
type: string
|
||||
description: Email address of the user
|
||||
created:
|
||||
type: string
|
||||
description: The date and time that this account was created
|
||||
expiry:
|
||||
type: string
|
||||
description: The date and time when this account will expire
|
||||
|
||||
# A cluster array item, as return by getClusters
|
||||
V4ClusterListItem:
|
||||
type: object
|
||||
properties:
|
||||
id:
|
||||
type: string
|
||||
description: Unique cluster identifier
|
||||
create_date:
|
||||
type: string
|
||||
description: Date/time of cluster creation
|
||||
name:
|
||||
type: string
|
||||
description: Cluster name
|
||||
owner:
|
||||
type: string
|
||||
description: Name of the organization owning the cluster
|
||||
release_version:
|
||||
type: string
|
||||
description: The semantic version number of this cluster
|
||||
|
||||
# A cluster array item, as return by getClusters
|
||||
V4ReleaseListItem:
|
||||
type: object
|
||||
required: ["version", "timestamp", "changelog", "components"]
|
||||
properties:
|
||||
version:
|
||||
type: string
|
||||
description: The semantic version number
|
||||
timestamp:
|
||||
type: string
|
||||
description: Date and time of the release creation
|
||||
active:
|
||||
type: boolean
|
||||
description: |
|
||||
If true, the version is available for new clusters and cluster
|
||||
upgrades. Older versions become unavailable and thus have the
|
||||
value `false` here.
|
||||
changelog:
|
||||
description: |
|
||||
Structured list of changes in this release, in comparison to the
|
||||
previous version, with respect to the contained components.
|
||||
type: array
|
||||
items:
|
||||
type: object
|
||||
properties:
|
||||
component:
|
||||
type: string
|
||||
description: |
|
||||
If the changed item was a component, this attribute is the
|
||||
name of the component.
|
||||
description:
|
||||
type: string
|
||||
description: Human-friendly description of the change
|
||||
components:
|
||||
description: |
|
||||
List of components and their version contained in the release
|
||||
type: array
|
||||
items:
|
||||
type: object
|
||||
required: ["name", "version"]
|
||||
properties:
|
||||
name:
|
||||
type: string
|
||||
description: Name of the component
|
||||
version:
|
||||
type: string
|
||||
description: Version number of the component
|
||||
|
||||
V4CreateUserRequest:
|
||||
type: object
|
||||
required:
|
||||
- password
|
||||
description: Request model for creating a new user
|
||||
properties:
|
||||
password:
|
||||
type: string
|
||||
description: A Base64 encoded password
|
||||
expiry:
|
||||
type: string
|
||||
description: The date and time when this account will expire
|
||||
|
||||
V4AddCredentialsRequest:
|
||||
type: object
|
||||
required:
|
||||
- provider
|
||||
description: Request model for adding a set of credentials
|
||||
properties:
|
||||
provider:
|
||||
type: string
|
||||
aws:
|
||||
type: object
|
||||
description: Credentials specific to an AWS account
|
||||
required:
|
||||
- roles
|
||||
properties:
|
||||
roles:
|
||||
type: object
|
||||
description: IAM roles to assume by certain entities
|
||||
required:
|
||||
- awsoperator
|
||||
- admin
|
||||
properties:
|
||||
admin:
|
||||
type: string
|
||||
description: ARN of the IAM role to assume by Giant Swarm support staff
|
||||
awsoperator:
|
||||
type: string
|
||||
description: ARN of the IAM role to assume by the software operating clusters
|
||||
|
||||
# A request for an auth token
|
||||
V4CreateAuthTokenRequest:
|
||||
type: object
|
||||
properties:
|
||||
email:
|
||||
type: string
|
||||
description: Your email address
|
||||
password_base64:
|
||||
type: string
|
||||
description: Your password as a base64 encoded string
|
||||
|
||||
# A response to a successful auth token request
|
||||
V4CreateAuthTokenResponse:
|
||||
type: object
|
||||
properties:
|
||||
auth_token:
|
||||
type: string
|
||||
description: The newly created API token
|
||||
|
1310
vendor/github.com/go-openapi/spec/fixtures/bugs/1621/fixture-1621.yaml
generated
vendored
Normal file
1310
vendor/github.com/go-openapi/spec/fixtures/bugs/1621/fixture-1621.yaml
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
61
vendor/github.com/go-openapi/spec/fixtures/bugs/1621/parameters.yaml
generated
vendored
Normal file
61
vendor/github.com/go-openapi/spec/fixtures/bugs/1621/parameters.yaml
generated
vendored
Normal file
@@ -0,0 +1,61 @@
|
||||
parameters:
|
||||
|
||||
RequiredGiantSwarmAuthorizationHeader:
|
||||
name: Authorization
|
||||
type: string
|
||||
in: header
|
||||
required: true
|
||||
description: As described in the [authentication](#section/Authentication) section
|
||||
|
||||
ClusterIdPathParameter:
|
||||
name: cluster_id
|
||||
in: path
|
||||
required: true
|
||||
type: string
|
||||
description: Cluster ID
|
||||
|
||||
UserEmailPathParameter:
|
||||
name: email
|
||||
in: path
|
||||
required: true
|
||||
type: string
|
||||
description: The user's email address
|
||||
|
||||
OrganizationIdPathParameter:
|
||||
name: organization_id
|
||||
in: path
|
||||
required: true
|
||||
type: string
|
||||
description: |
|
||||
An ID for the organization.
|
||||
This ID must be unique and match this regular
|
||||
expression: ^[a-z0-9_]{4,30}$
|
||||
|
||||
XRequestIDHeader:
|
||||
name: X-Request-ID
|
||||
in: header
|
||||
type: string
|
||||
required: false
|
||||
description: |
|
||||
A randomly generated key that can be used to track a request throughout
|
||||
services of Giant Swarm.
|
||||
|
||||
XGiantSwarmActivityHeader:
|
||||
name: X-Giant-Swarm-Activity
|
||||
in: header
|
||||
type: string
|
||||
required: false
|
||||
description: |
|
||||
Name of an activity to track, like "list-clusters". This allows to
|
||||
analyze several API requests sent in context and gives an idea on
|
||||
the purpose.
|
||||
|
||||
XGiantSwarmCmdLineHeader:
|
||||
name: X-Giant-Swarm-CmdLine
|
||||
in: header
|
||||
type: string
|
||||
required: false
|
||||
description: |
|
||||
If activity has been issued by a CLI, this header can contain the
|
||||
command line
|
||||
|
13
vendor/github.com/go-openapi/spec/fixtures/bugs/1621/responses.yaml
generated
vendored
Normal file
13
vendor/github.com/go-openapi/spec/fixtures/bugs/1621/responses.yaml
generated
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
responses:
|
||||
|
||||
V4Generic401Response:
|
||||
description: Permission denied
|
||||
schema:
|
||||
$ref: "./definitions.yaml#/definitions/V4GenericResponse"
|
||||
examples:
|
||||
application/json:
|
||||
{
|
||||
"code": "PERMISSION_DENIED",
|
||||
"message": "The requested resource cannot be accessed using the provided authentication details."
|
||||
}
|
||||
|
16
vendor/github.com/go-openapi/spec/go.mod
generated
vendored
Normal file
16
vendor/github.com/go-openapi/spec/go.mod
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
module github.com/go-openapi/spec
|
||||
|
||||
require (
|
||||
github.com/PuerkitoBio/purell v1.1.0 // indirect
|
||||
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect
|
||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||
github.com/go-openapi/jsonpointer v0.17.0
|
||||
github.com/go-openapi/jsonreference v0.17.0
|
||||
github.com/go-openapi/swag v0.17.0
|
||||
github.com/mailru/easyjson v0.0.0-20180823135443-60711f1a8329 // indirect
|
||||
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||
github.com/stretchr/testify v1.2.2
|
||||
golang.org/x/net v0.0.0-20181005035420-146acd28ed58 // indirect
|
||||
golang.org/x/text v0.3.0 // indirect
|
||||
gopkg.in/yaml.v2 v2.2.1
|
||||
)
|
22
vendor/github.com/go-openapi/spec/go.sum
generated
vendored
Normal file
22
vendor/github.com/go-openapi/spec/go.sum
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
github.com/PuerkitoBio/purell v1.1.0 h1:rmGxhojJlM0tuKtfdvliR84CFHljx9ag64t2xmVkjK4=
|
||||
github.com/PuerkitoBio/purell v1.1.0/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0=
|
||||
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 h1:d+Bc7a5rLufV/sSk/8dngufqelfh6jnri85riMAaF/M=
|
||||
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/go-openapi/jsonpointer v0.17.0 h1:Bpl2DtZ6k7wKqfFs7e+4P08+M9I3FQgn09a1UsRUQbk=
|
||||
github.com/go-openapi/jsonpointer v0.17.0/go.mod h1:+35s3my2LFTysnkMfxsJBAMHj/DoqoB9knIWoYG/Vk0=
|
||||
github.com/go-openapi/jsonreference v0.17.0 h1:d/o7/fsLWWQZACbihvZxcyLQ59jfUVs7WOJv/ak7T7A=
|
||||
github.com/go-openapi/jsonreference v0.17.0/go.mod h1:W3Z9FmVs9qj+KR4zFKmDPGiLdk1D9Rlm7cyMvf57TTg=
|
||||
github.com/go-openapi/swag v0.17.0 h1:7wu+dZ5k83kvUWeAb+WUkFiUhDzwGqzTR/NhWzeo1JU=
|
||||
github.com/go-openapi/swag v0.17.0/go.mod h1:DXUve3Dpr1UfpPtxFw+EFuQ41HhCWZfha5jSVRG7C7I=
|
||||
github.com/mailru/easyjson v0.0.0-20180823135443-60711f1a8329 h1:2gxZ0XQIU/5z3Z3bUBu+FXuk2pFbkN6tcwi/pjyaDic=
|
||||
github.com/mailru/easyjson v0.0.0-20180823135443-60711f1a8329/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w=
|
||||
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||
golang.org/x/net v0.0.0-20181005035420-146acd28ed58 h1:otZG8yDCO4LVps5+9bxOeNiCvgmOyt96J3roHTYs7oE=
|
||||
golang.org/x/net v0.0.0-20181005035420-146acd28ed58/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
80
vendor/github.com/go-openapi/spec/spec_test.go
generated
vendored
80
vendor/github.com/go-openapi/spec/spec_test.go
generated
vendored
@@ -16,6 +16,7 @@ package spec_test
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"strings"
|
||||
@@ -27,7 +28,10 @@ import (
|
||||
)
|
||||
|
||||
// mimics what the go-openapi/load does
|
||||
var yamlLoader = swag.YAMLDoc
|
||||
var (
|
||||
yamlLoader = swag.YAMLDoc
|
||||
rex = regexp.MustCompile(`"\$ref":\s*"(.+)"`)
|
||||
)
|
||||
|
||||
func loadOrFail(t *testing.T, path string) *spec.Swagger {
|
||||
raw, erl := yamlLoader(path)
|
||||
@@ -60,8 +64,6 @@ func Test_Issue1429(t *testing.T) {
|
||||
t.FailNow()
|
||||
return
|
||||
}
|
||||
//bbb, _ := json.MarshalIndent(sp, "", " ")
|
||||
//t.Log(string(bbb))
|
||||
|
||||
// assert well expanded
|
||||
if !assert.Truef(t, (sp.Paths != nil && sp.Paths.Paths != nil), "expected paths to be available in fixture") {
|
||||
@@ -185,7 +187,6 @@ func Test_Issue69(t *testing.T) {
|
||||
jazon, _ := json.MarshalIndent(sp, "", " ")
|
||||
|
||||
// assert all $ref maches "$ref": "#/definitions/something"
|
||||
rex := regexp.MustCompile(`"\$ref":\s*"(.+)"`)
|
||||
m := rex.FindAllStringSubmatch(string(jazon), -1)
|
||||
if assert.NotNil(t, m) {
|
||||
for _, matched := range m {
|
||||
@@ -195,3 +196,74 @@ func Test_Issue69(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func Test_Issue1621(t *testing.T) {
|
||||
prevPathLoader := spec.PathLoader
|
||||
defer func() {
|
||||
spec.PathLoader = prevPathLoader
|
||||
}()
|
||||
spec.PathLoader = yamlLoader
|
||||
path := filepath.Join("fixtures", "bugs", "1621", "fixture-1621.yaml")
|
||||
|
||||
// expand with relative path
|
||||
// load and expand
|
||||
sp := loadOrFail(t, path)
|
||||
|
||||
err := spec.ExpandSpec(sp, &spec.ExpandOptions{RelativeBase: path, SkipSchemas: false})
|
||||
if !assert.NoError(t, err) {
|
||||
t.FailNow()
|
||||
return
|
||||
}
|
||||
// asserts all $ref expanded
|
||||
jazon, _ := json.MarshalIndent(sp, "", " ")
|
||||
m := rex.FindAllStringSubmatch(string(jazon), -1)
|
||||
assert.Nil(t, m)
|
||||
}
|
||||
|
||||
func Test_Issue1614(t *testing.T) {
|
||||
|
||||
path := filepath.Join("fixtures", "bugs", "1614", "gitea.json")
|
||||
|
||||
// expand with relative path
|
||||
// load and expand
|
||||
sp := loadOrFail(t, path)
|
||||
err := spec.ExpandSpec(sp, &spec.ExpandOptions{RelativeBase: path, SkipSchemas: false})
|
||||
if !assert.NoError(t, err) {
|
||||
t.FailNow()
|
||||
return
|
||||
}
|
||||
// asserts all $ref expanded
|
||||
jazon, _ := json.MarshalIndent(sp, "", " ")
|
||||
|
||||
// assert all $ref maches "$ref": "#/definitions/something"
|
||||
m := rex.FindAllStringSubmatch(string(jazon), -1)
|
||||
if assert.NotNil(t, m) {
|
||||
for _, matched := range m {
|
||||
subMatch := matched[1]
|
||||
assert.True(t, strings.HasPrefix(subMatch, "#/definitions/"),
|
||||
"expected $ref to be inlined, got: %s", matched[0])
|
||||
}
|
||||
}
|
||||
|
||||
// now with option CircularRefAbsolute
|
||||
sp = loadOrFail(t, path)
|
||||
err = spec.ExpandSpec(sp, &spec.ExpandOptions{RelativeBase: path, SkipSchemas: false, AbsoluteCircularRef: true})
|
||||
if !assert.NoError(t, err) {
|
||||
t.FailNow()
|
||||
return
|
||||
}
|
||||
// asserts all $ref expanded
|
||||
jazon, _ = json.MarshalIndent(sp, "", " ")
|
||||
|
||||
// assert all $ref maches "$ref": "{file path}#/definitions/something"
|
||||
refPath, _ := os.Getwd()
|
||||
refPath = filepath.Join(refPath, path)
|
||||
m = rex.FindAllStringSubmatch(string(jazon), -1)
|
||||
if assert.NotNil(t, m) {
|
||||
for _, matched := range m {
|
||||
subMatch := matched[1]
|
||||
assert.True(t, strings.HasPrefix(subMatch, refPath+"#/definitions/"),
|
||||
"expected $ref to be inlined, got: %s", matched[0])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
3
vendor/github.com/go-openapi/swag/.golangci.yml
generated
vendored
3
vendor/github.com/go-openapi/swag/.golangci.yml
generated
vendored
@@ -10,10 +10,11 @@ linters-settings:
|
||||
dupl:
|
||||
threshold: 100
|
||||
goconst:
|
||||
min-len: 2
|
||||
min-len: 3
|
||||
min-occurrences: 2
|
||||
|
||||
linters:
|
||||
enable-all: true
|
||||
disable:
|
||||
- maligned
|
||||
- lll
|
||||
|
14
vendor/github.com/go-openapi/swag/.travis.yml
generated
vendored
14
vendor/github.com/go-openapi/swag/.travis.yml
generated
vendored
@@ -1,16 +1,16 @@
|
||||
language: go
|
||||
after_success:
|
||||
- bash <(curl -s https://codecov.io/bash)
|
||||
go:
|
||||
- 1.8
|
||||
- 1.9.x
|
||||
- '1.9'
|
||||
- 1.10.x
|
||||
- 1.11.x
|
||||
install:
|
||||
- go get -u github.com/stretchr/testify
|
||||
- go get -u github.com/mailru/easyjson
|
||||
- go get -u gopkg.in/yaml.v2
|
||||
script:
|
||||
- go test -v -race -cover -coverprofile=coverage.txt -covermode=atomic ./...
|
||||
after_success:
|
||||
- bash <(curl -s https://codecov.io/bash)
|
||||
language: go
|
||||
notifications:
|
||||
slack:
|
||||
secure: QUWvCkBBK09GF7YtEvHHVt70JOkdlNBG0nIKu/5qc4/nW5HP8I2w0SEf/XR2je0eED1Qe3L/AfMCWwrEj+IUZc3l4v+ju8X8R3Lomhme0Eb0jd1MTMCuPcBT47YCj0M7RON7vXtbFfm1hFJ/jLe5+9FXz0hpXsR24PJc5ZIi/ogNwkaPqG4BmndzecpSh0vc2FJPZUD9LT0I09REY/vXR0oQAalLkW0asGD5taHZTUZq/kBpsNxaAFrLM23i4mUcf33M5fjLpvx5LRICrX/57XpBrDh2TooBU6Qj3CgoY0uPRYUmSNxbVx1czNzl2JtEpb5yjoxfVPQeg0BvQM00G8LJINISR+ohrjhkZmAqchDupAX+yFrxTtORa78CtnIL6z/aTNlgwwVD8kvL/1pFA/JWYmKDmz93mV/+6wubGzNSQCstzjkFA4/iZEKewKUoRIAi/fxyscP6L/rCpmY/4llZZvrnyTqVbt6URWpopUpH4rwYqreXAtJxJsfBJIeSmUIiDIOMGkCTvyTEW3fWGmGoqWtSHLoaWDyAIGb7azb+KvfpWtEcoPFWfSWU+LGee0A/YsUhBl7ADB9A0CJEuR8q4BPpKpfLwPKSiKSAXL7zDkyjExyhtgqbSl2jS+rKIHOZNL8JkCcTP2MKMVd563C5rC5FMKqu3S9m2b6380E=
|
||||
script:
|
||||
- go test -v -race -cover -coverprofile=coverage.txt -covermode=atomic ./...
|
||||
|
14
vendor/github.com/go-openapi/swag/README.md
generated
vendored
14
vendor/github.com/go-openapi/swag/README.md
generated
vendored
@@ -5,11 +5,19 @@
|
||||
[](https://golangci.com)
|
||||
[](https://goreportcard.com/report/github.com/go-openapi/swag)
|
||||
|
||||
Contains a bunch of helper functions:
|
||||
Contains a bunch of helper functions for go-openapi and go-swagger projects.
|
||||
|
||||
* convert between value and pointers for builtins
|
||||
* convert from string to builtin
|
||||
You may also use it standalone for your projects.
|
||||
|
||||
* convert between value and pointers for builtin types
|
||||
* convert from string to builtin types (wraps strconv)
|
||||
* fast json concatenation
|
||||
* search in path
|
||||
* load from file or http
|
||||
* name mangling
|
||||
|
||||
|
||||
This repo has only few dependencies outside of the standard library:
|
||||
|
||||
* JSON utilities depend on github.com/mailru/easyjson
|
||||
* YAML utilities depend on gopkg.in/yaml.v2
|
||||
|
47
vendor/github.com/go-openapi/swag/convert.go
generated
vendored
47
vendor/github.com/go-openapi/swag/convert.go
generated
vendored
@@ -22,8 +22,9 @@ import (
|
||||
|
||||
// same as ECMA Number.MAX_SAFE_INTEGER and Number.MIN_SAFE_INTEGER
|
||||
const (
|
||||
maxJSONFloat = float64(1<<53 - 1) // 9007199254740991.0 2^53 - 1
|
||||
minJSONFloat = -float64(1<<53 - 1) //-9007199254740991.0 -2^53 - 1
|
||||
maxJSONFloat = float64(1<<53 - 1) // 9007199254740991.0 2^53 - 1
|
||||
minJSONFloat = -float64(1<<53 - 1) //-9007199254740991.0 -2^53 - 1
|
||||
epsilon float64 = 1e-9
|
||||
)
|
||||
|
||||
// IsFloat64AJSONInteger allow for integers [-2^53, 2^53-1] inclusive
|
||||
@@ -31,21 +32,39 @@ func IsFloat64AJSONInteger(f float64) bool {
|
||||
if math.IsNaN(f) || math.IsInf(f, 0) || f < minJSONFloat || f > maxJSONFloat {
|
||||
return false
|
||||
}
|
||||
fa := math.Abs(f)
|
||||
g := float64(uint64(f))
|
||||
ga := math.Abs(g)
|
||||
|
||||
return f == float64(int64(f)) || f == float64(uint64(f))
|
||||
diff := math.Abs(f - g)
|
||||
|
||||
// more info: https://floating-point-gui.de/errors/comparison/#look-out-for-edge-cases
|
||||
if f == g { // best case
|
||||
return true
|
||||
} else if f == float64(int64(f)) || f == float64(uint64(f)) { // optimistic case
|
||||
return true
|
||||
} else if f == 0 || g == 0 || diff < math.SmallestNonzeroFloat64 { // very close to 0 values
|
||||
return diff < (epsilon * math.SmallestNonzeroFloat64)
|
||||
}
|
||||
// check the relative error
|
||||
return diff/math.Min(fa+ga, math.MaxFloat64) < epsilon
|
||||
}
|
||||
|
||||
var evaluatesAsTrue = map[string]struct{}{
|
||||
"true": {},
|
||||
"1": {},
|
||||
"yes": {},
|
||||
"ok": {},
|
||||
"y": {},
|
||||
"on": {},
|
||||
"selected": {},
|
||||
"checked": {},
|
||||
"t": {},
|
||||
"enabled": {},
|
||||
var evaluatesAsTrue map[string]struct{}
|
||||
|
||||
func init() {
|
||||
evaluatesAsTrue = map[string]struct{}{
|
||||
"true": {},
|
||||
"1": {},
|
||||
"yes": {},
|
||||
"ok": {},
|
||||
"y": {},
|
||||
"on": {},
|
||||
"selected": {},
|
||||
"checked": {},
|
||||
"t": {},
|
||||
"enabled": {},
|
||||
}
|
||||
}
|
||||
|
||||
// ConvertBool turn a string into a boolean
|
||||
|
1
vendor/github.com/go-openapi/swag/convert_test.go
generated
vendored
1
vendor/github.com/go-openapi/swag/convert_test.go
generated
vendored
@@ -207,6 +207,7 @@ func TestIsFloat64AJSONInteger(t *testing.T) {
|
||||
assert.True(t, IsFloat64AJSONInteger(1.0))
|
||||
assert.True(t, IsFloat64AJSONInteger(maxJSONFloat))
|
||||
assert.True(t, IsFloat64AJSONInteger(minJSONFloat))
|
||||
assert.True(t, IsFloat64AJSONInteger(1/0.01*67.15000001))
|
||||
}
|
||||
|
||||
func TestFormatBool(t *testing.T) {
|
||||
|
580
vendor/github.com/go-openapi/swag/convert_types_test.go
generated
vendored
580
vendor/github.com/go-openapi/swag/convert_types_test.go
generated
vendored
@@ -1,12 +1,70 @@
|
||||
package swag
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func assertSingleValue(t *testing.T, inElem, elem reflect.Value, expectPointer bool, idx int) {
|
||||
if !assert.Truef(t,
|
||||
(elem.Kind() == reflect.Ptr) == expectPointer,
|
||||
"Unexpected expectPointer=%t value type", expectPointer) {
|
||||
return
|
||||
}
|
||||
if inElem.Kind() == reflect.Ptr && !inElem.IsNil() {
|
||||
inElem = reflect.Indirect(inElem)
|
||||
}
|
||||
if elem.Kind() == reflect.Ptr && !elem.IsNil() {
|
||||
elem = reflect.Indirect(elem)
|
||||
}
|
||||
|
||||
if !assert.Truef(t,
|
||||
(elem.Kind() == reflect.Ptr && elem.IsNil()) || IsZero(elem.Interface()) ==
|
||||
(inElem.Kind() == reflect.Ptr && inElem.IsNil()) || IsZero(inElem.Interface()),
|
||||
"Unexpected nil pointer at idx %d", idx) {
|
||||
return
|
||||
}
|
||||
|
||||
if !((elem.Kind() == reflect.Ptr && elem.IsNil()) || IsZero(elem.Interface())) {
|
||||
if !assert.IsTypef(t, inElem.Interface(), elem.Interface(), "Expected in/out to match types") {
|
||||
return
|
||||
}
|
||||
assert.EqualValuesf(t, inElem.Interface(), elem.Interface(), "Unexpected value at idx %d: %v", idx, elem.Interface())
|
||||
}
|
||||
}
|
||||
|
||||
// assertValues checks equivalent representation pointer vs values for single var, slices and maps
|
||||
func assertValues(t *testing.T, in, out interface{}, expectPointer bool, idx int) {
|
||||
vin := reflect.ValueOf(in)
|
||||
vout := reflect.ValueOf(out)
|
||||
switch vin.Kind() {
|
||||
case reflect.Slice, reflect.Map:
|
||||
if !assert.Equalf(t, vin.Kind(), vout.Kind(), "Unexpected output type at idx %d", idx) ||
|
||||
!assert.Equalf(t, vin.Len(), vout.Len(), "Unexpected len at idx %d", idx) {
|
||||
break
|
||||
}
|
||||
var elem, inElem reflect.Value
|
||||
for i := 0; i < vin.Len(); i++ {
|
||||
if vin.Kind() == reflect.Slice {
|
||||
elem = vout.Index(i)
|
||||
inElem = vin.Index(i)
|
||||
} else if vin.Kind() == reflect.Map {
|
||||
keys := vin.MapKeys()
|
||||
elem = vout.MapIndex(keys[i])
|
||||
inElem = vout.MapIndex(keys[i])
|
||||
}
|
||||
assertSingleValue(t, inElem, elem, expectPointer, idx)
|
||||
}
|
||||
default:
|
||||
inElem := vin
|
||||
elem := vout
|
||||
assertSingleValue(t, inElem, elem, expectPointer, idx)
|
||||
}
|
||||
}
|
||||
|
||||
var testCasesStringSlice = [][]string{
|
||||
{"a", "b", "c", "d", "e"},
|
||||
{"a", "b", "", "", "e"},
|
||||
@@ -18,14 +76,10 @@ func TestStringSlice(t *testing.T) {
|
||||
continue
|
||||
}
|
||||
out := StringSlice(in)
|
||||
assert.Len(t, out, len(in), "Unexpected len at idx %d", idx)
|
||||
for i := range out {
|
||||
assert.Equal(t, in[i], *(out[i]), "Unexpected value at idx %d", idx)
|
||||
}
|
||||
assertValues(t, in, out, true, idx)
|
||||
|
||||
out2 := StringValueSlice(out)
|
||||
assert.Len(t, out2, len(in), "Unexpected len at idx %d", idx)
|
||||
assert.Equal(t, in, out2, "Unexpected value at idx %d", idx)
|
||||
assertValues(t, in, out2, false, idx)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,24 +93,10 @@ func TestStringValueSlice(t *testing.T) {
|
||||
continue
|
||||
}
|
||||
out := StringValueSlice(in)
|
||||
assert.Len(t, out, len(in), "Unexpected len at idx %d", idx)
|
||||
for i := range out {
|
||||
if in[i] == nil {
|
||||
assert.Empty(t, out[i], "Unexpected value at idx %d", idx)
|
||||
} else {
|
||||
assert.Equal(t, *(in[i]), out[i], "Unexpected value at idx %d", idx)
|
||||
}
|
||||
}
|
||||
assertValues(t, in, out, false, idx)
|
||||
|
||||
out2 := StringSlice(out)
|
||||
assert.Len(t, out2, len(in), "Unexpected len at idx %d", idx)
|
||||
for i := range out2 {
|
||||
if in[i] == nil {
|
||||
assert.Empty(t, *(out2[i]), "Unexpected value at idx %d", idx)
|
||||
} else {
|
||||
assert.Equal(t, in[i], out2[i], "Unexpected value at idx %d", idx)
|
||||
}
|
||||
}
|
||||
assertValues(t, in, out2, true, idx)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,14 +110,10 @@ func TestStringMap(t *testing.T) {
|
||||
continue
|
||||
}
|
||||
out := StringMap(in)
|
||||
assert.Len(t, out, len(in), "Unexpected len at idx %d", idx)
|
||||
for i := range out {
|
||||
assert.Equal(t, in[i], *(out[i]), "Unexpected value at idx %d", idx)
|
||||
}
|
||||
assertValues(t, in, out, true, idx)
|
||||
|
||||
out2 := StringValueMap(out)
|
||||
assert.Len(t, out2, len(in), "Unexpected len at idx %d", idx)
|
||||
assert.Equal(t, in, out2, "Unexpected value at idx %d", idx)
|
||||
assertValues(t, in, out2, false, idx)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -91,18 +127,16 @@ func TestBoolSlice(t *testing.T) {
|
||||
continue
|
||||
}
|
||||
out := BoolSlice(in)
|
||||
assert.Len(t, out, len(in), "Unexpected len at idx %d", idx)
|
||||
for i := range out {
|
||||
assert.Equal(t, in[i], *(out[i]), "Unexpected value at idx %d", idx)
|
||||
}
|
||||
assertValues(t, in, out, true, idx)
|
||||
|
||||
out2 := BoolValueSlice(out)
|
||||
assert.Len(t, out2, len(in), "Unexpected len at idx %d", idx)
|
||||
assert.Equal(t, in, out2, "Unexpected value at idx %d", idx)
|
||||
assertValues(t, in, out2, false, idx)
|
||||
}
|
||||
}
|
||||
|
||||
var testCasesBoolValueSlice = [][]*bool{}
|
||||
var testCasesBoolValueSlice = [][]*bool{
|
||||
{Bool(true), Bool(true), Bool(false), Bool(false)},
|
||||
}
|
||||
|
||||
func TestBoolValueSlice(t *testing.T) {
|
||||
for idx, in := range testCasesBoolValueSlice {
|
||||
@@ -110,24 +144,10 @@ func TestBoolValueSlice(t *testing.T) {
|
||||
continue
|
||||
}
|
||||
out := BoolValueSlice(in)
|
||||
assert.Len(t, out, len(in), "Unexpected len at idx %d", idx)
|
||||
for i := range out {
|
||||
if in[i] == nil {
|
||||
assert.Empty(t, out[i], "Unexpected value at idx %d", idx)
|
||||
} else {
|
||||
assert.Equal(t, *(in[i]), out[i], "Unexpected value at idx %d", idx)
|
||||
}
|
||||
}
|
||||
assertValues(t, in, out, false, idx)
|
||||
|
||||
out2 := BoolSlice(out)
|
||||
assert.Len(t, out2, len(in), "Unexpected len at idx %d", idx)
|
||||
for i := range out2 {
|
||||
if in[i] == nil {
|
||||
assert.Empty(t, *(out2[i]), "Unexpected value at idx %d", idx)
|
||||
} else {
|
||||
assert.Equal(t, in[i], out2[i], "Unexpected value at idx %d", idx)
|
||||
}
|
||||
}
|
||||
assertValues(t, in, out2, true, idx)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -141,14 +161,10 @@ func TestBoolMap(t *testing.T) {
|
||||
continue
|
||||
}
|
||||
out := BoolMap(in)
|
||||
assert.Len(t, out, len(in), "Unexpected len at idx %d", idx)
|
||||
for i := range out {
|
||||
assert.Equal(t, in[i], *(out[i]), "Unexpected value at idx %d", idx)
|
||||
}
|
||||
assertValues(t, in, out, true, idx)
|
||||
|
||||
out2 := BoolValueMap(out)
|
||||
assert.Len(t, out2, len(in), "Unexpected len at idx %d", idx)
|
||||
assert.Equal(t, in, out2, "Unexpected value at idx %d", idx)
|
||||
assertValues(t, in, out2, false, idx)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -162,18 +178,16 @@ func TestIntSlice(t *testing.T) {
|
||||
continue
|
||||
}
|
||||
out := IntSlice(in)
|
||||
assert.Len(t, out, len(in), "Unexpected len at idx %d", idx)
|
||||
for i := range out {
|
||||
assert.Equal(t, in[i], *(out[i]), "Unexpected value at idx %d", idx)
|
||||
}
|
||||
assertValues(t, in, out, true, idx)
|
||||
|
||||
out2 := IntValueSlice(out)
|
||||
assert.Len(t, out2, len(in), "Unexpected len at idx %d", idx)
|
||||
assert.Equal(t, in, out2, "Unexpected value at idx %d", idx)
|
||||
assertValues(t, in, out2, false, idx)
|
||||
}
|
||||
}
|
||||
|
||||
var testCasesIntValueSlice = [][]*int{}
|
||||
var testCasesIntValueSlice = [][]*int{
|
||||
{Int(1), Int(2), Int(3), Int(4)},
|
||||
}
|
||||
|
||||
func TestIntValueSlice(t *testing.T) {
|
||||
for idx, in := range testCasesIntValueSlice {
|
||||
@@ -181,24 +195,10 @@ func TestIntValueSlice(t *testing.T) {
|
||||
continue
|
||||
}
|
||||
out := IntValueSlice(in)
|
||||
assert.Len(t, out, len(in), "Unexpected len at idx %d", idx)
|
||||
for i := range out {
|
||||
if in[i] == nil {
|
||||
assert.Empty(t, out[i], "Unexpected value at idx %d", idx)
|
||||
} else {
|
||||
assert.Equal(t, *(in[i]), out[i], "Unexpected value at idx %d", idx)
|
||||
}
|
||||
}
|
||||
assertValues(t, in, out, false, idx)
|
||||
|
||||
out2 := IntSlice(out)
|
||||
assert.Len(t, out2, len(in), "Unexpected len at idx %d", idx)
|
||||
for i := range out2 {
|
||||
if in[i] == nil {
|
||||
assert.Empty(t, *(out2[i]), "Unexpected value at idx %d", idx)
|
||||
} else {
|
||||
assert.Equal(t, in[i], out2[i], "Unexpected value at idx %d", idx)
|
||||
}
|
||||
}
|
||||
assertValues(t, in, out2, true, idx)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -212,14 +212,10 @@ func TestIntMap(t *testing.T) {
|
||||
continue
|
||||
}
|
||||
out := IntMap(in)
|
||||
assert.Len(t, out, len(in), "Unexpected len at idx %d", idx)
|
||||
for i := range out {
|
||||
assert.Equal(t, in[i], *(out[i]), "Unexpected value at idx %d", idx)
|
||||
}
|
||||
assertValues(t, in, out, true, idx)
|
||||
|
||||
out2 := IntValueMap(out)
|
||||
assert.Len(t, out2, len(in), "Unexpected len at idx %d", idx)
|
||||
assert.Equal(t, in, out2, "Unexpected value at idx %d", idx)
|
||||
assertValues(t, in, out2, false, idx)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -233,18 +229,16 @@ func TestInt64Slice(t *testing.T) {
|
||||
continue
|
||||
}
|
||||
out := Int64Slice(in)
|
||||
assert.Len(t, out, len(in), "Unexpected len at idx %d", idx)
|
||||
for i := range out {
|
||||
assert.Equal(t, in[i], *(out[i]), "Unexpected value at idx %d", idx)
|
||||
}
|
||||
assertValues(t, in, out, true, idx)
|
||||
|
||||
out2 := Int64ValueSlice(out)
|
||||
assert.Len(t, out2, len(in), "Unexpected len at idx %d", idx)
|
||||
assert.Equal(t, in, out2, "Unexpected value at idx %d", idx)
|
||||
assertValues(t, in, out2, false, idx)
|
||||
}
|
||||
}
|
||||
|
||||
var testCasesInt64ValueSlice = [][]*int64{}
|
||||
var testCasesInt64ValueSlice = [][]*int64{
|
||||
{Int64(1), Int64(2), Int64(3), Int64(4)},
|
||||
}
|
||||
|
||||
func TestInt64ValueSlice(t *testing.T) {
|
||||
for idx, in := range testCasesInt64ValueSlice {
|
||||
@@ -252,24 +246,10 @@ func TestInt64ValueSlice(t *testing.T) {
|
||||
continue
|
||||
}
|
||||
out := Int64ValueSlice(in)
|
||||
assert.Len(t, out, len(in), "Unexpected len at idx %d", idx)
|
||||
for i := range out {
|
||||
if in[i] == nil {
|
||||
assert.Empty(t, out[i], "Unexpected value at idx %d", idx)
|
||||
} else {
|
||||
assert.Equal(t, *(in[i]), out[i], "Unexpected value at idx %d", idx)
|
||||
}
|
||||
}
|
||||
assertValues(t, in, out, false, idx)
|
||||
|
||||
out2 := Int64Slice(out)
|
||||
assert.Len(t, out2, len(in), "Unexpected len at idx %d", idx)
|
||||
for i := range out2 {
|
||||
if in[i] == nil {
|
||||
assert.Empty(t, *(out2[i]), "Unexpected value at idx %d", idx)
|
||||
} else {
|
||||
assert.Equal(t, in[i], out2[i], "Unexpected value at idx %d", idx)
|
||||
}
|
||||
}
|
||||
assertValues(t, in, out2, true, idx)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -283,14 +263,10 @@ func TestInt64Map(t *testing.T) {
|
||||
continue
|
||||
}
|
||||
out := Int64Map(in)
|
||||
assert.Len(t, out, len(in), "Unexpected len at idx %d", idx)
|
||||
for i := range out {
|
||||
assert.Equal(t, in[i], *(out[i]), "Unexpected value at idx %d", idx)
|
||||
}
|
||||
assertValues(t, in, out, true, idx)
|
||||
|
||||
out2 := Int64ValueMap(out)
|
||||
assert.Len(t, out2, len(in), "Unexpected len at idx %d", idx)
|
||||
assert.Equal(t, in, out2, "Unexpected value at idx %d", idx)
|
||||
assertValues(t, in, out2, false, idx)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -304,14 +280,10 @@ func TestFloat64Slice(t *testing.T) {
|
||||
continue
|
||||
}
|
||||
out := Float64Slice(in)
|
||||
assert.Len(t, out, len(in), "Unexpected len at idx %d", idx)
|
||||
for i := range out {
|
||||
assert.Equal(t, in[i], *(out[i]), "Unexpected value at idx %d", idx)
|
||||
}
|
||||
assertValues(t, in, out, true, idx)
|
||||
|
||||
out2 := Float64ValueSlice(out)
|
||||
assert.Len(t, out2, len(in), "Unexpected len at idx %d", idx)
|
||||
assert.Equal(t, in, out2, "Unexpected value at idx %d", idx)
|
||||
assertValues(t, in, out2, false, idx)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -325,14 +297,10 @@ func TestUintSlice(t *testing.T) {
|
||||
continue
|
||||
}
|
||||
out := UintSlice(in)
|
||||
assert.Len(t, out, len(in), "Unexpected len at idx %d", idx)
|
||||
for i := range out {
|
||||
assert.Equal(t, in[i], *(out[i]), "Unexpected value at idx %d", idx)
|
||||
}
|
||||
assertValues(t, in, out, true, idx)
|
||||
|
||||
out2 := UintValueSlice(out)
|
||||
assert.Len(t, out2, len(in), "Unexpected len at idx %d", idx)
|
||||
assert.Equal(t, in, out2, "Unexpected value at idx %d", idx)
|
||||
assertValues(t, in, out2, false, idx)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -344,24 +312,10 @@ func TestUintValueSlice(t *testing.T) {
|
||||
continue
|
||||
}
|
||||
out := UintValueSlice(in)
|
||||
assert.Len(t, out, len(in), "Unexpected len at idx %d", idx)
|
||||
for i := range out {
|
||||
if in[i] == nil {
|
||||
assert.Empty(t, out[i], "Unexpected value at idx %d", idx)
|
||||
} else {
|
||||
assert.Equal(t, *(in[i]), out[i], "Unexpected value at idx %d", idx)
|
||||
}
|
||||
}
|
||||
assertValues(t, in, out, true, idx)
|
||||
|
||||
out2 := UintSlice(out)
|
||||
assert.Len(t, out2, len(in), "Unexpected len at idx %d", idx)
|
||||
for i := range out2 {
|
||||
if in[i] == nil {
|
||||
assert.Empty(t, *(out2[i]), "Unexpected value at idx %d", idx)
|
||||
} else {
|
||||
assert.Equal(t, in[i], out2[i], "Unexpected value at idx %d", idx)
|
||||
}
|
||||
}
|
||||
assertValues(t, in, out2, false, idx)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -375,14 +329,10 @@ func TestUintMap(t *testing.T) {
|
||||
continue
|
||||
}
|
||||
out := UintMap(in)
|
||||
assert.Len(t, out, len(in), "Unexpected len at idx %d", idx)
|
||||
for i := range out {
|
||||
assert.Equal(t, in[i], *(out[i]), "Unexpected value at idx %d", idx)
|
||||
}
|
||||
assertValues(t, in, out, true, idx)
|
||||
|
||||
out2 := UintValueMap(out)
|
||||
assert.Len(t, out2, len(in), "Unexpected len at idx %d", idx)
|
||||
assert.Equal(t, in, out2, "Unexpected value at idx %d", idx)
|
||||
assertValues(t, in, out2, false, idx)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -396,14 +346,10 @@ func TestUint64Slice(t *testing.T) {
|
||||
continue
|
||||
}
|
||||
out := Uint64Slice(in)
|
||||
assert.Len(t, out, len(in), "Unexpected len at idx %d", idx)
|
||||
for i := range out {
|
||||
assert.Equal(t, in[i], *(out[i]), "Unexpected value at idx %d", idx)
|
||||
}
|
||||
assertValues(t, in, out, true, idx)
|
||||
|
||||
out2 := Uint64ValueSlice(out)
|
||||
assert.Len(t, out2, len(in), "Unexpected len at idx %d", idx)
|
||||
assert.Equal(t, in, out2, "Unexpected value at idx %d", idx)
|
||||
assertValues(t, in, out2, false, idx)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -415,24 +361,10 @@ func TestUint64ValueSlice(t *testing.T) {
|
||||
continue
|
||||
}
|
||||
out := Uint64ValueSlice(in)
|
||||
assert.Len(t, out, len(in), "Unexpected len at idx %d", idx)
|
||||
for i := range out {
|
||||
if in[i] == nil {
|
||||
assert.Empty(t, out[i], "Unexpected value at idx %d", idx)
|
||||
} else {
|
||||
assert.Equal(t, *(in[i]), out[i], "Unexpected value at idx %d", idx)
|
||||
}
|
||||
}
|
||||
assertValues(t, in, out, true, idx)
|
||||
|
||||
out2 := Uint64Slice(out)
|
||||
assert.Len(t, out2, len(in), "Unexpected len at idx %d", idx)
|
||||
for i := range out2 {
|
||||
if in[i] == nil {
|
||||
assert.Empty(t, *(out2[i]), "Unexpected value at idx %d", idx)
|
||||
} else {
|
||||
assert.Equal(t, in[i], out2[i], "Unexpected value at idx %d", idx)
|
||||
}
|
||||
}
|
||||
assertValues(t, in, out2, false, idx)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -446,14 +378,10 @@ func TestUint64Map(t *testing.T) {
|
||||
continue
|
||||
}
|
||||
out := Uint64Map(in)
|
||||
assert.Len(t, out, len(in), "Unexpected len at idx %d", idx)
|
||||
for i := range out {
|
||||
assert.Equal(t, in[i], *(out[i]), "Unexpected value at idx %d", idx)
|
||||
}
|
||||
assertValues(t, in, out, true, idx)
|
||||
|
||||
out2 := Uint64ValueMap(out)
|
||||
assert.Len(t, out2, len(in), "Unexpected len at idx %d", idx)
|
||||
assert.Equal(t, in, out2, "Unexpected value at idx %d", idx)
|
||||
assertValues(t, in, out2, false, idx)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -465,24 +393,10 @@ func TestFloat64ValueSlice(t *testing.T) {
|
||||
continue
|
||||
}
|
||||
out := Float64ValueSlice(in)
|
||||
assert.Len(t, out, len(in), "Unexpected len at idx %d", idx)
|
||||
for i := range out {
|
||||
if in[i] == nil {
|
||||
assert.Empty(t, out[i], "Unexpected value at idx %d", idx)
|
||||
} else {
|
||||
assert.Equal(t, *(in[i]), out[i], "Unexpected value at idx %d", idx)
|
||||
}
|
||||
}
|
||||
assertValues(t, in, out, true, idx)
|
||||
|
||||
out2 := Float64Slice(out)
|
||||
assert.Len(t, out2, len(in), "Unexpected len at idx %d", idx)
|
||||
for i := range out2 {
|
||||
if in[i] == nil {
|
||||
assert.Empty(t, *(out2[i]), "Unexpected value at idx %d", idx)
|
||||
} else {
|
||||
assert.Equal(t, in[i], out2[i], "Unexpected value at idx %d", idx)
|
||||
}
|
||||
}
|
||||
assertValues(t, in, out2, false, idx)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -496,14 +410,10 @@ func TestFloat64Map(t *testing.T) {
|
||||
continue
|
||||
}
|
||||
out := Float64Map(in)
|
||||
assert.Len(t, out, len(in), "Unexpected len at idx %d", idx)
|
||||
for i := range out {
|
||||
assert.Equal(t, in[i], *(out[i]), "Unexpected value at idx %d", idx)
|
||||
}
|
||||
assertValues(t, in, out, true, idx)
|
||||
|
||||
out2 := Float64ValueMap(out)
|
||||
assert.Len(t, out2, len(in), "Unexpected len at idx %d", idx)
|
||||
assert.Equal(t, in, out2, "Unexpected value at idx %d", idx)
|
||||
assertValues(t, in, out2, false, idx)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -517,18 +427,16 @@ func TestTimeSlice(t *testing.T) {
|
||||
continue
|
||||
}
|
||||
out := TimeSlice(in)
|
||||
assert.Len(t, out, len(in), "Unexpected len at idx %d", idx)
|
||||
for i := range out {
|
||||
assert.Equal(t, in[i], *(out[i]), "Unexpected value at idx %d", idx)
|
||||
}
|
||||
assertValues(t, in, out, true, idx)
|
||||
|
||||
out2 := TimeValueSlice(out)
|
||||
assert.Len(t, out2, len(in), "Unexpected len at idx %d", idx)
|
||||
assert.Equal(t, in, out2, "Unexpected value at idx %d", idx)
|
||||
assertValues(t, in, out2, false, idx)
|
||||
}
|
||||
}
|
||||
|
||||
var testCasesTimeValueSlice = [][]*time.Time{}
|
||||
var testCasesTimeValueSlice = [][]*time.Time{
|
||||
{Time(time.Now()), Time(time.Now().AddDate(100, 0, 0))},
|
||||
}
|
||||
|
||||
func TestTimeValueSlice(t *testing.T) {
|
||||
for idx, in := range testCasesTimeValueSlice {
|
||||
@@ -536,24 +444,10 @@ func TestTimeValueSlice(t *testing.T) {
|
||||
continue
|
||||
}
|
||||
out := TimeValueSlice(in)
|
||||
assert.Len(t, out, len(in), "Unexpected len at idx %d", idx)
|
||||
for i := range out {
|
||||
if in[i] == nil {
|
||||
assert.Empty(t, out[i], "Unexpected value at idx %d", idx)
|
||||
} else {
|
||||
assert.Equal(t, *(in[i]), out[i], "Unexpected value at idx %d", idx)
|
||||
}
|
||||
}
|
||||
assertValues(t, in, out, false, idx)
|
||||
|
||||
out2 := TimeSlice(out)
|
||||
assert.Len(t, out2, len(in), "Unexpected len at idx %d", idx)
|
||||
for i := range out2 {
|
||||
if in[i] == nil {
|
||||
assert.Empty(t, *(out2[i]), "Unexpected value at idx %d", idx)
|
||||
} else {
|
||||
assert.Equal(t, in[i], out2[i], "Unexpected value at idx %d", idx)
|
||||
}
|
||||
}
|
||||
assertValues(t, in, out2, true, idx)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -567,13 +461,243 @@ func TestTimeMap(t *testing.T) {
|
||||
continue
|
||||
}
|
||||
out := TimeMap(in)
|
||||
assert.Len(t, out, len(in), "Unexpected len at idx %d", idx)
|
||||
for i := range out {
|
||||
assert.Equal(t, in[i], *(out[i]), "Unexpected value at idx %d", idx)
|
||||
}
|
||||
assertValues(t, in, out, true, idx)
|
||||
|
||||
out2 := TimeValueMap(out)
|
||||
assert.Len(t, out2, len(in), "Unexpected len at idx %d", idx)
|
||||
assert.Equal(t, in, out2, "Unexpected value at idx %d", idx)
|
||||
assertValues(t, in, out2, false, idx)
|
||||
}
|
||||
}
|
||||
|
||||
var testCasesInt32Slice = [][]int32{
|
||||
{1, 2, 3, 4},
|
||||
}
|
||||
|
||||
func TestInt32Slice(t *testing.T) {
|
||||
for idx, in := range testCasesInt32Slice {
|
||||
if in == nil {
|
||||
continue
|
||||
}
|
||||
out := Int32Slice(in)
|
||||
assertValues(t, in, out, true, idx)
|
||||
|
||||
out2 := Int32ValueSlice(out)
|
||||
assertValues(t, in, out2, false, idx)
|
||||
}
|
||||
}
|
||||
|
||||
var testCasesInt32ValueSlice = [][]*int32{
|
||||
{Int32(1), Int32(2), Int32(3), Int32(4)},
|
||||
}
|
||||
|
||||
func TestInt32ValueSlice(t *testing.T) {
|
||||
for idx, in := range testCasesInt32ValueSlice {
|
||||
if in == nil {
|
||||
continue
|
||||
}
|
||||
out := Int32ValueSlice(in)
|
||||
assertValues(t, in, out, false, idx)
|
||||
|
||||
out2 := Int32Slice(out)
|
||||
assertValues(t, in, out2, true, idx)
|
||||
}
|
||||
}
|
||||
|
||||
var testCasesInt32Map = []map[string]int32{
|
||||
{"a": 3, "b": 2, "c": 1},
|
||||
}
|
||||
|
||||
func TestInt32Map(t *testing.T) {
|
||||
for idx, in := range testCasesInt32Map {
|
||||
if in == nil {
|
||||
continue
|
||||
}
|
||||
out := Int32Map(in)
|
||||
assertValues(t, in, out, true, idx)
|
||||
|
||||
out2 := Int32ValueMap(out)
|
||||
assertValues(t, in, out2, false, idx)
|
||||
}
|
||||
}
|
||||
|
||||
var testCasesUint32Slice = [][]uint32{
|
||||
{1, 2, 3, 4},
|
||||
}
|
||||
|
||||
func TestUint32Slice(t *testing.T) {
|
||||
for idx, in := range testCasesUint32Slice {
|
||||
if in == nil {
|
||||
continue
|
||||
}
|
||||
out := Uint32Slice(in)
|
||||
assertValues(t, in, out, true, idx)
|
||||
|
||||
out2 := Uint32ValueSlice(out)
|
||||
assertValues(t, in, out2, false, idx)
|
||||
}
|
||||
}
|
||||
|
||||
var testCasesUint32ValueSlice = [][]*uint32{
|
||||
{Uint32(1), Uint32(2), Uint32(3), Uint32(4)},
|
||||
}
|
||||
|
||||
func TestUint32ValueSlice(t *testing.T) {
|
||||
for idx, in := range testCasesUint32ValueSlice {
|
||||
if in == nil {
|
||||
continue
|
||||
}
|
||||
out := Uint32ValueSlice(in)
|
||||
assertValues(t, in, out, false, idx)
|
||||
|
||||
out2 := Uint32Slice(out)
|
||||
assertValues(t, in, out2, true, idx)
|
||||
}
|
||||
}
|
||||
|
||||
var testCasesUint32Map = []map[string]uint32{
|
||||
{"a": 3, "b": 2, "c": 1},
|
||||
}
|
||||
|
||||
func TestUint32Map(t *testing.T) {
|
||||
for idx, in := range testCasesUint32Map {
|
||||
if in == nil {
|
||||
continue
|
||||
}
|
||||
out := Uint32Map(in)
|
||||
assertValues(t, in, out, true, idx)
|
||||
|
||||
out2 := Uint32ValueMap(out)
|
||||
assertValues(t, in, out2, false, idx)
|
||||
}
|
||||
}
|
||||
|
||||
var testCasesString = []string{"a", "b", "c", "d", "e", ""}
|
||||
|
||||
func TestStringValue(t *testing.T) {
|
||||
for idx, in := range testCasesString {
|
||||
out := String(in)
|
||||
assertValues(t, in, out, true, idx)
|
||||
|
||||
out2 := StringValue(out)
|
||||
assertValues(t, in, out2, false, idx)
|
||||
}
|
||||
assert.Zerof(t, StringValue(nil), "expected conversion from nil to return zero value")
|
||||
}
|
||||
|
||||
var testCasesBool = []bool{true, false}
|
||||
|
||||
func TestBoolValue(t *testing.T) {
|
||||
for idx, in := range testCasesBool {
|
||||
out := Bool(in)
|
||||
assertValues(t, in, out, true, idx)
|
||||
|
||||
out2 := BoolValue(out)
|
||||
assertValues(t, in, out2, false, idx)
|
||||
}
|
||||
assert.Zerof(t, BoolValue(nil), "expected conversion from nil to return zero value")
|
||||
}
|
||||
|
||||
var testCasesInt = []int{1, 2, 3, 0}
|
||||
|
||||
func TestIntValue(t *testing.T) {
|
||||
for idx, in := range testCasesInt {
|
||||
out := Int(in)
|
||||
assertValues(t, in, out, true, idx)
|
||||
|
||||
out2 := IntValue(out)
|
||||
assertValues(t, in, out2, false, idx)
|
||||
}
|
||||
assert.Zerof(t, IntValue(nil), "expected conversion from nil to return zero value")
|
||||
}
|
||||
|
||||
var testCasesInt32 = []int32{1, 2, 3, 0}
|
||||
|
||||
func TestInt32Value(t *testing.T) {
|
||||
for idx, in := range testCasesInt32 {
|
||||
out := Int32(in)
|
||||
assertValues(t, in, out, true, idx)
|
||||
|
||||
out2 := Int32Value(out)
|
||||
assertValues(t, in, out2, false, idx)
|
||||
}
|
||||
assert.Zerof(t, Int32Value(nil), "expected conversion from nil to return zero value")
|
||||
}
|
||||
|
||||
var testCasesInt64 = []int64{1, 2, 3, 0}
|
||||
|
||||
func TestInt64Value(t *testing.T) {
|
||||
for idx, in := range testCasesInt64 {
|
||||
out := Int64(in)
|
||||
assertValues(t, in, out, true, idx)
|
||||
|
||||
out2 := Int64Value(out)
|
||||
assertValues(t, in, out2, false, idx)
|
||||
}
|
||||
assert.Zerof(t, Int64Value(nil), "expected conversion from nil to return zero value")
|
||||
}
|
||||
|
||||
var testCasesUint = []uint{1, 2, 3, 0}
|
||||
|
||||
func TestUintValue(t *testing.T) {
|
||||
for idx, in := range testCasesUint {
|
||||
out := Uint(in)
|
||||
assertValues(t, in, out, true, idx)
|
||||
|
||||
out2 := UintValue(out)
|
||||
assertValues(t, in, out2, false, idx)
|
||||
}
|
||||
assert.Zerof(t, UintValue(nil), "expected conversion from nil to return zero value")
|
||||
}
|
||||
|
||||
var testCasesUint32 = []uint32{1, 2, 3, 0}
|
||||
|
||||
func TestUint32Value(t *testing.T) {
|
||||
for idx, in := range testCasesUint32 {
|
||||
out := Uint32(in)
|
||||
assertValues(t, in, out, true, idx)
|
||||
|
||||
out2 := Uint32Value(out)
|
||||
assertValues(t, in, out2, false, idx)
|
||||
}
|
||||
assert.Zerof(t, Uint32Value(nil), "expected conversion from nil to return zero value")
|
||||
}
|
||||
|
||||
var testCasesUint64 = []uint64{1, 2, 3, 0}
|
||||
|
||||
func TestUint64Value(t *testing.T) {
|
||||
for idx, in := range testCasesUint64 {
|
||||
out := Uint64(in)
|
||||
assertValues(t, in, out, true, idx)
|
||||
|
||||
out2 := Uint64Value(out)
|
||||
assertValues(t, in, out2, false, idx)
|
||||
}
|
||||
assert.Zerof(t, Uint64Value(nil), "expected conversion from nil to return zero value")
|
||||
}
|
||||
|
||||
var testCasesFloat64 = []float64{1, 2, 3, 0}
|
||||
|
||||
func TestFloat64Value(t *testing.T) {
|
||||
for idx, in := range testCasesFloat64 {
|
||||
out := Float64(in)
|
||||
assertValues(t, in, out, true, idx)
|
||||
|
||||
out2 := Float64Value(out)
|
||||
assertValues(t, in, out2, false, idx)
|
||||
}
|
||||
assert.Zerof(t, Float64Value(nil), "expected conversion from nil to return zero value")
|
||||
}
|
||||
|
||||
var testCasesTime = []time.Time{
|
||||
time.Now().AddDate(-100, 0, 0), time.Now(),
|
||||
}
|
||||
|
||||
func TestTimeValue(t *testing.T) {
|
||||
for idx, in := range testCasesTime {
|
||||
out := Time(in)
|
||||
assertValues(t, in, out, true, idx)
|
||||
|
||||
out2 := TimeValue(out)
|
||||
assertValues(t, in, out2, false, idx)
|
||||
}
|
||||
assert.Zerof(t, TimeValue(nil), "expected conversion from nil to return zero value")
|
||||
}
|
||||
|
33
vendor/github.com/go-openapi/swag/doc.go
generated
vendored
Normal file
33
vendor/github.com/go-openapi/swag/doc.go
generated
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
// Copyright 2015 go-swagger maintainers
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
/*
|
||||
Package swag contains a bunch of helper functions for go-openapi and go-swagger projects.
|
||||
|
||||
You may also use it standalone for your projects.
|
||||
|
||||
* convert between value and pointers for builtin types
|
||||
* convert from string to builtin types (wraps strconv)
|
||||
* fast json concatenation
|
||||
* search in path
|
||||
* load from file or http
|
||||
* name mangling
|
||||
|
||||
|
||||
This repo has only few dependencies outside of the standard library:
|
||||
|
||||
* JSON utilities depend on github.com/mailru/easyjson
|
||||
* YAML utilities depend on gopkg.in/yaml.v2
|
||||
*/
|
||||
package swag
|
9
vendor/github.com/go-openapi/swag/go.mod
generated
vendored
Normal file
9
vendor/github.com/go-openapi/swag/go.mod
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
module github.com/go-openapi/swag
|
||||
|
||||
require (
|
||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||
github.com/mailru/easyjson v0.0.0-20180823135443-60711f1a8329
|
||||
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||
github.com/stretchr/testify v1.2.2
|
||||
gopkg.in/yaml.v2 v2.2.1
|
||||
)
|
9
vendor/github.com/go-openapi/swag/go.sum
generated
vendored
Normal file
9
vendor/github.com/go-openapi/swag/go.sum
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/mailru/easyjson v0.0.0-20180823135443-60711f1a8329 h1:2gxZ0XQIU/5z3Z3bUBu+FXuk2pFbkN6tcwi/pjyaDic=
|
||||
github.com/mailru/easyjson v0.0.0-20180823135443-60711f1a8329/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w=
|
||||
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
15
vendor/github.com/go-openapi/swag/json.go
generated
vendored
15
vendor/github.com/go-openapi/swag/json.go
generated
vendored
@@ -21,7 +21,6 @@ import (
|
||||
"reflect"
|
||||
"strings"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
|
||||
"github.com/mailru/easyjson/jlexer"
|
||||
"github.com/mailru/easyjson/jwriter"
|
||||
@@ -35,14 +34,13 @@ var DefaultJSONNameProvider = NewNameProvider()
|
||||
|
||||
const comma = byte(',')
|
||||
|
||||
var atomicClosers atomic.Value
|
||||
var closers map[byte]byte
|
||||
|
||||
func init() {
|
||||
atomicClosers.Store(
|
||||
map[byte]byte{
|
||||
'{': '}',
|
||||
'[': ']',
|
||||
})
|
||||
closers = map[byte]byte{
|
||||
'{': '}',
|
||||
'[': ']',
|
||||
}
|
||||
}
|
||||
|
||||
type ejMarshaler interface {
|
||||
@@ -113,7 +111,6 @@ func ConcatJSON(blobs ...[]byte) []byte {
|
||||
var opening, closing byte
|
||||
var idx, a int
|
||||
buf := bytes.NewBuffer(nil)
|
||||
closers := atomicClosers.Load().(map[byte]byte)
|
||||
|
||||
for i, b := range blobs[:last+1] {
|
||||
if b == nil || bytes.Equal(b, nullJSON) {
|
||||
@@ -264,7 +261,7 @@ func (n *NameProvider) GetJSONNames(subject interface{}) []string {
|
||||
names = n.makeNameIndex(tpe)
|
||||
}
|
||||
|
||||
var res []string
|
||||
res := make([]string, 0, len(names.jsonNames))
|
||||
for k := range names.jsonNames {
|
||||
res = append(res, k)
|
||||
}
|
||||
|
2
vendor/github.com/go-openapi/swag/loading_test.go
generated
vendored
2
vendor/github.com/go-openapi/swag/loading_test.go
generated
vendored
@@ -37,7 +37,7 @@ func TestLoadFromHTTP(t *testing.T) {
|
||||
|
||||
ts2 := httptest.NewServer(http.HandlerFunc(func(rw http.ResponseWriter, r *http.Request) {
|
||||
rw.WriteHeader(http.StatusOK)
|
||||
rw.Write([]byte("the content"))
|
||||
_, _ = rw.Write([]byte("the content"))
|
||||
}))
|
||||
defer ts2.Close()
|
||||
|
||||
|
4
vendor/github.com/go-openapi/swag/path_test.go
generated
vendored
4
vendor/github.com/go-openapi/swag/path_test.go
generated
vendored
@@ -25,7 +25,7 @@ import (
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func makeDirStructure(t *testing.T, tgt string) (string, string, error) {
|
||||
func makeDirStructure(tgt string) (string, string, error) {
|
||||
if tgt == "" {
|
||||
tgt = "pkgpaths"
|
||||
}
|
||||
@@ -66,7 +66,7 @@ func makeDirStructure(t *testing.T, tgt string) (string, string, error) {
|
||||
}
|
||||
|
||||
func TestFindPackage(t *testing.T) {
|
||||
pth, pth2, err := makeDirStructure(t, "")
|
||||
pth, pth2, err := makeDirStructure("")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
79
vendor/github.com/go-openapi/swag/util.go
generated
vendored
79
vendor/github.com/go-openapi/swag/util.go
generated
vendored
@@ -88,7 +88,15 @@ func ensureSorted() {
|
||||
initialisms = commonInitialisms.sorted()
|
||||
}
|
||||
|
||||
// JoinByFormat joins a string array by a known format:
|
||||
const (
|
||||
//collectionFormatComma = "csv"
|
||||
collectionFormatSpace = "ssv"
|
||||
collectionFormatTab = "tsv"
|
||||
collectionFormatPipe = "pipes"
|
||||
collectionFormatMulti = "multi"
|
||||
)
|
||||
|
||||
// JoinByFormat joins a string array by a known format (e.g. swagger's collectionFormat attribute):
|
||||
// ssv: space separated value
|
||||
// tsv: tab separated value
|
||||
// pipes: pipe (|) separated value
|
||||
@@ -99,13 +107,13 @@ func JoinByFormat(data []string, format string) []string {
|
||||
}
|
||||
var sep string
|
||||
switch format {
|
||||
case "ssv":
|
||||
case collectionFormatSpace:
|
||||
sep = " "
|
||||
case "tsv":
|
||||
case collectionFormatTab:
|
||||
sep = "\t"
|
||||
case "pipes":
|
||||
case collectionFormatPipe:
|
||||
sep = "|"
|
||||
case "multi":
|
||||
case collectionFormatMulti:
|
||||
return data
|
||||
default:
|
||||
sep = ","
|
||||
@@ -118,19 +126,20 @@ func JoinByFormat(data []string, format string) []string {
|
||||
// tsv: tab separated value
|
||||
// pipes: pipe (|) separated value
|
||||
// csv: comma separated value (default)
|
||||
//
|
||||
func SplitByFormat(data, format string) []string {
|
||||
if data == "" {
|
||||
return nil
|
||||
}
|
||||
var sep string
|
||||
switch format {
|
||||
case "ssv":
|
||||
case collectionFormatSpace:
|
||||
sep = " "
|
||||
case "tsv":
|
||||
case collectionFormatTab:
|
||||
sep = "\t"
|
||||
case "pipes":
|
||||
case collectionFormatPipe:
|
||||
sep = "|"
|
||||
case "multi":
|
||||
case collectionFormatMulti:
|
||||
return nil
|
||||
default:
|
||||
sep = ","
|
||||
@@ -157,7 +166,7 @@ func (s byLength) Less(i, j int) bool {
|
||||
}
|
||||
|
||||
// Prepares strings by splitting by caps, spaces, dashes, and underscore
|
||||
func split(str string) (words []string) {
|
||||
func split(str string) []string {
|
||||
repl := strings.NewReplacer(
|
||||
"@", "At ",
|
||||
"&", "And ",
|
||||
@@ -185,9 +194,8 @@ func split(str string) (words []string) {
|
||||
str = strings.Replace(str, rex1.ReplaceAllString(k, " $1"), " "+k, -1)
|
||||
}
|
||||
// Get the final list of words
|
||||
words = rex2.FindAllString(str, -1)
|
||||
|
||||
return
|
||||
//words = rex2.FindAllString(str, -1)
|
||||
return rex2.FindAllString(str, -1)
|
||||
}
|
||||
|
||||
// Removes leading whitespaces
|
||||
@@ -219,9 +227,10 @@ func Camelize(word string) (camelized string) {
|
||||
|
||||
// ToFileName lowercases and underscores a go type name
|
||||
func ToFileName(name string) string {
|
||||
var out []string
|
||||
in := split(name)
|
||||
out := make([]string, 0, len(in))
|
||||
|
||||
for _, w := range split(name) {
|
||||
for _, w := range in {
|
||||
out = append(out, lower(w))
|
||||
}
|
||||
|
||||
@@ -230,8 +239,10 @@ func ToFileName(name string) string {
|
||||
|
||||
// ToCommandName lowercases and underscores a go type name
|
||||
func ToCommandName(name string) string {
|
||||
var out []string
|
||||
for _, w := range split(name) {
|
||||
in := split(name)
|
||||
out := make([]string, 0, len(in))
|
||||
|
||||
for _, w := range in {
|
||||
out = append(out, lower(w))
|
||||
}
|
||||
return strings.Join(out, "-")
|
||||
@@ -239,8 +250,10 @@ func ToCommandName(name string) string {
|
||||
|
||||
// ToHumanNameLower represents a code name as a human series of words
|
||||
func ToHumanNameLower(name string) string {
|
||||
var out []string
|
||||
for _, w := range split(name) {
|
||||
in := split(name)
|
||||
out := make([]string, 0, len(in))
|
||||
|
||||
for _, w := range in {
|
||||
if !isInitialism(upper(w)) {
|
||||
out = append(out, lower(w))
|
||||
} else {
|
||||
@@ -252,8 +265,10 @@ func ToHumanNameLower(name string) string {
|
||||
|
||||
// ToHumanNameTitle represents a code name as a human series of words with the first letters titleized
|
||||
func ToHumanNameTitle(name string) string {
|
||||
var out []string
|
||||
for _, w := range split(name) {
|
||||
in := split(name)
|
||||
out := make([]string, 0, len(in))
|
||||
|
||||
for _, w := range in {
|
||||
uw := upper(w)
|
||||
if !isInitialism(uw) {
|
||||
out = append(out, upper(w[:1])+lower(w[1:]))
|
||||
@@ -266,8 +281,10 @@ func ToHumanNameTitle(name string) string {
|
||||
|
||||
// ToJSONName camelcases a name which can be underscored or pascal cased
|
||||
func ToJSONName(name string) string {
|
||||
var out []string
|
||||
for i, w := range split(name) {
|
||||
in := split(name)
|
||||
out := make([]string, 0, len(in))
|
||||
|
||||
for i, w := range in {
|
||||
if i == 0 {
|
||||
out = append(out, lower(w))
|
||||
continue
|
||||
@@ -291,8 +308,10 @@ func ToVarName(name string) string {
|
||||
|
||||
// ToGoName translates a swagger name which can be underscored or camel cased to a name that golint likes
|
||||
func ToGoName(name string) string {
|
||||
var out []string
|
||||
for _, w := range split(name) {
|
||||
in := split(name)
|
||||
out := make([]string, 0, len(in))
|
||||
|
||||
for _, w := range in {
|
||||
uw := upper(w)
|
||||
mod := int(math.Min(float64(len(uw)), 2))
|
||||
if !isInitialism(uw) && !isInitialism(uw[:len(uw)-mod]) {
|
||||
@@ -314,6 +333,16 @@ func ToGoName(name string) string {
|
||||
return result
|
||||
}
|
||||
|
||||
// ContainsStrings searches a slice of strings for a case-sensitive match
|
||||
func ContainsStrings(coll []string, item string) bool {
|
||||
for _, a := range coll {
|
||||
if a == item {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// ContainsStringsCI searches a slice of strings for a case-insensitive match
|
||||
func ContainsStringsCI(coll []string, item string) bool {
|
||||
for _, a := range coll {
|
||||
|
102
vendor/github.com/go-openapi/swag/util_test.go
generated
vendored
102
vendor/github.com/go-openapi/swag/util_test.go
generated
vendored
@@ -76,22 +76,38 @@ func TestContainsStringsCI(t *testing.T) {
|
||||
assert.False(t, ContainsStringsCI(list, "nuts"))
|
||||
}
|
||||
|
||||
func TestContainsStrings(t *testing.T) {
|
||||
list := []string{"hello", "world", "and", "such"}
|
||||
|
||||
assert.True(t, ContainsStrings(list, "hello"))
|
||||
assert.False(t, ContainsStrings(list, "hELLo"))
|
||||
assert.True(t, ContainsStrings(list, "world"))
|
||||
assert.False(t, ContainsStrings(list, "World"))
|
||||
assert.True(t, ContainsStrings(list, "and"))
|
||||
assert.False(t, ContainsStrings(list, "AND"))
|
||||
assert.False(t, ContainsStrings(list, "nuts"))
|
||||
}
|
||||
|
||||
const (
|
||||
collectionFormatComma = "csv"
|
||||
)
|
||||
|
||||
func TestSplitByFormat(t *testing.T) {
|
||||
expected := []string{"one", "two", "three"}
|
||||
for _, fmt := range []string{"csv", "pipes", "tsv", "ssv", "multi"} {
|
||||
for _, fmt := range []string{collectionFormatComma, collectionFormatPipe, collectionFormatTab, collectionFormatSpace, collectionFormatMulti} {
|
||||
|
||||
var actual []string
|
||||
switch fmt {
|
||||
case "multi":
|
||||
case collectionFormatMulti:
|
||||
assert.Nil(t, SplitByFormat("", fmt))
|
||||
assert.Nil(t, SplitByFormat("blah", fmt))
|
||||
case "ssv":
|
||||
case collectionFormatSpace:
|
||||
actual = SplitByFormat(strings.Join(expected, " "), fmt)
|
||||
assert.EqualValues(t, expected, actual)
|
||||
case "pipes":
|
||||
case collectionFormatPipe:
|
||||
actual = SplitByFormat(strings.Join(expected, "|"), fmt)
|
||||
assert.EqualValues(t, expected, actual)
|
||||
case "tsv":
|
||||
case collectionFormatTab:
|
||||
actual = SplitByFormat(strings.Join(expected, "\t"), fmt)
|
||||
assert.EqualValues(t, expected, actual)
|
||||
default:
|
||||
@@ -102,18 +118,18 @@ func TestSplitByFormat(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestJoinByFormat(t *testing.T) {
|
||||
for _, fmt := range []string{"csv", "pipes", "tsv", "ssv", "multi"} {
|
||||
for _, fmt := range []string{collectionFormatComma, collectionFormatPipe, collectionFormatTab, collectionFormatSpace, collectionFormatMulti} {
|
||||
|
||||
lval := []string{"one", "two", "three"}
|
||||
var expected []string
|
||||
switch fmt {
|
||||
case "multi":
|
||||
case collectionFormatMulti:
|
||||
expected = lval
|
||||
case "ssv":
|
||||
case collectionFormatSpace:
|
||||
expected = []string{strings.Join(lval, " ")}
|
||||
case "pipes":
|
||||
case collectionFormatPipe:
|
||||
expected = []string{strings.Join(lval, "|")}
|
||||
case "tsv":
|
||||
case collectionFormatTab:
|
||||
expected = []string{strings.Join(lval, "\t")}
|
||||
default:
|
||||
expected = []string{strings.Join(lval, ",")}
|
||||
@@ -291,3 +307,69 @@ func TestIsZero(t *testing.T) {
|
||||
assert.Equal(t, it.Expected, IsZero(it.Data), fmt.Sprintf("%#v", it.Data))
|
||||
}
|
||||
}
|
||||
|
||||
func TestCamelize(t *testing.T) {
|
||||
samples := []translationSample{
|
||||
{"SampleText", "Sampletext"},
|
||||
{"FindThingByID", "Findthingbyid"},
|
||||
{"CAPWD.folwdBylc", "Capwd.folwdbylc"},
|
||||
{"CAPWDfolwdBylc", "Capwdfolwdbylc"},
|
||||
{"CAP_WD_folwdBylc", "Cap_wd_folwdbylc"},
|
||||
{"TypeOAI_alias", "Typeoai_alias"},
|
||||
{"Type_OAI_alias", "Type_oai_alias"},
|
||||
{"Type_OAIAlias", "Type_oaialias"},
|
||||
{"ELB.HTTPLoadBalancer", "Elb.httploadbalancer"},
|
||||
{"elbHTTPLoadBalancer", "Elbhttploadbalancer"},
|
||||
{"ELBHTTPLoadBalancer", "Elbhttploadbalancer"},
|
||||
}
|
||||
|
||||
for _, sample := range samples {
|
||||
res := Camelize(sample.str)
|
||||
assert.Equalf(t, sample.out, res, "expected Camelize(%q)=%q, got %q", sample.str, sample.out, res)
|
||||
}
|
||||
}
|
||||
|
||||
func TestToHumanNameTitle(t *testing.T) {
|
||||
samples := []translationSample{
|
||||
{"SampleText", "Sample Text"},
|
||||
{"FindThingByID", "Find Thing By ID"},
|
||||
{"CAPWD.folwdBylc", "CAPWD Folwd Bylc"},
|
||||
{"CAPWDfolwdBylc", "Capwdfolwd Bylc"},
|
||||
{"CAP_WD_folwdBylc", "CAP WD Folwd Bylc"},
|
||||
{"TypeOAI_alias", "Type OAI Alias"},
|
||||
{"Type_OAI_alias", "Type OAI Alias"},
|
||||
{"Type_OAIAlias", "Type OAI Alias"},
|
||||
{"ELB.HTTPLoadBalancer", "ELB HTTP Load Balancer"},
|
||||
{"elbHTTPLoadBalancer", "elb HTTP Load Balancer"},
|
||||
{"ELBHTTPLoadBalancer", "ELB HTTP Load Balancer"},
|
||||
}
|
||||
|
||||
for _, sample := range samples {
|
||||
res := ToHumanNameTitle(sample.str)
|
||||
assert.Equalf(t, sample.out, res, "expected ToHumanNameTitle(%q)=%q, got %q", sample.str, sample.out, res)
|
||||
}
|
||||
}
|
||||
|
||||
func TestToVarName(t *testing.T) {
|
||||
samples := []translationSample{
|
||||
{"SampleText", "sampleText"},
|
||||
{"FindThingByID", "findThingByID"},
|
||||
{"CAPWD.folwdBylc", "cAPWDFolwdBylc"},
|
||||
{"CAPWDfolwdBylc", "capwdfolwdBylc"},
|
||||
{"CAP_WD_folwdBylc", "cAPWDFolwdBylc"},
|
||||
{"TypeOAI_alias", "typeOAIAlias"},
|
||||
{"Type_OAI_alias", "typeOAIAlias"},
|
||||
{"Type_OAIAlias", "typeOAIAlias"},
|
||||
{"ELB.HTTPLoadBalancer", "eLBHTTPLoadBalancer"},
|
||||
{"elbHTTPLoadBalancer", "eLBHTTPLoadBalancer"},
|
||||
{"ELBHTTPLoadBalancer", "eLBHTTPLoadBalancer"},
|
||||
{"Id", "id"},
|
||||
{"HTTP", "http"},
|
||||
{"A", "a"},
|
||||
}
|
||||
|
||||
for _, sample := range samples {
|
||||
res := ToVarName(sample.str)
|
||||
assert.Equalf(t, sample.out, res, "expected ToVarName(%q)=%q, got %q", sample.str, sample.out, res)
|
||||
}
|
||||
}
|
||||
|
8
vendor/github.com/go-openapi/swag/yaml_test.go
generated
vendored
8
vendor/github.com/go-openapi/swag/yaml_test.go
generated
vendored
@@ -48,7 +48,7 @@ func TestLoadHTTPBytes(t *testing.T) {
|
||||
|
||||
ts2 := httptest.NewServer(http.HandlerFunc(func(rw http.ResponseWriter, r *http.Request) {
|
||||
rw.WriteHeader(http.StatusOK)
|
||||
rw.Write([]byte("the content"))
|
||||
_, _ = rw.Write([]byte("the content"))
|
||||
}))
|
||||
defer ts2.Close()
|
||||
|
||||
@@ -65,7 +65,7 @@ name: a string value
|
||||
'y': some value
|
||||
`
|
||||
var data yaml.MapSlice
|
||||
yaml.Unmarshal([]byte(sd), &data)
|
||||
_ = yaml.Unmarshal([]byte(sd), &data)
|
||||
|
||||
d, err := YAMLToJSON(data)
|
||||
if assert.NoError(t, err) {
|
||||
@@ -142,7 +142,7 @@ func TestLoadStrategy(t *testing.T) {
|
||||
|
||||
ts2 := httptest.NewServer(http.HandlerFunc(func(rw http.ResponseWriter, r *http.Request) {
|
||||
rw.WriteHeader(http.StatusNotFound)
|
||||
rw.Write([]byte("\n"))
|
||||
_, _ = rw.Write([]byte("\n"))
|
||||
}))
|
||||
defer ts2.Close()
|
||||
_, err = YAMLDoc(ts2.URL)
|
||||
@@ -151,7 +151,7 @@ func TestLoadStrategy(t *testing.T) {
|
||||
|
||||
var yamlPestoreServer = func(rw http.ResponseWriter, r *http.Request) {
|
||||
rw.WriteHeader(http.StatusOK)
|
||||
rw.Write([]byte(yamlPetStore))
|
||||
_, _ = rw.Write([]byte(yamlPetStore))
|
||||
}
|
||||
|
||||
func TestWithYKey(t *testing.T) {
|
||||
|
Reference in New Issue
Block a user