Update a few dependencies

github.com/go-openapi/*
github.com/asaskevich/govalidator
This commit is contained in:
Mikhail Mazurskiy
2018-10-18 23:33:10 +11:00
parent b8731a76f0
commit 8763223ab9
191 changed files with 18648 additions and 1800 deletions

View File

@@ -1 +0,0 @@
eyJhbGciOiJSU0EtT0FFUCIsImVuYyI6IkExMjhHQ00ifQ.oFD1QZMPp6fyNX1o0DOnc4z-x2hG-sfZQd9R7kKzmybFk6xHSiyMyqYH6v3zdehvIj2oficznIvKfFsS1WHNWLB0sq3UpcN2-e9x8Ib0ugH6unqr5pYkVhQ4rzn2_m1o-AnV6FkPoQLv1989yqwdJlpfF6XzrHH_XHrUqDmB6vpIthSl7w7lDWM_dkHs78ysNW3X1_4cHcltC6Vouk4RaKn9NF703RPweBm0MvNaxOSu5dnWJAR8WkB3ok83yhqb-uogECE85M4bvVzVR5kslVToDACB6seTHHOfYNGi3r7kyGaf8wHhv6EMWekTh1ezfHjIFqOrSI66SPW8k4EQNQ.z1lRoo00GLx-rCe3.MwoukkAcqSh2BBEn12T_ITjDhJK5N_8zokty2mJs0Wl37_fdOnqw2PSMdTFubFl-1bRRhEtj7PpgNK7lIQFK-Fid3zm0MHE6C_QXAx6EeWORvCBVnJD-fUntOfP3Vy6iQpgPdNmtf3vk0NRHXPUsBjftfKdDDgdidyS3KnPBLrmE10g963Ig30ryNj59JT922M-rjTAnJMZP3AhOzr5Ws0R_vtDllyguMzktmMOLj7UbQRLEtupdke7QXcJnt7NMNruraXfHYqnfNE00kLDe8a1T0atIjyoDXjGFmYCxOe3B96obCf9uTDu649nA7rOZuCWh9detU1v8Tl_VmsQ8KB8XQXMo10dx33Cq-pdQWtWGGDh1hyMnCKMkuv5FVRDTa8tNnfiVvYx-AJyZYbrUkpuJPhnz0Zjd44bParuYUU6P7EDvZShpokVb79de_gGJZLuBeWbUgvzbS71WaCn_M1m6Uat-WYpzs-hdb-t2Pyu3fKFxlfh8hlcT1xdQq1gy4chu5F_WplGzHWXC2xvXVkq-XoKsGanoiso29-5aH9ZwyjCKK6Lr4j3Na653arj9MafJmcq-WFRcAZdiAM7nTEYNqExpIUV13QDlDefMD_wYj2fQqE13dVKL2ymphjtlLVk.AIDupKXX32FU7k0A9NynjA

View File

@@ -1,31 +0,0 @@
clone:
path: github.com/go-openapi/errors
matrix:
GO_VERSION:
- "1.6"
build:
integration:
image: golang:$$GO_VERSION
pull: true
commands:
- go get -u github.com/stretchr/testify/assert
- go test -race
- go test -v -cover -coverprofile=coverage.out -covermode=count ./...
notify:
slack:
channel: bots
webhook_url: $$SLACK_URL
username: drone
publish:
coverage:
server: https://coverage.vmware.run
token: $$GITHUB_TOKEN
# threshold: 70
# must_increase: true
when:
matrix:
GO_VERSION: "1.6"

View File

@@ -1,13 +0,0 @@
approve_by_comment: true
approve_regex: '^(:shipit:|:\+1:|\+1|LGTM|lgtm|Approved)'
reject_regex: ^[Rr]ejected
reset_on_push: false
reviewers:
members:
- casualjim
- chancez
- frapposelli
- vburenin
- pytlesk4
name: pullapprove
required: 1

14
vendor/github.com/go-openapi/errors/.travis.yml generated vendored Normal file
View File

@@ -0,0 +1,14 @@
after_success:
- bash <(curl -s https://codecov.io/bash)
go:
- '1.9'
- 1.10.x
- 1.11.x
install:
- go get -u github.com/stretchr/testify/assert
language: go
notifications:
slack:
secure: gZGp9NaHxi7zawlXJXKY92BGeDR1x0tbIcTyU5nMKLq0fhIaiEBJEeALwZ4VgqsSv3DytSSF5mLH8fevAM3ixE6hxjKQ+lQuf7V/w3btCN1CSWgoua5LOh1kTnqZQtJuRvO4pzoJcT3bJWBsVZ07VGNVzzJEy/zAKCHFqBUCXShw7QemlLBcYWFNqveTlvDIfCzvouoLnPoXwxEpkjxe9uz/ZKZgAnup/fXjC8RFctmgCnkCyvJTk0Y/fZCsufixJrJhshBWTnlrFCzRmgNkz2d+i1Ls3+MJ5EJJ2Tx/A5S63dL49J1f9Kr0AKHADmulSy8JNzIckKwbyFMYUecrsW+Lsu9DhnVMy1jj5pKsJDLRi2iIU3fXTMWbcyQbXjbbnBO2mPdP3Tzme75y4D9fc8hUPeyqVv2BU26NEbQ7EF2pKJ93OXvci7HlwRBgdJa8j6mP2LEDClcPQW00g7N/OZe0cTOMa8L5AwiBlbArwqt9wv6YLJoTG0wpDhzWsFvbCg5bJxe28Yn3fIDD0Lk1I7iSnBbp/5gzF19jmxqvcT8tHRkDL4xfjbENFTZjA5uB4Z4pj4WSyWQILLV/Jwhe3fi9uQwdviFHfj5pnVrmNUiGSOQL672K5wl2c3E9mGwejvsu2dfEz28n7Y/FUnOpY3/cBS0n27JJaerS0zMKNLE=
script:
- go test -v -race -cover -coverprofile=coverage.txt -covermode=atomic ./...

View File

@@ -5,6 +5,7 @@ go_library(
srcs = [
"api.go",
"auth.go",
"doc.go",
"headers.go",
"middleware.go",
"parsing.go",

View File

@@ -1,5 +1,8 @@
# OpenAPI errors [![Build Status](https://ci.vmware.run/api/badges/go-openapi/errors/status.svg)](https://ci.vmware.run/go-openapi/errors) [![Coverage](https://coverage.vmware.run/badges/go-openapi/errors/coverage.svg)](https://coverage.vmware.run/go-openapi/errors) [![Slack Status](https://slackin.goswagger.io/badge.svg)](https://slackin.goswagger.io)
# OpenAPI errors [![Build Status](https://travis-ci.org/go-openapi/errors.svg?branch=master)](https://travis-ci.org/go-openapi/errors) [![codecov](https://codecov.io/gh/go-openapi/errors/branch/master/graph/badge.svg)](https://codecov.io/gh/go-openapi/errors) [![Slack Status](https://slackin.goswagger.io/badge.svg)](https://slackin.goswagger.io)
[![license](http://img.shields.io/badge/license-Apache%20v2-orange.svg)](https://raw.githubusercontent.com/go-openapi/errors/master/LICENSE) [![GoDoc](https://godoc.org/github.com/go-openapi/errors?status.svg)](http://godoc.org/github.com/go-openapi/errors)
[![license](http://img.shields.io/badge/license-Apache%20v2-orange.svg)](https://raw.githubusercontent.com/go-openapi/errors/master/LICENSE)
[![GoDoc](https://godoc.org/github.com/go-openapi/errors?status.svg)](http://godoc.org/github.com/go-openapi/errors)
[![GolangCI](https://golangci.com/badges/github.com/go-openapi/errors.svg)](https://golangci.com)
[![Go Report Card](https://goreportcard.com/badge/github.com/go-openapi/errors)](https://goreportcard.com/report/github.com/go-openapi/errors)
Shared errors used throughout the various libraries for the go-openapi toolkit
Shared errors and error interface used throughout the various libraries found in the go-openapi toolkit.

View File

@@ -18,9 +18,13 @@ import (
"encoding/json"
"fmt"
"net/http"
"reflect"
"strings"
)
// DefaultHTTPCode is used when the error Code cannot be used as an HTTP code.
var DefaultHTTPCode = 422
// Error represents a error interface all swagger framework errors implement
type Error interface {
error
@@ -111,33 +115,52 @@ func MethodNotAllowed(requested string, allow []string) Error {
return &MethodNotAllowedError{code: http.StatusMethodNotAllowed, Allowed: allow, message: msg}
}
// ServeError the error handler interface implemenation
const head = "HEAD"
// ServeError the error handler interface implementation
func ServeError(rw http.ResponseWriter, r *http.Request, err error) {
rw.Header().Set("Content-Type", "application/json")
switch e := err.(type) {
case *CompositeError:
er := flattenComposite(e)
ServeError(rw, r, er.Errors[0])
// strips composite errors to first element only
if len(er.Errors) > 0 {
ServeError(rw, r, er.Errors[0])
} else {
// guard against empty CompositeError (invalid construct)
ServeError(rw, r, nil)
}
case *MethodNotAllowedError:
rw.Header().Add("Allow", strings.Join(err.(*MethodNotAllowedError).Allowed, ","))
rw.WriteHeader(int(e.Code()))
if r == nil || r.Method != "HEAD" {
rw.WriteHeader(asHTTPCode(int(e.Code())))
if r == nil || r.Method != head {
rw.Write(errorAsJSON(e))
}
case Error:
if e == nil {
value := reflect.ValueOf(e)
if value.Kind() == reflect.Ptr && value.IsNil() {
rw.WriteHeader(http.StatusInternalServerError)
rw.Write(errorAsJSON(New(http.StatusInternalServerError, "Unknown error")))
return
}
rw.WriteHeader(int(e.Code()))
if r == nil || r.Method != "HEAD" {
rw.WriteHeader(asHTTPCode(int(e.Code())))
if r == nil || r.Method != head {
rw.Write(errorAsJSON(e))
}
case nil:
rw.WriteHeader(http.StatusInternalServerError)
rw.Write(errorAsJSON(New(http.StatusInternalServerError, "Unknown error")))
default:
rw.WriteHeader(http.StatusInternalServerError)
if r == nil || r.Method != "HEAD" {
if r == nil || r.Method != head {
rw.Write(errorAsJSON(New(http.StatusInternalServerError, err.Error())))
}
}
}
func asHTTPCode(input int) int {
if input >= 600 {
return DefaultHTTPCode
}
return input
}

28
vendor/github.com/go-openapi/errors/doc.go generated vendored Normal file
View File

@@ -0,0 +1,28 @@
// 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 errors provides an Error interface and several concrete types
implementing this interface to manage API errors and JSON-schema validation
errors.
A middleware handler ServeError() is provided to serve the errors types
it defines.
It is used throughout the various go-openapi toolkit libraries
(https://github.com/go-openapi).
*/
package errors

