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

Function ResolveNames

pkg/codegen/resolve_names.go:20–42  ·  view source on GitHub ↗

ResolveNames takes the gathered schemas and assigns unique Go type names to each. It returns a map from the schema's path string to the resolved Go type name.

(schemas []*GatheredSchema)

Source from the content-addressed store, hash-verified

18// ResolveNames takes the gathered schemas and assigns unique Go type names to each.
19// It returns a map from the schema's path string to the resolved Go type name.
20func ResolveNames(schemas []*GatheredSchema) map[string]string {
21 // Step 1: Generate candidate names for all schemas
22 candidates := make([]*ResolvedName, len(schemas))
23 for i, s := range schemas {
24 candidate := generateCandidateName(s)
25 candidates[i] = &ResolvedName{
26 Schema: s,
27 GoName: candidate,
28 Candidate: candidate,
29 Pinned: s.GoNameOverride != "",
30 }
31 }
32
33 // Step 2: Resolve collisions iteratively
34 resolveCollisions(candidates)
35
36 // Step 3: Build the result map
37 result := make(map[string]string, len(candidates))
38 for _, c := range candidates {
39 result[c.Schema.Path.String()] = c.GoName
40 }
41 return result
42}
43
44// generateCandidateName produces an initial Go type name candidate based on
45// the schema's location and context in the OpenAPI document.

Calls 3

generateCandidateNameFunction · 0.85
resolveCollisionsFunction · 0.85
StringMethod · 0.45