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

Function initAttr

expr/http_endpoint.go:1112–1132  ·  view source on GitHub ↗

initAttr initializes the given mapped attribute with the given service attribute.

(ma *MappedAttributeExpr, svcAtt *AttributeExpr)

Source from the content-addressed store, hash-verified

1110// initAttr initializes the given mapped attribute with the given service
1111// attribute.
1112func initAttr(ma *MappedAttributeExpr, svcAtt *AttributeExpr) {
1113 svcObj := AsObject(svcAtt.Type)
1114 for _, nat := range *AsObject(ma.Type) {
1115 var patt *AttributeExpr
1116 var required bool
1117 if svcObj != nil {
1118 patt = svcObj.Attribute(nat.Name)
1119 required = svcAtt.IsRequired(nat.Name)
1120 } else {
1121 patt = svcAtt
1122 required = true
1123 }
1124 initAttrFromDesign(nat.Attribute, patt)
1125 if required {
1126 if ma.Validation == nil {
1127 ma.Validation = &ValidationExpr{}
1128 }
1129 ma.Validation.AddRequired(nat.Name)
1130 }
1131 }
1132}
1133
1134// initAttrFromDesign overrides the type of att with the one of patt and
1135// initializes other non-initialized fields of att with the one of patt except

Callers 4

FinalizeMethod · 0.85
FinalizeMethod · 0.85
validateParamsMethod · 0.85

Calls 5

AsObjectFunction · 0.85
initAttrFromDesignFunction · 0.85
IsRequiredMethod · 0.80
AddRequiredMethod · 0.80
AttributeMethod · 0.65

Tested by

no test coverage detected