Bumping k8s dependencies to 1.13
This commit is contained in:
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