1
1
mirror of https://github.com/go-gitea/gitea synced 2025-07-22 18:28:37 +00:00

[Vendor] update go-swagger v0.21.0 -> v0.25.0 (#12670)

* Update go-swagger

* vendor
This commit is contained in:
6543
2020-09-01 16:01:23 +02:00
committed by GitHub
parent 66843f2237
commit 3270e7a443
350 changed files with 26353 additions and 5552 deletions

View File

@@ -180,7 +180,13 @@ func (ejv *extJSONValue) parseDBPointer() (ns string, oid primitive.ObjectID, er
return ns, oid, nil
}
const rfc3339Milli = "2006-01-02T15:04:05.999Z07:00"
const (
rfc3339Milli = "2006-01-02T15:04:05.999Z07:00"
)
var (
timeFormats = []string{rfc3339Milli, "2006-01-02T15:04:05.999Z0700"}
)
func (ejv *extJSONValue) parseDateTime() (int64, error) {
switch ejv.t {
@@ -198,7 +204,15 @@ func (ejv *extJSONValue) parseDateTime() (int64, error) {
}
func parseDatetimeString(data string) (int64, error) {
t, err := time.Parse(rfc3339Milli, data)
var t time.Time
var err error
// try acceptable time formats until one matches
for _, format := range timeFormats {
t, err = time.Parse(format, data)
if err == nil {
break
}
}
if err != nil {
return 0, fmt.Errorf("invalid $date value string: %s", data)
}
@@ -416,17 +430,20 @@ func (ejv *extJSONValue) parseTimestamp() (t, i uint32, err error) {
switch val.t {
case bsontype.Int32:
if val.v.(int32) < 0 {
return 0, fmt.Errorf("$timestamp %s number should be uint32: %s", key, string(val.v.(int32)))
value := val.v.(int32)
if value < 0 {
return 0, fmt.Errorf("$timestamp %s number should be uint32: %d", key, value)
}
return uint32(val.v.(int32)), nil
return uint32(value), nil
case bsontype.Int64:
if val.v.(int64) < 0 || uint32(val.v.(int64)) > math.MaxUint32 {
return 0, fmt.Errorf("$timestamp %s number should be uint32: %s", key, string(val.v.(int32)))
value := val.v.(int64)
if value < 0 || value > int64(math.MaxUint32) {
return 0, fmt.Errorf("$timestamp %s number should be uint32: %d", key, value)
}
return uint32(val.v.(int64)), nil
return uint32(value), nil
default:
return 0, fmt.Errorf("$timestamp %s value should be uint32, but instead is %s", key, val.t)
}