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

Function isEmpty

expr/http_endpoint.go:1164–1184  ·  view source on GitHub ↗

isEmpty returns true if an attribute is Empty type and it has no bases and references, or if an attribute is an empty object.

(a *AttributeExpr)

Source from the content-addressed store, hash-verified

1162// isEmpty returns true if an attribute is Empty type and it has no bases and
1163// references, or if an attribute is an empty object.
1164func isEmpty(a *AttributeExpr) bool {
1165 if !IsObject(a.Type) {
1166 return false
1167 }
1168 if obj := AsObject(a.Type); obj != nil && len(*obj) != 0 {
1169 if a.Type == Empty {
1170 panic("Empty should have no attribute") // bug
1171 }
1172 return false
1173 }
1174 if len(a.Bases) != 0 || len(a.References) != 0 {
1175 return false
1176 }
1177 if ut, ok := a.Type.(UserType); ok {
1178 uatt := ut.Attribute()
1179 if len(uatt.Bases) != 0 || len(uatt.References) != 0 {
1180 return false
1181 }
1182 }
1183 return true
1184}
1185
1186// hasJSONRPCIDField returns true if an attribute or any of its nested attributes
1187// has the "jsonrpc:id" meta tag, indicating it's designated as the JSON-RPC ID field.

Callers 5

validateMessageFunction · 0.70
validateMetadataFunction · 0.70
ValidateMethod · 0.70
ValidateMethod · 0.70
extendBodyAttributeFunction · 0.70

Calls 3

IsObjectFunction · 0.85
AsObjectFunction · 0.85
AttributeMethod · 0.65

Tested by

no test coverage detected