mirror of
https://gitcode.com/gitea/gitea.git
synced 2025-07-03 19:28:36 +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
127
vendor/github.com/go-openapi/spec/responses.go
generated
vendored
Normal file
127
vendor/github.com/go-openapi/spec/responses.go
generated
vendored
Normal file
@ -0,0 +1,127 @@
|
||||
// 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 spec
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"reflect"
|
||||
"strconv"
|
||||
|
||||
"github.com/go-openapi/swag"
|
||||
)
|
||||
|
||||
// Responses is a container for the expected responses of an operation.
|
||||
// The container maps a HTTP response code to the expected response.
|
||||
// It is not expected from the documentation to necessarily cover all possible HTTP response codes,
|
||||
// since they may not be known in advance. However, it is expected from the documentation to cover
|
||||
// a successful operation response and any known errors.
|
||||
//
|
||||
// The `default` can be used a default response object for all HTTP codes that are not covered
|
||||
// individually by the specification.
|
||||
//
|
||||
// The `Responses Object` MUST contain at least one response code, and it SHOULD be the response
|
||||
// for a successful operation call.
|
||||
//
|
||||
// For more information: http://goo.gl/8us55a#responsesObject
|
||||
type Responses struct {
|
||||
VendorExtensible
|
||||
ResponsesProps
|
||||
}
|
||||
|
||||
// JSONLookup implements an interface to customize json pointer lookup
|
||||
func (r Responses) JSONLookup(token string) (interface{}, error) {
|
||||
if token == "default" {
|
||||
return r.Default, nil
|
||||
}
|
||||
if ex, ok := r.Extensions[token]; ok {
|
||||
return &ex, nil
|
||||
}
|
||||
if i, err := strconv.Atoi(token); err == nil {
|
||||
if scr, ok := r.StatusCodeResponses[i]; ok {
|
||||
return scr, nil
|
||||
}
|
||||
}
|
||||
return nil, fmt.Errorf("object has no field %q", token)
|
||||
}
|
||||
|
||||
// UnmarshalJSON hydrates this items instance with the data from JSON
|
||||
func (r *Responses) UnmarshalJSON(data []byte) error {
|
||||
if err := json.Unmarshal(data, &r.ResponsesProps); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := json.Unmarshal(data, &r.VendorExtensible); err != nil {
|
||||
return err
|
||||
}
|
||||
if reflect.DeepEqual(ResponsesProps{}, r.ResponsesProps) {
|
||||
r.ResponsesProps = ResponsesProps{}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// MarshalJSON converts this items object to JSON
|
||||
func (r Responses) MarshalJSON() ([]byte, error) {
|
||||
b1, err := json.Marshal(r.ResponsesProps)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
b2, err := json.Marshal(r.VendorExtensible)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
concated := swag.ConcatJSON(b1, b2)
|
||||
return concated, nil
|
||||
}
|
||||
|
||||
// ResponsesProps describes all responses for an operation.
|
||||
// It tells what is the default response and maps all responses with a
|
||||
// HTTP status code.
|
||||
type ResponsesProps struct {
|
||||
Default *Response
|
||||
StatusCodeResponses map[int]Response
|
||||
}
|
||||
|
||||
// MarshalJSON marshals responses as JSON
|
||||
func (r ResponsesProps) MarshalJSON() ([]byte, error) {
|
||||
toser := map[string]Response{}
|
||||
if r.Default != nil {
|
||||
toser["default"] = *r.Default
|
||||
}
|
||||
for k, v := range r.StatusCodeResponses {
|
||||
toser[strconv.Itoa(k)] = v
|
||||
}
|
||||
return json.Marshal(toser)
|
||||
}
|
||||
|
||||
// UnmarshalJSON unmarshals responses from JSON
|
||||
func (r *ResponsesProps) UnmarshalJSON(data []byte) error {
|
||||
var res map[string]Response
|
||||
if err := json.Unmarshal(data, &res); err != nil {
|
||||
return nil
|
||||
}
|
||||
if v, ok := res["default"]; ok {
|
||||
r.Default = &v
|
||||
delete(res, "default")
|
||||
}
|
||||
for k, v := range res {
|
||||
if nk, err := strconv.Atoi(k); err == nil {
|
||||
if r.StatusCodeResponses == nil {
|
||||
r.StatusCodeResponses = map[int]Response{}
|
||||
}
|
||||
r.StatusCodeResponses[nk] = v
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
Reference in New Issue
Block a user