Update go dependencies

This commit is contained in:
Manuel de Brito Fontes 2017-11-12 14:14:23 -03:00
parent a858c549d9
commit f3bde94d68
643 changed files with 14296 additions and 19354 deletions

View file

@ -28,6 +28,7 @@ type SimpleSchema struct {
Items *Items `json:"items,omitempty"`
CollectionFormat string `json:"collectionFormat,omitempty"`
Default interface{} `json:"default,omitempty"`
Example interface{} `json:"example,omitempty"`
}
func (s *SimpleSchema) TypeName() string {

View file

@ -1 +1,3 @@
secrets.yml
vendor
Godeps

View file

@ -17,8 +17,8 @@ package swag
import (
"io/ioutil"
"os"
"path/filepath"
"path"
"path/filepath"
"runtime"
"testing"
@ -75,7 +75,7 @@ func TestFindPackage(t *testing.T) {
os.RemoveAll(pth2)
}()
searchPath := pth + string(filepath.ListSeparator) + pth2
searchPath := pth + string(filepath.ListSeparator) + pth2
// finds package when real name mentioned
pkg := FindInSearchPath(searchPath, "foo/bar")
assert.NotEmpty(t, pkg)

View file

@ -40,6 +40,7 @@ var commonInitialisms = map[string]bool{
"IP": true,
"JSON": true,
"LHS": true,
"OAI": true,
"QPS": true,
"RAM": true,
"RHS": true,
@ -163,8 +164,8 @@ func split(str string) (words []string) {
// Split when uppercase is found (needed for Snake)
str = rex1.ReplaceAllString(str, " $1")
// check if consecutive single char things make up an initialism
// check if consecutive single char things make up an initialism
for _, k := range initialisms {
str = strings.Replace(str, rex1.ReplaceAllString(k, " $1"), " "+k, -1)
}
@ -189,10 +190,47 @@ func lower(str string) string {
return strings.ToLower(trim(str))
}
// Camelize an uppercased word
func Camelize(word string) (camelized string) {
for pos, ru := range word {
if pos > 0 {
camelized += string(unicode.ToLower(ru))
} else {
camelized += string(unicode.ToUpper(ru))
}
}
return
}
// ToFileName lowercases and underscores a go type name
func ToFileName(name string) string {
var out []string
for _, w := range split(name) {
cml := trim(name)
// Camelize any capital word preceding a reserved keyword ("initialism")
// thus, upper-cased words preceding a common initialism will get separated
// e.g: ELBHTTPLoadBalancer becomes elb_http_load_balancer
rexPrevious := regexp.MustCompile(`(?P<word>\p{Lu}{2,})(?:HTTP|OAI)`)
cml = rexPrevious.ReplaceAllStringFunc(cml, func(match string) (replaceInMatch string) {
for _, m := range rexPrevious.FindAllStringSubmatch(match, -1) { // [ match submatch ]
if m[1] != "" {
replaceInMatch = strings.Replace(m[0], m[1], Camelize(m[1]), -1)
}
}
return
})
// Pre-camelize reserved keywords ("initialisms") to avoid unnecessary hyphenization
for _, k := range initialisms {
cml = strings.Replace(cml, k, Camelize(k), -1)
}
// Camelize other capital words to avoid unnecessary hyphenization
rexCase := regexp.MustCompile(`(\p{Lu}{2,})`)
cml = rexCase.ReplaceAllStringFunc(cml, Camelize)
// Final split with hyphens
for _, w := range split(cml) {
out = append(out, lower(w))
}
return strings.Join(out, "_")

View file

@ -39,6 +39,7 @@ func TestToGoName(t *testing.T) {
{"findThingById", "FindThingByID"},
{"日本語sample 2 Text", "X日本語sample2Text"},
{"日本語findThingById", "X日本語findThingByID"},
{"findTHINGSbyID", "FindTHINGSbyID"},
}
for k := range commonInitialisms {
@ -122,8 +123,16 @@ func TestToFileName(t *testing.T) {
samples := []translationSample{
{"SampleText", "sample_text"},
{"FindThingByID", "find_thing_by_id"},
{"CAPWD.folwdBYlc", "capwd_folwd_bylc"},
{"CAPWDfolwdBYlc", "capwdfolwd_bylc"},
{"CAP_WD_folwdBYlc", "cap_wd_folwd_bylc"},
{"TypeOAI_alias", "type_oai_alias"},
{"Type_OAI_alias", "type_oai_alias"},
{"Type_OAIAlias", "type_oai_alias"},
{"ELB.HTTPLoadBalancer", "elb_http_load_balancer"},
{"elbHTTPLoadBalancer", "elb_http_load_balancer"},
{"ELBHTTPLoadBalancer", "elb_http_load_balancer"},
}
for k := range commonInitialisms {
samples = append(samples,
translationSample{"Sample" + k + "Text", "sample_" + lower(k) + "_text"},