MCPcopy Index your code
hub / github.com/oapi-codegen/oapi-codegen / renderServerURLs

Function renderServerURLs

pkg/codegen/server_urls_test.go:66–76  ·  view source on GitHub ↗

renderServerURLs parses the embedded templates and renders the server-urls template for spec, mirroring the setup in Generate.

(t *testing.T, spec *openapi3.T)

Source from the content-addressed store, hash-verified

64// renderServerURLs parses the embedded templates and renders the
65// server-urls template for spec, mirroring the setup in Generate.
66func 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:

Callers 1

TestServerURLInjectionFunction · 0.85

Calls 2

LoadTemplatesFunction · 0.85
GenerateServerURLsFunction · 0.85

Tested by

no test coverage detected