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

Method UsedVariables

pkg/codegen/server_urls.go:55–67  ·  view source on GitHub ↗

UsedVariables returns the subset of OAPISchema.Variables whose `{name}` placeholder actually appears in OAPISchema.URL. Variables declared but unused are skipped — they would otherwise produce a type, constant, function parameter, and a no-op `strings.ReplaceAll` (https://github.com/oapi-codegen/oap

()

Source from the content-addressed store, hash-verified

53// both server-urls.tmpl and BuildServerURLTypeDefinitions so that
54// emitted types and the generated function signature stay in sync.
55func (s ServerObjectDefinition) UsedVariables() map[string]*openapi3.ServerVariable {
56 if s.OAPISchema == nil || len(s.OAPISchema.Variables) == 0 {
57 return nil
58 }
59 placeholders := urlPlaceholders(s.OAPISchema.URL)
60 used := make(map[string]*openapi3.ServerVariable, len(s.OAPISchema.Variables))
61 for name, v := range s.OAPISchema.Variables {
62 if _, ok := placeholders[name]; ok {
63 used[name] = v
64 }
65 }
66 return used
67}
68
69// UndeclaredPlaceholders returns the sorted list of `{name}`
70// placeholder names that appear in OAPISchema.URL but have no

Callers 4

EnumDefaultPointersMethod · 0.95

Calls 1

urlPlaceholdersFunction · 0.85

Tested by 1