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

Function headersFromAttr

http/codegen/openapi/v3/response.go:12–31  ·  view source on GitHub ↗
(attr *expr.MappedAttributeExpr, rand *expr.ExampleGenerator)

Source from the content-addressed store, hash-verified

10)
11
12func headersFromAttr(attr *expr.MappedAttributeExpr, rand *expr.ExampleGenerator) map[string]*HeaderRef {
13 o := expr.AsObject(attr.Type)
14 if len(*o) == 0 {
15 return nil
16 }
17 headers := make(map[string]*HeaderRef, len(*o))
18 expr.WalkMappedAttr(attr, func(name, elem string, attr *expr.AttributeExpr) error { // nolint: errcheck
19 header := &Header{
20 Description: attr.Description,
21 Required: attr.IsRequiredNoDefault(name),
22 Schema: newSchemafier(rand).schemafy(attr),
23 Example: attr.Example(rand),
24 Extensions: openapi.ExtensionsFromExpr(attr.Meta),
25 }
26 initExamples(header, attr, rand)
27 headers[elem] = &HeaderRef{Value: header}
28 return nil
29 })
30 return headers
31}
32
33func responseFromExpr(r *expr.HTTPResponseExpr, bodies map[int][]*openapi.Schema, rand *expr.ExampleGenerator) *Response {
34 ct := r.ContentType

Callers 1

responseFromExprFunction · 0.85

Calls 8

AsObjectFunction · 0.92
WalkMappedAttrFunction · 0.92
ExtensionsFromExprFunction · 0.92
newSchemafierFunction · 0.85
initExamplesFunction · 0.85
IsRequiredNoDefaultMethod · 0.80
schemafyMethod · 0.80
ExampleMethod · 0.65

Tested by

no test coverage detected