renderServerURLs parses the embedded templates and renders the server-urls template for spec, mirroring the setup in Generate.
(t *testing.T, spec *openapi3.T)
| 64 | // renderServerURLs parses the embedded templates and renders the |
| 65 | // server-urls template for spec, mirroring the setup in Generate. |
| 66 | func renderServerURLs(t *testing.T, spec *openapi3.T) string { |
| 67 | t.Helper() |
| 68 | // Generate registers `opts` before parsing; mirror that here so the |
| 69 | // (unrelated) framework templates parse cleanly. |
| 70 | TemplateFunctions["opts"] = func() Configuration { return globalState.options } |
| 71 | tmpl := template.New("oapi-codegen").Funcs(TemplateFunctions) |
| 72 | require.NoError(t, LoadTemplates(templates, tmpl)) |
| 73 | out, err := GenerateServerURLs(tmpl, spec) |
| 74 | require.NoError(t, err) |
| 75 | return out |
| 76 | } |
| 77 | |
| 78 | // injectSentinel is the identifier a malicious spec tries to smuggle in |
| 79 | // as a real top-level declaration. The two escape techniques covered are: |
no test coverage detected