feat: apply separate security requirement object for each route

Signed-off-by: soasurs <soasurs@gmail.com>
This commit is contained in:
soasurs 2022-04-15 12:59:22 +08:00
parent 10c670eac2
commit a0743019ac

View File

@ -59,7 +59,7 @@ func applyGenerate(p *plugin.Plugin, host string, basePath string) (*swaggerObje
newSecDefValue.In = "header"
s.SecurityDefinitions["apiKey"] = newSecDefValue
s.Security = append(s.Security, swaggerSecurityRequirementObject{"apiKey": []string{}})
//s.Security = append(s.Security, swaggerSecurityRequirementObject{"apiKey": []string{}})
requestResponseRefs := refMap{}
renderServiceRoutes(p.Api.Service, p.Api.Service.Groups, s.Paths, requestResponseRefs)
@ -233,6 +233,10 @@ func renderServiceRoutes(service spec.Service, groups []spec.Group, paths swagge
operationObject.Description = strings.ReplaceAll(operationObject.Description, "\"", "")
if group.Annotation.Properties["jwt"] != "" {
operationObject.Security = &[]swaggerSecurityRequirementObject{{"apiKey": []string{}}}
}
switch strings.ToUpper(route.Method) {
case http.MethodGet:
pathItemObject.Get = operationObject