add global securitydefinitions to parameters set in router

This commit is contained in:
franzwilhelm 2017-05-13 15:13:56 +02:00
parent 1a79d6dcca
commit 208c3aa697
1 changed files with 7 additions and 0 deletions

View File

@ -184,6 +184,13 @@ func GenerateDocs(curpath string) {
rootapi.Schemes = strings.Split(strings.TrimSpace(s[len("@Schemes"):]), ",")
} else if strings.HasPrefix(s, "@Host") {
rootapi.Host = strings.TrimSpace(s[len("@Host"):])
} else if strings.HasPrefix(s, "@SecurityDefinition") {
if len(rootapi.SecurityDefinitions) == 0 {
rootapi.SecurityDefinitions = make(map[string]swagger.Security)
}
fullString := strings.TrimSpace(s[len("@SecurityDefinition"):])
e := strings.SplitN(fullString, " ", 4)
rootapi.SecurityDefinitions[e[0]] = swagger.Security{Type: e[1], Name: e[2], In: e[3]}
}
}
}