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

Function serverURLEnumKeys

pkg/codegen/server_urls.go:186–200  ·  view source on GitHub ↗

serverURLEnumKeys returns deterministic identifier suffixes for each enum value of `v`, in `v.Enum` order. Each suffix is just the value with its first character upper-cased — matching what the previous template-only path produced for happy-path specs (` `), so adopters with

(v *openapi3.ServerVariable)

Source from the content-addressed store, hash-verified

184// correctness improvement, not a naming change for any spec that
185// actually compiled before.
186func serverURLEnumKeys(v *openapi3.ServerVariable) []string {
187 keys := make([]string, len(v.Enum))
188 seen := make(map[string]int, len(v.Enum))
189 for i, val := range v.Enum {
190 base := UppercaseFirstCharacter(val)
191 if n, dup := seen[base]; dup {
192 keys[i] = base + strconv.Itoa(n)
193 seen[base] = n + 1
194 } else {
195 keys[i] = base
196 seen[base] = 1
197 }
198 }
199 return keys
200}
201
202// serverURLEnumValues returns the EnumValues map handed to GenerateEnums
203// for variable `v`: key is the deduplicated identifier suffix from

Callers 2

serverURLEnumValuesFunction · 0.85
EnumDefaultPointersMethod · 0.85

Calls 1

UppercaseFirstCharacterFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…