addScopeDescription generates and adds required scopes to the scheme's description.
(scopes []*expr.ScopeExpr, sd *SecurityDefinition)
| 123 | |
| 124 | // addScopeDescription generates and adds required scopes to the scheme's description. |
| 125 | func addScopeDescription(scopes []*expr.ScopeExpr, sd *SecurityDefinition) { |
| 126 | // Generate scopes to add to description |
| 127 | lines := make([]string, 0, len(scopes)) |
| 128 | |
| 129 | for _, scope := range scopes { |
| 130 | lines = append(lines, fmt.Sprintf(" * `%s`: %s", scope.Name, scope.Description)) |
| 131 | } |
| 132 | // Add scope description only if scopes are defined |
| 133 | if len(lines) > 0 { |
| 134 | if sd.Description != "" { |
| 135 | sd.Description += "\n" |
| 136 | } |
| 137 | sd.Description += fmt.Sprintf("\n**Security Scopes**:\n%s", strings.Join(lines, "\n")) |
| 138 | } |
| 139 | } |
| 140 | |
| 141 | // securitySpecFromExpr generates the OpenAPI security definitions from the |
| 142 | // security design. |
no outgoing calls
no test coverage detected