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

Function paramsFromHeadersAndCookies

http/codegen/openapi/v3/parameters.go:37–58  ·  view source on GitHub ↗

paramsFromHeadersAndCookies computes the OpenAPI spec parameters for the given endpoint HTTP headers and cookies.

(endpoint *expr.HTTPEndpointExpr, rand *expr.ExampleGenerator)

Source from the content-addressed store, hash-verified

35// paramsFromHeadersAndCookies computes the OpenAPI spec parameters for the
36// given endpoint HTTP headers and cookies.
37func paramsFromHeadersAndCookies(endpoint *expr.HTTPEndpointExpr, rand *expr.ExampleGenerator) []*Parameter {
38 var params []*Parameter
39
40 expr.WalkMappedAttr(endpoint.Headers, func(name, elem string, att *expr.AttributeExpr) error { // nolint: errcheck
41 if openapiinternal.IsSecurityParameter(endpoint, "header", elem) {
42 return nil
43 }
44 required := endpoint.Headers.IsRequiredNoDefault(name)
45 params = append(params, paramFor(att, elem, "header", required, rand))
46 return nil
47 })
48 expr.WalkMappedAttr(endpoint.Cookies, func(name, elem string, att *expr.AttributeExpr) error { // nolint: errcheck
49 if openapiinternal.IsSecurityParameter(endpoint, "cookie", elem) {
50 return nil
51 }
52 required := endpoint.Cookies.IsRequiredNoDefault(name)
53 params = append(params, paramFor(att, elem, "cookie", required, rand))
54 return nil
55 })
56
57 return params
58}
59
60// paramFor converts the given attribute into a OpenAPI spec parameter.
61func paramFor(att *expr.AttributeExpr, name, in string, required bool, rand *expr.ExampleGenerator) *Parameter {

Callers 1

buildOperationFunction · 0.85

Calls 3

WalkMappedAttrFunction · 0.92
IsRequiredNoDefaultMethod · 0.80
paramForFunction · 0.70

Tested by

no test coverage detected