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

Function paramsFromPath

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

paramsFromPath computes the OpenAPI spec parameters for the given endpoint HTTP path and query parameters.

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

Source from the content-addressed store, hash-verified

12// paramsFromPath computes the OpenAPI spec parameters for the given endpoint
13// HTTP path and query parameters.
14func paramsFromPath(endpoint *expr.HTTPEndpointExpr, path string, rand *expr.ExampleGenerator) []*Parameter {
15 var (
16 res []*Parameter
17 params = endpoint.Params
18 wildcards = expr.ExtractHTTPWildcards(path)
19 )
20 codegen.WalkMappedAttr(params, func(n, pn string, required bool, at *expr.AttributeExpr) error { // nolint: errcheck
21 in := "query"
22 if slices.Contains(wildcards, n) {
23 in = "path"
24 required = true
25 }
26 if in != "path" && openapiinternal.IsSecurityParameter(endpoint, in, pn) {
27 return nil
28 }
29 res = append(res, paramFor(at, pn, in, required, rand))
30 return nil
31 })
32 return res
33}
34
35// paramsFromHeadersAndCookies computes the OpenAPI spec parameters for the
36// given endpoint HTTP headers and cookies.

Callers 1

buildOperationFunction · 0.85

Calls 3

ExtractHTTPWildcardsFunction · 0.92
WalkMappedAttrFunction · 0.92
paramForFunction · 0.70

Tested by

no test coverage detected