mirror of
https://gitcode.com/gitea/gitea.git
synced 2025-06-22 21:04:41 +08:00
Use vendored go-swagger (#8087)
* Use vendored go-swagger * vendor go-swagger * revert un wanteed change * remove un-needed GO111MODULE * Update Makefile Co-Authored-By: techknowlogick <matti@mdranta.net>
This commit is contained in:

committed by
Lauris BH

parent
4cb1bdddc8
commit
9fe4437bda
Makefilego.modgo.sumtools.gomodules.txt
vendor
github.com
PuerkitoBio
asaskevich/govalidator
.travis.ymlCONTRIBUTING.mdLICENSEREADME.mdarrays.goconverter.goerror.gonumerics.gopatterns.gotypes.goutils.govalidator.gowercker.yml
fsnotify/fsnotify
.editorconfig.gitignore.travis.ymlAUTHORSCHANGELOG.mdCONTRIBUTING.mdLICENSEREADME.mdfen.gofsnotify.goinotify.goinotify_poller.gokqueue.goopen_mode_bsd.goopen_mode_darwin.gowindows.go
go-openapi
analysis
.codecov.yml.gitignore.golangci.yml.travis.ymlCODE_OF_CONDUCT.mdLICENSEREADME.mdanalyzer.goappveyor.ymldebug.godoc.gofixer.goflatten.gogo.modgo.sum
internal
mixin.goschema.goerrors
.gitignore.golangci.yml.travis.ymlCODE_OF_CONDUCT.mdLICENSEREADME.mdapi.goauth.godoc.gogo.modgo.sumheaders.gomiddleware.goparsing.goschema.go
inflect
jsonpointer
jsonreference
loads
.editorconfig.gitignore.golangci.yml.travis.ymlCODE_OF_CONDUCT.mdLICENSEREADME.mddoc.go
fmts
go.modgo.sumspec.goruntime
.editorconfig.gitignore.travis.ymlCODE_OF_CONDUCT.mdLICENSEREADME.mdbytestream.goclient_auth_info.goclient_operation.goclient_request.goclient_response.goconstants.gocsv.godiscard.gofile.gogo.modgo.sumheaders.gointerfaces.gojson.go
logger
middleware
context.go
request.godenco
doc.gogo18.goheader
negotiate.gonot_implemented.gooperation.goparameter.gopre_go18.goredoc.gorequest.gorouter.gosecurity.gospec.gountyped
validation.gosecurity
statuses.gotext.govalues.goxml.gospec
.editorconfig.gitignore.golangci.yml.travis.ymlCODE_OF_CONDUCT.mdLICENSEREADME.mdbindata.gocache.gocontact_info.godebug.goexpander.goexternal_docs.gogo.modgo.sumheader.goinfo.goitems.golicense.gonormalizer.gooperation.goparameter.gopath_item.gopaths.goref.goresponse.goresponses.goschema.goschema_loader.gosecurity_scheme.gospec.goswagger.gotag.gounused.goxml_object.go
strfmt
.editorconfig.gitignore.golangci.yml.travis.ymlCODE_OF_CONDUCT.mdLICENSEREADME.mdbson.godate.godefault.godoc.goduration.goformat.gogo.modgo.sumtime.go
swag
.editorconfig.gitignore.golangci.yml.travis.ymlCODE_OF_CONDUCT.mdLICENSEREADME.mdconvert.goconvert_types.godoc.gogo.modgo.sumjson.goloading.goname_lexem.gonet.gopath.gopost_go18.gopost_go19.gopre_go18.gopre_go19.gosplit.goutil.goyaml.go
validate
.editorconfig.gitignore.golangci.yml.travis.ymlCODE_OF_CONDUCT.mdLICENSEREADME.mddebug.godefault_validator.godoc.goexample_validator.goformats.gogo.modgo.sumhelpers.goobject_validator.gooptions.goresult.gorexp.goschema.goschema_messages.goschema_option.goschema_props.goslice_validator.gospec.gospec_messages.gotype.goupdate-fixtures.shvalidator.govalues.go
go-stack/stack
go-swagger/go-swagger
LICENSE
cmd/swagger
.gitignore
commands
diff.go
swagger.godiff
array_diff.gocompatibility.godifference_location.godifftypes.gonode.goreporting.gospec_analyser.gospec_difference.gotype_adapters.go
expand.goflatten.gogenerate.gogenerate
initcmd.goinitcmd
mixin.goserve.govalidate.goversion.gocodescan
application.gometa.gooperations.goparameters.goparser.goregexprs.goresponses.goroute_params.goroutes.goschema.gospec.go
generator
bindata.goclient.goconfig.godebug.godiscriminators.godoc.goformats.gogen-debug.shmodel.gooperation.goshared.gostructs.gosupport.gotemplate_repo.gotypes.go
scan
gorilla/handlers
LICENSEREADME.mdcanonical.gocompress.gocors.godoc.gogo.modhandlers.gohandlers_go18.gohandlers_pre18.gologging.goproxy_headers.gorecovery.go
hashicorp/hcl
.gitignore.travis.ymlLICENSEMakefileREADME.mdappveyor.ymldecoder.gogo.modgo.sumhcl.go
hcl
ast
parser
printer
scanner
strconv
token
json
lex.goparse.gojessevdk/go-flags
.travis.ymlLICENSEREADME.mdarg.gocheck_crosscompile.shclosest.gocommand.gocompletion.goconvert.goerror.goflags.gogroup.gohelp.goini.goman.gomultitag.gooption.gooptstyle_other.gooptstyle_windows.goparser.gotermsize.gotermsize_nosysioctl.gotiocgwinsz_bsdish.gotiocgwinsz_linux.gotiocgwinsz_other.go
kr
pretty
text
magiconair/properties
.gitignore.travis.ymlCHANGELOG.mdLICENSEREADME.mddecode.godoc.gogo.modintegrate.golex.goload.goparser.goproperties.gorangecheck.go
mailru/easyjson
mitchellh/mapstructure
pelletier/go-toml
.dockerignore.gitignore.travis.ymlCONTRIBUTING.mdDockerfileLICENSEPULL_REQUEST_TEMPLATE.mdREADME.mdappveyor.ymlbenchmark.jsonbenchmark.shbenchmark.tomlbenchmark.ymldoc.goexample-crlf.tomlexample.tomlfuzz.gofuzz.shgo.modgo.sumkeysparsing.golexer.gomarshal.gomarshal_OrderPreserve_Map_test.tomlmarshal_OrderPreserve_test.tomlmarshal_test.tomlparser.goposition.gotoken.gotoml.gotomltree_create.gotomltree_write.go
spf13
afero
.travis.ymlLICENSE.txtREADME.mdafero.goappveyor.ymlbasepath.gocacheOnReadFs.goconst_bsds.goconst_win_unix.gocopyOnWriteFs.gogo.modgo.sumhttpFs.goioutil.golstater.gomatch.go
mem
memmap.goos.gopath.goreadonlyfs.goregexpfs.gounionFile.goutil.gocast
jwalterweatherman
pflag
.gitignore.travis.ymlLICENSEREADME.mdbool.gobool_slice.gobytes.gocount.goduration.goduration_slice.goflag.gofloat32.gofloat64.gogolangflag.goint.goint16.goint32.goint64.goint8.goint_slice.goip.goip_slice.goipmask.goipnet.gostring.gostring_array.gostring_slice.gostring_to_int.gostring_to_string.gouint.gouint16.gouint32.gouint64.gouint8.gouint_slice.go
viper
toqueteos/webbrowser
go.mongodb.org/mongo-driver
LICENSE
bson
bson.gobson_1_8.go
bsoncodec
bsoncodec.godefault_value_decoders.godefault_value_encoders.godoc.gomode.gopointer_codec.goproxy.goregistry.gostruct_codec.gostruct_tag_parser.gotypes.go
bsonrw
copier.godoc.goextjson_parser.goextjson_reader.goextjson_tables.goextjson_wrappers.goextjson_writer.gojson_scanner.gomode.goreader.govalue_reader.govalue_writer.gowriter.go
bsontype
decoder.godoc.goencoder.gomarshal.goprimitive
primitive_codecs.goraw.goraw_element.goraw_value.goregistry.gotypes.gounmarshal.gox/bsonx/bsoncore
golang.org/x
sys/cpu
text/width
gen.gogen_common.gogen_trieval.gokind_string.gotables10.0.0.gotables11.0.0.gotables9.0.0.gotransform.gotrieval.gowidth.go
tools
AUTHORSCONTRIBUTORSLICENSEPATENTS
go
ast/astutil
buildutil
gcexportdata
internal
cgo
gcimporter
bexport.gobimport.goexportdata.gogcimporter.goiexport.goiimport.gonewInterface10.gonewInterface11.go
packagesdriver
loader
packages
imports
internal
203
vendor/github.com/go-openapi/strfmt/time.go
generated
vendored
Normal file
203
vendor/github.com/go-openapi/strfmt/time.go
generated
vendored
Normal file
@ -0,0 +1,203 @@
|
||||
// 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 strfmt
|
||||
|
||||
import (
|
||||
"database/sql/driver"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"regexp"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"go.mongodb.org/mongo-driver/bson"
|
||||
)
|
||||
|
||||
func init() {
|
||||
dt := DateTime{}
|
||||
Default.Add("datetime", &dt, IsDateTime)
|
||||
}
|
||||
|
||||
// IsDateTime returns true when the string is a valid date-time
|
||||
func IsDateTime(str string) bool {
|
||||
if len(str) < 4 {
|
||||
return false
|
||||
}
|
||||
s := strings.Split(strings.ToLower(str), "t")
|
||||
if len(s) < 2 || !IsDate(s[0]) {
|
||||
return false
|
||||
}
|
||||
|
||||
matches := rxDateTime.FindAllStringSubmatch(s[1], -1)
|
||||
if len(matches) == 0 || len(matches[0]) == 0 {
|
||||
return false
|
||||
}
|
||||
m := matches[0]
|
||||
res := m[1] <= "23" && m[2] <= "59" && m[3] <= "59"
|
||||
return res
|
||||
}
|
||||
|
||||
const (
|
||||
// RFC3339Millis represents a ISO8601 format to millis instead of to nanos
|
||||
RFC3339Millis = "2006-01-02T15:04:05.000Z07:00"
|
||||
// RFC3339Micro represents a ISO8601 format to micro instead of to nano
|
||||
RFC3339Micro = "2006-01-02T15:04:05.000000Z07:00"
|
||||
// ISO8601LocalTime represents a ISO8601 format to ISO8601 in local time (no timezone)
|
||||
ISO8601LocalTime = "2006-01-02T15:04:05"
|
||||
// DateTimePattern pattern to match for the date-time format from http://tools.ietf.org/html/rfc3339#section-5.6
|
||||
DateTimePattern = `^([0-9]{2}):([0-9]{2}):([0-9]{2})(.[0-9]+)?(z|([+-][0-9]{2}:[0-9]{2}))$`
|
||||
)
|
||||
|
||||
var (
|
||||
dateTimeFormats = []string{RFC3339Micro, RFC3339Millis, time.RFC3339, time.RFC3339Nano, ISO8601LocalTime}
|
||||
rxDateTime = regexp.MustCompile(DateTimePattern)
|
||||
// MarshalFormat sets the time resolution format used for marshaling time (set to milliseconds)
|
||||
MarshalFormat = RFC3339Millis
|
||||
)
|
||||
|
||||
// ParseDateTime parses a string that represents an ISO8601 time or a unix epoch
|
||||
func ParseDateTime(data string) (DateTime, error) {
|
||||
if data == "" {
|
||||
return NewDateTime(), nil
|
||||
}
|
||||
var lastError error
|
||||
for _, layout := range dateTimeFormats {
|
||||
dd, err := time.Parse(layout, data)
|
||||
if err != nil {
|
||||
lastError = err
|
||||
continue
|
||||
}
|
||||
return DateTime(dd), nil
|
||||
}
|
||||
return DateTime{}, lastError
|
||||
}
|
||||
|
||||
// DateTime is a time but it serializes to ISO8601 format with millis
|
||||
// It knows how to read 3 different variations of a RFC3339 date time.
|
||||
// Most APIs we encounter want either millisecond or second precision times.
|
||||
// This just tries to make it worry-free.
|
||||
//
|
||||
// swagger:strfmt date-time
|
||||
type DateTime time.Time
|
||||
|
||||
// NewDateTime is a representation of zero value for DateTime type
|
||||
func NewDateTime() DateTime {
|
||||
return DateTime(time.Unix(0, 0).UTC())
|
||||
}
|
||||
|
||||
// String converts this time to a string
|
||||
func (t DateTime) String() string {
|
||||
return time.Time(t).Format(MarshalFormat)
|
||||
}
|
||||
|
||||
// MarshalText implements the text marshaller interface
|
||||
func (t DateTime) MarshalText() ([]byte, error) {
|
||||
return []byte(t.String()), nil
|
||||
}
|
||||
|
||||
// UnmarshalText implements the text unmarshaller interface
|
||||
func (t *DateTime) UnmarshalText(text []byte) error {
|
||||
tt, err := ParseDateTime(string(text))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
*t = tt
|
||||
return nil
|
||||
}
|
||||
|
||||
// Scan scans a DateTime value from database driver type.
|
||||
func (t *DateTime) Scan(raw interface{}) error {
|
||||
// TODO: case int64: and case float64: ?
|
||||
switch v := raw.(type) {
|
||||
case []byte:
|
||||
return t.UnmarshalText(v)
|
||||
case string:
|
||||
return t.UnmarshalText([]byte(v))
|
||||
case time.Time:
|
||||
*t = DateTime(v)
|
||||
case nil:
|
||||
*t = DateTime{}
|
||||
default:
|
||||
return fmt.Errorf("cannot sql.Scan() strfmt.DateTime from: %#v", v)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// Value converts DateTime to a primitive value ready to written to a database.
|
||||
func (t DateTime) Value() (driver.Value, error) {
|
||||
return driver.Value(t.String()), nil
|
||||
}
|
||||
|
||||
// MarshalJSON returns the DateTime as JSON
|
||||
func (t DateTime) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(time.Time(t).Format(MarshalFormat))
|
||||
}
|
||||
|
||||
// UnmarshalJSON sets the DateTime from JSON
|
||||
func (t *DateTime) UnmarshalJSON(data []byte) error {
|
||||
if string(data) == jsonNull {
|
||||
return nil
|
||||
}
|
||||
|
||||
var tstr string
|
||||
if err := json.Unmarshal(data, &tstr); err != nil {
|
||||
return err
|
||||
}
|
||||
tt, err := ParseDateTime(tstr)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
*t = tt
|
||||
return nil
|
||||
}
|
||||
|
||||
func (t DateTime) MarshalBSON() ([]byte, error) {
|
||||
return bson.Marshal(bson.M{"data": t.String()})
|
||||
}
|
||||
|
||||
func (t *DateTime) UnmarshalBSON(data []byte) error {
|
||||
var m bson.M
|
||||
if err := bson.Unmarshal(data, &m); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if data, ok := m["data"].(string); ok {
|
||||
rd, err := ParseDateTime(data)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
*t = rd
|
||||
return nil
|
||||
}
|
||||
|
||||
return errors.New("couldn't unmarshal bson bytes value as Date")
|
||||
}
|
||||
|
||||
// DeepCopyInto copies the receiver and writes its value into out.
|
||||
func (t *DateTime) DeepCopyInto(out *DateTime) {
|
||||
*out = *t
|
||||
}
|
||||
|
||||
// DeepCopy copies the receiver into a new DateTime.
|
||||
func (t *DateTime) DeepCopy() *DateTime {
|
||||
if t == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(DateTime)
|
||||
t.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
Reference in New Issue
Block a user