(headers *expr.MappedAttributeExpr)
| 371 | } |
| 372 | |
| 373 | func 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 | |
| 399 | func openAPITypeFormat(at *expr.AttributeExpr) (string, string) { |
| 400 | at = resolvedAliasAttribute(at) |
no test coverage detected