7
vendor/github.com/go-openapi/errors/go.mod generated vendored Normal file
View File

@@ -0,0 +1,7 @@
module github.com/go-openapi/errors
require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/stretchr/testify v1.2.2
)

5
vendor/github.com/go-openapi/errors/go.sum generated vendored Normal file
View File

@@ -0,0 +1,5 @@
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/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=

View File

@@ -38,6 +38,15 @@ func (e *Validation) Code() int32 {
return e.code
}
// ValidateName produces an error message name for an aliased property
func (e *Validation) ValidateName(name string) *Validation {
if e.Name == "" && name != "" {
e.Name = name
e.message = name + e.message
}
return e
}
const (
contentTypeFail = `unsupported media type %q, only %v are allowed`
responseFormatFail = `unsupported media type requested, only %v are available`

View File

@@ -63,6 +63,34 @@ const (
unallowedPropertyNoIn = "%s.%s is a forbidden property"
failedAllPatternProps = "%s.%s in %s failed all pattern properties"
failedAllPatternPropsNoIn = "%s.%s failed all pattern properties"
multipleOfMustBePositive = "factor MultipleOf declared for %s must be positive: %v"
)
// All code responses can be used to differentiate errors for different handling
// by the consuming program
const (
// CompositeErrorCode remains 422 for backwards-compatibility
// and to separate it from validation errors with cause
CompositeErrorCode = 422
// InvalidTypeCode is used for any subclass of invalid types
InvalidTypeCode = 600 + iota
RequiredFailCode
TooLongFailCode
TooShortFailCode
PatternFailCode
EnumFailCode
MultipleOfFailCode
MaxFailCode
MinFailCode
UniqueFailCode
MaxItemsFailCode
MinItemsFailCode
NoAdditionalItemsCode
TooFewPropertiesCode
TooManyPropertiesCode
UnallowedPropertyCode
FailedAllPatternPropsCode
MultipleOfMustBePositiveCode
)
// CompositeError is an error that groups several errors together
@@ -91,7 +119,7 @@ func (c *CompositeError) Error() string {
// CompositeValidationError an error to wrap a bunch of other errors
func CompositeValidationError(errors ...error) *CompositeError {
return &CompositeError{
code: 422,
code: CompositeErrorCode,
Errors: append([]error{}, errors...),
message: "validation failure list",
}
@@ -104,7 +132,7 @@ func FailedAllPatternProperties(name, in, key string) *Validation {
msg = fmt.Sprintf(failedAllPatternPropsNoIn, name, key)
}
return &Validation{
code: 422,
code: FailedAllPatternPropsCode,
Name: name,
In: in,
Value: key,
@@ -119,7 +147,7 @@ func PropertyNotAllowed(name, in, key string) *Validation {
msg = fmt.Sprintf(unallowedPropertyNoIn, name, key)
}
return &Validation{
code: 422,
code: UnallowedPropertyCode,
Name: name,
In: in,
Value: key,
@@ -134,7 +162,7 @@ func TooFewProperties(name, in string, n int64) *Validation {
msg = fmt.Sprintf(tooFewPropertiesNoIn, name, n)
}
return &Validation{
code: 422,
code: TooFewPropertiesCode,
Name: name,
In: in,
Value: n,
@@ -149,7 +177,7 @@ func TooManyProperties(name, in string, n int64) *Validation {
msg = fmt.Sprintf(tooManyPropertiesNoIn, name, n)
}
return &Validation{
code: 422,
code: TooManyPropertiesCode,
Name: name,
In: in,
Value: n,
@@ -164,7 +192,7 @@ func AdditionalItemsNotAllowed(name, in string) *Validation {
msg = fmt.Sprintf(noAdditionalItemsNoIn, name)
}
return &Validation{
code: 422,
code: NoAdditionalItemsCode,
Name: name,
In: in,
message: msg,
@@ -174,7 +202,7 @@ func AdditionalItemsNotAllowed(name, in string) *Validation {
// InvalidCollectionFormat another flavor of invalid type error
func InvalidCollectionFormat(name, in, format string) *Validation {
return &Validation{
code: 422,
code: InvalidTypeCode,
Name: name,
In: in,
Value: format,
@@ -185,7 +213,7 @@ func InvalidCollectionFormat(name, in, format string) *Validation {
// InvalidTypeName an error for when the type is invalid
func InvalidTypeName(typeName string) *Validation {
return &Validation{
code: 422,
code: InvalidTypeCode,
Value: typeName,
message: fmt.Sprintf(invalidType, typeName),
}
@@ -216,7 +244,7 @@ func InvalidType(name, in, typeName string, value interface{}) *Validation {
}
return &Validation{
code: 422,
code: InvalidTypeCode,
Name: name,
In: in,
Value: value,
@@ -232,7 +260,7 @@ func DuplicateItems(name, in string) *Validation {
msg = fmt.Sprintf(uniqueFailNoIn, name)
}
return &Validation{
code: 422,
code: UniqueFailCode,
Name: name,
In: in,
message: msg,
@@ -247,7 +275,7 @@ func TooManyItems(name, in string, max int64) *Validation {
}
return &Validation{
code: 422,
code: MaxItemsFailCode,
Name: name,
In: in,
message: msg,
@@ -261,7 +289,7 @@ func TooFewItems(name, in string, min int64) *Validation {
msg = fmt.Sprintf(minItemsFailNoIn, name, min)
}
return &Validation{
code: 422,
code: MinItemsFailCode,
Name: name,
In: in,
message: msg,
@@ -285,7 +313,7 @@ func ExceedsMaximumInt(name, in string, max int64, exclusive bool) *Validation {
message = fmt.Sprintf(m, name, in, max)
}
return &Validation{
code: 422,
code: MaxFailCode,
Name: name,
In: in,
Value: max,
@@ -310,7 +338,7 @@ func ExceedsMaximumUint(name, in string, max uint64, exclusive bool) *Validation
message = fmt.Sprintf(m, name, in, max)
}
return &Validation{
code: 422,
code: MaxFailCode,
Name: name,
In: in,
Value: max,
@@ -335,7 +363,7 @@ func ExceedsMaximum(name, in string, max float64, exclusive bool) *Validation {
message = fmt.Sprintf(m, name, in, max)
}
return &Validation{
code: 422,
code: MaxFailCode,
Name: name,
In: in,
Value: max,
@@ -360,7 +388,7 @@ func ExceedsMinimumInt(name, in string, min int64, exclusive bool) *Validation {
message = fmt.Sprintf(m, name, in, min)
}
return &Validation{
code: 422,
code: MinFailCode,
Name: name,
In: in,
Value: min,
@@ -385,7 +413,7 @@ func ExceedsMinimumUint(name, in string, min uint64, exclusive bool) *Validation
message = fmt.Sprintf(m, name, in, min)
}
return &Validation{
code: 422,
code: MinFailCode,
Name: name,
In: in,
Value: min,
@@ -410,7 +438,7 @@ func ExceedsMinimum(name, in string, min float64, exclusive bool) *Validation {
message = fmt.Sprintf(m, name, in, min)
}
return &Validation{
code: 422,
code: MinFailCode,
Name: name,
In: in,
Value: min,
@@ -419,7 +447,7 @@ func ExceedsMinimum(name, in string, min float64, exclusive bool) *Validation {
}
// NotMultipleOf error for when multiple of validation fails
func NotMultipleOf(name, in string, multiple float64) *Validation {
func NotMultipleOf(name, in string, multiple interface{}) *Validation {
var msg string
if in == "" {
msg = fmt.Sprintf(multipleOfFailNoIn, name, multiple)
@@ -427,7 +455,7 @@ func NotMultipleOf(name, in string, multiple float64) *Validation {
msg = fmt.Sprintf(multipleOfFail, name, in, multiple)
}
return &Validation{
code: 422,
code: MultipleOfFailCode,
Name: name,
In: in,
Value: multiple,
@@ -445,7 +473,7 @@ func EnumFail(name, in string, value interface{}, values []interface{}) *Validat
}
return &Validation{
code: 422,
code: EnumFailCode,
Name: name,
In: in,
Value: value,
@@ -463,7 +491,7 @@ func Required(name, in string) *Validation {
msg = fmt.Sprintf(requiredFail, name, in)
}
return &Validation{
code: 422,
code: RequiredFailCode,
Name: name,
In: in,
message: msg,
@@ -479,7 +507,7 @@ func TooLong(name, in string, max int64) *Validation {
msg = fmt.Sprintf(tooLongMessage, name, in, max)
}
return &Validation{
code: 422,
code: TooLongFailCode,
Name: name,
In: in,
message: msg,
@@ -496,7 +524,7 @@ func TooShort(name, in string, min int64) *Validation {
}
return &Validation{
code: 422,
code: TooShortFailCode,
Name: name,
In: in,
message: msg,
@@ -514,9 +542,21 @@ func FailedPattern(name, in, pattern string) *Validation {
}
return &Validation{
code: 422,
code: PatternFailCode,
Name: name,
In: in,
message: msg,
}
}
// MultipleOfMustBePositive error for when a
// multipleOf factor is negative
func MultipleOfMustBePositive(name, in string, factor interface{}) *Validation {
return &Validation{
code: MultipleOfMustBePositiveCode,
Name: name,
In: in,
Value: factor,
message: fmt.Sprintf(multipleOfMustBePositive, name, factor),
}
}