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

Function strategyNumericFallback

pkg/codegen/resolve_names.go:295–315  ·  view source on GitHub ↗

strategyNumericFallback is the last resort: append increasing numbers. Returns true if any name was modified (always true when group has 2+ members).

(group []*ResolvedName)

Source from the content-addressed store, hash-verified

293// strategyNumericFallback is the last resort: append increasing numbers.
294// Returns true if any name was modified (always true when group has 2+ members).
295func strategyNumericFallback(group []*ResolvedName) bool {
296 // Sort for determinism: pinned first, then component schemas, then by path
297 sort.Slice(group, func(i, j int) bool {
298 if group[i].Pinned != group[j].Pinned {
299 return group[i].Pinned
300 }
301 if group[i].Schema.IsComponentSchema() != group[j].Schema.IsComponentSchema() {
302 return group[i].Schema.IsComponentSchema()
303 }
304 return group[i].Schema.Path.String() < group[j].Schema.Path.String()
305 })
306
307 // First non-pinned keeps name, rest get numeric suffix
308 for i := 1; i < len(group); i++ {
309 if group[i].Pinned {
310 continue
311 }
312 group[i].GoName = group[i].GoName + strconv.Itoa(i+1)
313 }
314 return len(group) > 1
315}
316
317// contentTypeSuffix returns a short suffix for a media type.
318func contentTypeSuffix(ct string) string {

Callers

nothing calls this directly

Calls 2

IsComponentSchemaMethod · 0.80
StringMethod · 0.45

Tested by

no test coverage detected