forked from forgejo/forgejo
[Vendor] update go-swagger v0.21.0 -> v0.25.0 (#12670)
* Update go-swagger * vendor
This commit is contained in:
parent
66843f2237
commit
3270e7a443
350 changed files with 26353 additions and 5552 deletions
35
vendor/google.golang.org/protobuf/encoding/prototext/encode.go
generated
vendored
35
vendor/google.golang.org/protobuf/encoding/prototext/encode.go
generated
vendored
|
@ -14,10 +14,11 @@ import (
|
|||
"google.golang.org/protobuf/internal/encoding/messageset"
|
||||
"google.golang.org/protobuf/internal/encoding/text"
|
||||
"google.golang.org/protobuf/internal/errors"
|
||||
"google.golang.org/protobuf/internal/fieldnum"
|
||||
"google.golang.org/protobuf/internal/flags"
|
||||
"google.golang.org/protobuf/internal/genid"
|
||||
"google.golang.org/protobuf/internal/mapsort"
|
||||
"google.golang.org/protobuf/internal/pragma"
|
||||
"google.golang.org/protobuf/internal/strs"
|
||||
"google.golang.org/protobuf/proto"
|
||||
pref "google.golang.org/protobuf/reflect/protoreflect"
|
||||
"google.golang.org/protobuf/reflect/protoregistry"
|
||||
|
@ -55,6 +56,15 @@ type MarshalOptions struct {
|
|||
// Indent can only be composed of space or tab characters.
|
||||
Indent string
|
||||
|
||||
// EmitASCII specifies whether to format strings and bytes as ASCII only
|
||||
// as opposed to using UTF-8 encoding when possible.
|
||||
EmitASCII bool
|
||||
|
||||
// allowInvalidUTF8 specifies whether to permit the encoding of strings
|
||||
// with invalid UTF-8. This is unexported as it is intended to only
|
||||
// be specified by the Format method.
|
||||
allowInvalidUTF8 bool
|
||||
|
||||
// AllowPartial allows messages that have missing required fields to marshal
|
||||
// without returning an error. If AllowPartial is false (the default),
|
||||
// Marshal will return error if there are any missing required fields.
|
||||
|
@ -81,6 +91,7 @@ func (o MarshalOptions) Format(m proto.Message) string {
|
|||
if m == nil || !m.ProtoReflect().IsValid() {
|
||||
return "<nil>" // invalid syntax, but okay since this is for debugging
|
||||
}
|
||||
o.allowInvalidUTF8 = true
|
||||
o.AllowPartial = true
|
||||
o.EmitUnknown = true
|
||||
b, _ := o.Marshal(m)
|
||||
|
@ -91,7 +102,13 @@ func (o MarshalOptions) Format(m proto.Message) string {
|
|||
// MarshalOptions object. Do not depend on the output being stable. It may
|
||||
// change over time across different versions of the program.
|
||||
func (o MarshalOptions) Marshal(m proto.Message) ([]byte, error) {
|
||||
const outputASCII = false
|
||||
return o.marshal(m)
|
||||
}
|
||||
|
||||
// marshal is a centralized function that all marshal operations go through.
|
||||
// For profiling purposes, avoid changing the name of this function or
|
||||
// introducing other code paths for marshal that do not go through this.
|
||||
func (o MarshalOptions) marshal(m proto.Message) ([]byte, error) {
|
||||
var delims = [2]byte{'{', '}'}
|
||||
|
||||
if o.Multiline && o.Indent == "" {
|
||||
|
@ -101,7 +118,7 @@ func (o MarshalOptions) Marshal(m proto.Message) ([]byte, error) {
|
|||
o.Resolver = protoregistry.GlobalTypes
|
||||
}
|
||||
|
||||
internalEnc, err := text.NewEncoder(o.Indent, delims, outputASCII)
|
||||
internalEnc, err := text.NewEncoder(o.Indent, delims, o.EmitASCII)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -145,7 +162,7 @@ func (e encoder) marshalMessage(m pref.Message, inclDelims bool) error {
|
|||
}
|
||||
|
||||
// Handle Any expansion.
|
||||
if messageDesc.FullName() == "google.protobuf.Any" {
|
||||
if messageDesc.FullName() == genid.Any_message_fullname {
|
||||
if e.marshalAny(m) {
|
||||
return nil
|
||||
}
|
||||
|
@ -215,7 +232,7 @@ func (e encoder) marshalSingular(val pref.Value, fd pref.FieldDescriptor) error
|
|||
|
||||
case pref.StringKind:
|
||||
s := val.String()
|
||||
if !utf8.ValidString(s) {
|
||||
if !e.opts.allowInvalidUTF8 && strs.EnforceUTF8(fd) && !utf8.ValidString(s) {
|
||||
return errors.InvalidUTF8(string(fd.FullName()))
|
||||
}
|
||||
e.WriteString(s)
|
||||
|
@ -278,13 +295,13 @@ func (e encoder) marshalMap(name string, mmap pref.Map, fd pref.FieldDescriptor)
|
|||
e.StartMessage()
|
||||
defer e.EndMessage()
|
||||
|
||||
e.WriteName("key")
|
||||
e.WriteName(string(genid.MapEntry_Key_field_name))
|
||||
err = e.marshalSingular(key.Value(), fd.MapKey())
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
|
||||
e.WriteName("value")
|
||||
e.WriteName(string(genid.MapEntry_Value_field_name))
|
||||
err = e.marshalSingular(val, fd.MapValue())
|
||||
if err != nil {
|
||||
return false
|
||||
|
@ -382,7 +399,7 @@ func (e encoder) marshalUnknown(b []byte) {
|
|||
func (e encoder) marshalAny(any pref.Message) bool {
|
||||
// Construct the embedded message.
|
||||
fds := any.Descriptor().Fields()
|
||||
fdType := fds.ByNumber(fieldnum.Any_TypeUrl)
|
||||
fdType := fds.ByNumber(genid.Any_TypeUrl_field_number)
|
||||
typeURL := any.Get(fdType).String()
|
||||
mt, err := e.opts.Resolver.FindMessageByURL(typeURL)
|
||||
if err != nil {
|
||||
|
@ -391,7 +408,7 @@ func (e encoder) marshalAny(any pref.Message) bool {
|
|||
m := mt.New().Interface()
|
||||
|
||||
// Unmarshal bytes into embedded message.
|
||||
fdValue := fds.ByNumber(fieldnum.Any_Value)
|
||||
fdValue := fds.ByNumber(genid.Any_Value_field_number)
|
||||
value := any.Get(fdValue)
|
||||
err = proto.UnmarshalOptions{
|
||||
AllowPartial: true,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue