mirror of
https://github.com/go-gitea/gitea.git
synced 2025-08-18 14:44:06 +09: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
61
vendor/github.com/go-swagger/go-swagger/generator/config.go
generated
vendored
Normal file
61
vendor/github.com/go-swagger/go-swagger/generator/config.go
generated
vendored
Normal file
@ -0,0 +1,61 @@
|
||||
package generator
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/spf13/viper"
|
||||
)
|
||||
|
||||
// LanguageDefinition in the configuration file.
|
||||
type LanguageDefinition struct {
|
||||
Layout SectionOpts `mapstructure:"layout"`
|
||||
}
|
||||
|
||||
// ConfigureOpts for generation
|
||||
func (d *LanguageDefinition) ConfigureOpts(opts *GenOpts) error {
|
||||
opts.Sections = d.Layout
|
||||
if opts.LanguageOpts == nil {
|
||||
opts.LanguageOpts = GoLangOpts()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// LanguageConfig structure that is obtained from parsing a config file
|
||||
type LanguageConfig map[string]LanguageDefinition
|
||||
|
||||
// ReadConfig at the specified path, when no path is specified it will look into
|
||||
// the current directory and load a .swagger.{yml,json,hcl,toml,properties} file
|
||||
// Returns a viper config or an error
|
||||
func ReadConfig(fpath string) (*viper.Viper, error) {
|
||||
v := viper.New()
|
||||
if fpath != "" {
|
||||
if !fileExists(fpath, "") {
|
||||
return nil, fmt.Errorf("can't find file for %q", fpath)
|
||||
}
|
||||
file, err := os.Open(fpath)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer func() { _ = file.Close() }()
|
||||
ext := filepath.Ext(fpath)
|
||||
if len(ext) > 0 {
|
||||
ext = ext[1:]
|
||||
}
|
||||
v.SetConfigType(ext)
|
||||
if err := v.ReadConfig(file); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return v, nil
|
||||
}
|
||||
|
||||
v.SetConfigName(".swagger")
|
||||
v.AddConfigPath(".")
|
||||
if err := v.ReadInConfig(); err != nil {
|
||||
if _, ok := err.(viper.UnsupportedConfigError); !ok && v.ConfigFileUsed() != "" {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
return v, nil
|
||||
}
|
Reference in New Issue
Block a user