mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-11-08 00:19:32 -06:00
[chore] update go dependencies (#4304)
- github.com/KimMachineGun/automemlimit v0.7.2 => v0.7.3
- github.com/gin-contrib/cors v1.7.5 => v1.7.6
- github.com/minio/minio-go/v7 v7.0.92 => v7.0.94
- github.com/spf13/cast v1.8.0 => v1.9.2
- github.com/uptrace/bun{,/*} v1.2.11 => v1.2.14
- golang.org/x/image v0.27.0 => v0.28.0
- golang.org/x/net v0.40.0 => v0.41.0
- code.superseriousbusiness.org/go-swagger v0.31.0-gts-go1.23-fix => v0.32.3-gts-go1.23-fix
Reviewed-on: https://codeberg.org/superseriousbusiness/gotosocial/pulls/4304
Co-authored-by: kim <grufwub@gmail.com>
Co-committed-by: kim <grufwub@gmail.com>
This commit is contained in:
parent
7712885038
commit
8b0ea56027
294 changed files with 139999 additions and 21873 deletions
24
vendor/github.com/go-swagger/go-swagger/cmd/swagger/commands/generate/spec.go
generated
vendored
24
vendor/github.com/go-swagger/go-swagger/cmd/swagger/commands/generate/spec.go
generated
vendored
|
|
@ -30,17 +30,18 @@ import (
|
|||
|
||||
// SpecFile command to generate a swagger spec from a go application
|
||||
type SpecFile struct {
|
||||
WorkDir string `long:"work-dir" short:"w" description:"the base path to use" default:"."`
|
||||
BuildTags string `long:"tags" short:"t" description:"build tags" default:""`
|
||||
ScanModels bool `long:"scan-models" short:"m" description:"includes models that were annotated with 'swagger:model'"`
|
||||
Compact bool `long:"compact" description:"when present, doesn't prettify the json"`
|
||||
Output flags.Filename `long:"output" short:"o" description:"the file to write to"`
|
||||
Input flags.Filename `long:"input" short:"i" description:"an input swagger file with which to merge"`
|
||||
Include []string `long:"include" short:"c" description:"include packages matching pattern"`
|
||||
Exclude []string `long:"exclude" short:"x" description:"exclude packages matching pattern"`
|
||||
IncludeTags []string `long:"include-tag" short:"" description:"include routes having specified tags (can be specified many times)"`
|
||||
ExcludeTags []string `long:"exclude-tag" short:"" description:"exclude routes having specified tags (can be specified many times)"`
|
||||
ExcludeDeps bool `long:"exclude-deps" short:"" description:"exclude all dependencies of project"`
|
||||
WorkDir string `long:"work-dir" short:"w" description:"the base path to use" default:"."`
|
||||
BuildTags string `long:"tags" short:"t" description:"build tags" default:""`
|
||||
ScanModels bool `long:"scan-models" short:"m" description:"includes models that were annotated with 'swagger:model'"`
|
||||
Compact bool `long:"compact" description:"when present, doesn't prettify the json"`
|
||||
Output flags.Filename `long:"output" short:"o" description:"the file to write to"`
|
||||
Input flags.Filename `long:"input" short:"i" description:"an input swagger file with which to merge"`
|
||||
Include []string `long:"include" short:"c" description:"include packages matching pattern"`
|
||||
Exclude []string `long:"exclude" short:"x" description:"exclude packages matching pattern"`
|
||||
IncludeTags []string `long:"include-tag" short:"" description:"include routes having specified tags (can be specified many times)"`
|
||||
ExcludeTags []string `long:"exclude-tag" short:"" description:"exclude routes having specified tags (can be specified many times)"`
|
||||
ExcludeDeps bool `long:"exclude-deps" short:"" description:"exclude all dependencies of project"`
|
||||
SetXNullableForPointers bool `long:"nullable-pointers" short:"n" description:"set x-nullable extension to true automatically for fields of pointer types without 'omitempty'"`
|
||||
}
|
||||
|
||||
// Execute runs this command
|
||||
|
|
@ -65,6 +66,7 @@ func (s *SpecFile) Execute(args []string) error {
|
|||
opts.IncludeTags = s.IncludeTags
|
||||
opts.ExcludeTags = s.ExcludeTags
|
||||
opts.ExcludeDeps = s.ExcludeDeps
|
||||
opts.SetXNullableForPointers = s.SetXNullableForPointers
|
||||
swspec, err := codescan.Run(&opts)
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
|
|||
69
vendor/github.com/go-swagger/go-swagger/codescan/application.go
generated
vendored
69
vendor/github.com/go-swagger/go-swagger/codescan/application.go
generated
vendored
|
|
@ -42,16 +42,17 @@ const (
|
|||
|
||||
// Options for the scanner
|
||||
type Options struct {
|
||||
Packages []string
|
||||
InputSpec *spec.Swagger
|
||||
ScanModels bool
|
||||
WorkDir string
|
||||
BuildTags string
|
||||
ExcludeDeps bool
|
||||
Include []string
|
||||
Exclude []string
|
||||
IncludeTags []string
|
||||
ExcludeTags []string
|
||||
Packages []string
|
||||
InputSpec *spec.Swagger
|
||||
ScanModels bool
|
||||
WorkDir string
|
||||
BuildTags string
|
||||
ExcludeDeps bool
|
||||
Include []string
|
||||
Exclude []string
|
||||
IncludeTags []string
|
||||
ExcludeTags []string
|
||||
SetXNullableForPointers bool
|
||||
}
|
||||
|
||||
type scanCtx struct {
|
||||
|
|
@ -94,7 +95,7 @@ func newScanCtx(opts *Options) (*scanCtx, error) {
|
|||
|
||||
app, err := newTypeIndex(pkgs, opts.ExcludeDeps,
|
||||
sliceToSet(opts.IncludeTags), sliceToSet(opts.ExcludeTags),
|
||||
opts.Include, opts.Exclude)
|
||||
opts.Include, opts.Exclude, opts.SetXNullableForPointers)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
@ -418,16 +419,17 @@ func (s *scanCtx) FindEnumValues(pkg *packages.Package, enumName string) (list [
|
|||
return list, descList, true
|
||||
}
|
||||
|
||||
func newTypeIndex(pkgs []*packages.Package, excludeDeps bool, includeTags, excludeTags map[string]bool, includePkgs, excludePkgs []string) (*typeIndex, error) {
|
||||
func newTypeIndex(pkgs []*packages.Package, excludeDeps bool, includeTags, excludeTags map[string]bool, includePkgs, excludePkgs []string, setXNullableForPointers bool) (*typeIndex, error) {
|
||||
ac := &typeIndex{
|
||||
AllPackages: make(map[string]*packages.Package),
|
||||
Models: make(map[*ast.Ident]*entityDecl),
|
||||
ExtraModels: make(map[*ast.Ident]*entityDecl),
|
||||
excludeDeps: excludeDeps,
|
||||
includeTags: includeTags,
|
||||
excludeTags: excludeTags,
|
||||
includePkgs: includePkgs,
|
||||
excludePkgs: excludePkgs,
|
||||
AllPackages: make(map[string]*packages.Package),
|
||||
Models: make(map[*ast.Ident]*entityDecl),
|
||||
ExtraModels: make(map[*ast.Ident]*entityDecl),
|
||||
excludeDeps: excludeDeps,
|
||||
includeTags: includeTags,
|
||||
excludeTags: excludeTags,
|
||||
includePkgs: includePkgs,
|
||||
excludePkgs: excludePkgs,
|
||||
setXNullableForPointers: setXNullableForPointers,
|
||||
}
|
||||
if err := ac.build(pkgs); err != nil {
|
||||
return nil, err
|
||||
|
|
@ -436,19 +438,20 @@ func newTypeIndex(pkgs []*packages.Package, excludeDeps bool, includeTags, exclu
|
|||
}
|
||||
|
||||
type typeIndex struct {
|
||||
AllPackages map[string]*packages.Package
|
||||
Models map[*ast.Ident]*entityDecl
|
||||
ExtraModels map[*ast.Ident]*entityDecl
|
||||
Meta []metaSection
|
||||
Routes []parsedPathContent
|
||||
Operations []parsedPathContent
|
||||
Parameters []*entityDecl
|
||||
Responses []*entityDecl
|
||||
excludeDeps bool
|
||||
includeTags map[string]bool
|
||||
excludeTags map[string]bool
|
||||
includePkgs []string
|
||||
excludePkgs []string
|
||||
AllPackages map[string]*packages.Package
|
||||
Models map[*ast.Ident]*entityDecl
|
||||
ExtraModels map[*ast.Ident]*entityDecl
|
||||
Meta []metaSection
|
||||
Routes []parsedPathContent
|
||||
Operations []parsedPathContent
|
||||
Parameters []*entityDecl
|
||||
Responses []*entityDecl
|
||||
excludeDeps bool
|
||||
includeTags map[string]bool
|
||||
excludeTags map[string]bool
|
||||
includePkgs []string
|
||||
excludePkgs []string
|
||||
setXNullableForPointers bool
|
||||
}
|
||||
|
||||
func (a *typeIndex) build(pkgs []*packages.Package) error {
|
||||
|
|
|
|||
2
vendor/github.com/go-swagger/go-swagger/codescan/parameters.go
generated
vendored
2
vendor/github.com/go-swagger/go-swagger/codescan/parameters.go
generated
vendored
|
|
@ -339,7 +339,7 @@ func (p *parameterBuilder) buildFromStruct(decl *entityDecl, tpe *types.Struct,
|
|||
continue
|
||||
}
|
||||
|
||||
name, ignore, _, err := parseJSONTag(afld)
|
||||
name, ignore, _, _, err := parseJSONTag(afld)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
|||
2
vendor/github.com/go-swagger/go-swagger/codescan/responses.go
generated
vendored
2
vendor/github.com/go-swagger/go-swagger/codescan/responses.go
generated
vendored
|
|
@ -333,7 +333,7 @@ func (r *responseBuilder) buildFromStruct(decl *entityDecl, tpe *types.Struct, r
|
|||
continue
|
||||
}
|
||||
|
||||
name, ignore, _, err := parseJSONTag(afld)
|
||||
name, ignore, _, _, err := parseJSONTag(afld)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
|||
39
vendor/github.com/go-swagger/go-swagger/codescan/schema.go
generated
vendored
39
vendor/github.com/go-swagger/go-swagger/codescan/schema.go
generated
vendored
|
|
@ -365,6 +365,10 @@ func (s *schemaBuilder) buildFromType(tpe types.Type, tgt swaggerTypable) error
|
|||
return s.buildFromType(titpe.Underlying(), tgt)
|
||||
}
|
||||
|
||||
if titpe.TypeArgs() != nil && titpe.TypeArgs().Len() > 0 {
|
||||
return s.buildFromType(titpe.Underlying(), tgt)
|
||||
}
|
||||
|
||||
switch utitpe := tpe.Underlying().(type) {
|
||||
case *types.Struct:
|
||||
if decl, ok := s.ctx.FindModel(tio.Pkg().Path(), tio.Name()); ok {
|
||||
|
|
@ -407,7 +411,7 @@ func (s *schemaBuilder) buildFromType(tpe types.Type, tgt swaggerTypable) error
|
|||
}
|
||||
|
||||
if defaultName, ok := defaultName(cmt); ok {
|
||||
debugLog(defaultName)
|
||||
debugLog(defaultName) //nolint:govet
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
@ -651,6 +655,12 @@ func (s *schemaBuilder) buildFromInterface(decl *entityDecl, it *types.Interface
|
|||
ps.AddExtension("x-go-name", fld.Name())
|
||||
}
|
||||
|
||||
if s.ctx.app.setXNullableForPointers {
|
||||
if _, isPointer := fld.Type().(*types.Signature).Results().At(0).Type().(*types.Pointer); isPointer && (ps.Extensions == nil || (ps.Extensions["x-nullable"] == nil && ps.Extensions["x-isnullable"] == nil)) {
|
||||
ps.AddExtension("x-nullable", true)
|
||||
}
|
||||
}
|
||||
|
||||
seen[name] = fld.Name()
|
||||
tgt.Properties[name] = ps
|
||||
}
|
||||
|
|
@ -716,7 +726,7 @@ func (s *schemaBuilder) buildFromStruct(decl *entityDecl, st *types.Struct, sche
|
|||
continue
|
||||
}
|
||||
|
||||
_, ignore, _, err := parseJSONTag(afld)
|
||||
_, ignore, _, _, err := parseJSONTag(afld)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
@ -816,7 +826,7 @@ func (s *schemaBuilder) buildFromStruct(decl *entityDecl, st *types.Struct, sche
|
|||
continue
|
||||
}
|
||||
|
||||
name, ignore, isString, err := parseJSONTag(afld)
|
||||
name, ignore, isString, omitEmpty, err := parseJSONTag(afld)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
@ -853,6 +863,13 @@ func (s *schemaBuilder) buildFromStruct(decl *entityDecl, st *types.Struct, sche
|
|||
addExtension(&ps.VendorExtensible, "x-go-name", fld.Name())
|
||||
}
|
||||
|
||||
if s.ctx.app.setXNullableForPointers {
|
||||
if _, isPointer := fld.Type().(*types.Pointer); isPointer && !omitEmpty &&
|
||||
(ps.Extensions == nil || (ps.Extensions["x-nullable"] == nil && ps.Extensions["x-isnullable"] == nil)) {
|
||||
ps.AddExtension("x-nullable", true)
|
||||
}
|
||||
}
|
||||
|
||||
// we have 2 cases:
|
||||
// 1. field with different name override tag
|
||||
// 2. field with different name removes tag
|
||||
|
|
@ -1106,17 +1123,17 @@ func (t tagOptions) Name() string {
|
|||
return t[0]
|
||||
}
|
||||
|
||||
func parseJSONTag(field *ast.Field) (name string, ignore bool, isString bool, err error) {
|
||||
func parseJSONTag(field *ast.Field) (name string, ignore, isString, omitEmpty bool, err error) {
|
||||
if len(field.Names) > 0 {
|
||||
name = field.Names[0].Name
|
||||
}
|
||||
if field.Tag == nil || len(strings.TrimSpace(field.Tag.Value)) == 0 {
|
||||
return name, false, false, nil
|
||||
return name, false, false, false, nil
|
||||
}
|
||||
|
||||
tv, err := strconv.Unquote(field.Tag.Value)
|
||||
if err != nil {
|
||||
return name, false, false, err
|
||||
return name, false, false, false, err
|
||||
}
|
||||
|
||||
if strings.TrimSpace(tv) != "" {
|
||||
|
|
@ -1129,16 +1146,18 @@ func parseJSONTag(field *ast.Field) (name string, ignore bool, isString bool, er
|
|||
isString = isFieldStringable(field.Type)
|
||||
}
|
||||
|
||||
omitEmpty = jsonParts.Contain("omitempty")
|
||||
|
||||
switch jsonParts.Name() {
|
||||
case "-":
|
||||
return name, true, isString, nil
|
||||
return name, true, isString, omitEmpty, nil
|
||||
case "":
|
||||
return name, false, isString, nil
|
||||
return name, false, isString, omitEmpty, nil
|
||||
default:
|
||||
return jsonParts.Name(), false, isString, nil
|
||||
return jsonParts.Name(), false, isString, omitEmpty, nil
|
||||
}
|
||||
}
|
||||
return name, false, false, nil
|
||||
return name, false, false, false, nil
|
||||
}
|
||||
|
||||
// isFieldStringable check if the field type is a scalar. If the field type is
|
||||
|
|
|
|||
2
vendor/github.com/go-swagger/go-swagger/generator/operation.go
generated
vendored
2
vendor/github.com/go-swagger/go-swagger/generator/operation.go
generated
vendored
|
|
@ -1258,7 +1258,7 @@ func (b *codeGenOpBuilder) analyzeTags() (string, []string, bool) {
|
|||
return tag, intersected, len(filter) == 0 || len(filter) > 0 && len(intersected) > 0
|
||||
}
|
||||
|
||||
var versionedPkgRex = regexp.MustCompile(`(?i)(v)([0-9]+)`)
|
||||
var versionedPkgRex = regexp.MustCompile(`(?i)^(v)([0-9]+)$`)
|
||||
|
||||
func maxInt(a, b int) int {
|
||||
if a > b {
|
||||
|
|
|
|||
2
vendor/github.com/go-swagger/go-swagger/generator/shared.go
generated
vendored
2
vendor/github.com/go-swagger/go-swagger/generator/shared.go
generated
vendored
|
|
@ -280,7 +280,7 @@ type TemplateOpts struct {
|
|||
Target string `mapstructure:"target"`
|
||||
FileName string `mapstructure:"file_name"`
|
||||
SkipExists bool `mapstructure:"skip_exists"`
|
||||
SkipFormat bool `mapstructure:"skip_format"`
|
||||
SkipFormat bool `mapstructure:"skip_format"` // not a feature, but for debugging. generated code before formatting might not work because of unused imports.
|
||||
}
|
||||
|
||||
// SectionOpts allows for specifying options to customize the templates used for generation
|
||||
|
|
|
|||
2
vendor/github.com/go-swagger/go-swagger/generator/types.go
generated
vendored
2
vendor/github.com/go-swagger/go-swagger/generator/types.go
generated
vendored
|
|
@ -24,8 +24,8 @@ import (
|
|||
"github.com/go-openapi/loads"
|
||||
"github.com/go-openapi/spec"
|
||||
"github.com/go-openapi/swag"
|
||||
"github.com/go-viper/mapstructure/v2"
|
||||
"github.com/kr/pretty"
|
||||
"github.com/mitchellh/mapstructure"
|
||||
)
|
||||
|
||||
const (
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue