paramsFromPath computes the OpenAPI spec parameters for the given endpoint HTTP path and query parameters.
(endpoint *expr.HTTPEndpointExpr, path string, rand *expr.ExampleGenerator)
| 12 | // paramsFromPath computes the OpenAPI spec parameters for the given endpoint |
| 13 | // HTTP path and query parameters. |
| 14 | func 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. |
no test coverage detected