MCPcopy Create free account
hub / github.com/goadesign/goa / buildSecurityRequirements

Function buildSecurityRequirements

http/codegen/openapi/v3/builder.go:541–561  ·  view source on GitHub ↗

buildSecurityRequirements builds the OpenAPI security requirements for the given security expressions.

(reqs []*expr.SecurityExpr)

Source from the content-addressed store, hash-verified

539// buildSecurityRequirements builds the OpenAPI security requirements for the
540// given security expressions.
541func buildSecurityRequirements(reqs []*expr.SecurityExpr) SecurityRequirements {
542 if expr.HasNoSecurity(reqs) {
543 return SecurityRequirements{}
544 }
545 if len(reqs) == 0 {
546 return nil
547 }
548 srs := make(SecurityRequirements, len(reqs))
549 for i, req := range reqs {
550 sr := make(map[string][]string, len(req.Schemes))
551 for _, sch := range req.Schemes {
552 scopes := make([]string, 0)
553 if sch.Kind == expr.OAuth2Kind && len(req.Scopes) > 0 {
554 scopes = req.Scopes
555 }
556 sr[sch.Hash()] = scopes
557 }
558 srs[i] = sr
559 }
560 return srs
561}
562
563// buildSecurityScheme builds the OpenAPI SecurityScheme object from the
564// top-level security scheme definition.

Callers 3

NewFunction · 0.85
buildOperationFunction · 0.85
buildFileServerOperationFunction · 0.85

Calls 2

HasNoSecurityFunction · 0.92
HashMethod · 0.65

Tested by

no test coverage detected