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

Function headersFromExpr

http/codegen/openapi/v2/builder.go:373–397  ·  view source on GitHub ↗
(headers *expr.MappedAttributeExpr)

Source from the content-addressed store, hash-verified

371}
372
373func headersFromExpr(headers *expr.MappedAttributeExpr) map[string]*Header {
374 if headers == nil {
375 return nil
376 }
377 res := make(map[string]*Header)
378 codegen.WalkMappedAttr(headers, func(_, n string, _ bool, at *expr.AttributeExpr) error { // nolint: errcheck
379 headerType, headerFormat := openAPITypeFormat(at)
380 header := &Header{
381 Default: at.DefaultValue,
382 Description: at.Description,
383 Type: headerType,
384 Format: headerFormat,
385 }
386 if expr.IsArray(at.Type) {
387 header.Items = itemsFromExpr(expr.AsArray(at.Type).ElemType)
388 }
389 initAttributeValidations(at, header)
390 res[n] = header
391 return nil
392 })
393 if len(res) == 0 {
394 return nil
395 }
396 return res
397}
398
399func openAPITypeFormat(at *expr.AttributeExpr) (string, string) {
400 at = resolvedAliasAttribute(at)

Callers 1

responseSpecFromExprFunction · 0.85

Calls 6

WalkMappedAttrFunction · 0.92
IsArrayFunction · 0.92
AsArrayFunction · 0.92
openAPITypeFormatFunction · 0.85
itemsFromExprFunction · 0.85
initAttributeValidationsFunction · 0.85

Tested by

no test coverage detected