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

Function GenerateTemplates

pkg/codegen/operations.go:1357–1373  ·  view source on GitHub ↗

GenerateTemplates used to generate templates

(templates []string, t *template.Template, ops any)

Source from the content-addressed store, hash-verified

1355
1356// GenerateTemplates used to generate templates
1357func GenerateTemplates(templates []string, t *template.Template, ops any) (string, error) {
1358 var generatedTemplates []string
1359 for _, tmpl := range templates {
1360 var buf bytes.Buffer
1361 w := bufio.NewWriter(&buf)
1362
1363 if err := t.ExecuteTemplate(w, tmpl, ops); err != nil {
1364 return "", fmt.Errorf("error generating %s: %s", tmpl, err)
1365 }
1366 if err := w.Flush(); err != nil {
1367 return "", fmt.Errorf("error flushing output buffer for %s: %s", tmpl, err)
1368 }
1369 generatedTemplates = append(generatedTemplates, buf.String())
1370 }
1371
1372 return strings.Join(generatedTemplates, "\n"), nil
1373}
1374
1375// CombineOperationParameters combines the Parameters defined at a global level (Parameters defined for all methods on a given path) with the Parameters defined at a local level (Parameters defined for a specific path), preferring the locally defined parameter over the global one
1376func CombineOperationParameters(globalParams []ParameterDefinition, localParams []ParameterDefinition) ([]ParameterDefinition, error) {

Callers 15

GenerateInlinedSpecFunction · 0.85
GenerateServerURLsFunction · 0.85
GenerateConstantsFunction · 0.85
GenerateTypesFunction · 0.85
GenerateEnumsFunction · 0.85
GenerateImportsFunction · 0.85
GenerateUnionBoilerplateFunction · 0.85
GenerateIrisServerFunction · 0.85
GenerateChiServerFunction · 0.85

Calls 1

StringMethod · 0.45

Tested by

no test coverage detected