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

Function externalPackageFor

pkg/codegen/externalref.go:64–73  ·  view source on GitHub ↗

externalPackageFor returns the imported Go package name for a `$ref` that targets a file outside the current spec. Returns an empty string when the ref is empty, points within the current spec, or has no import-mapping.

(ref string)

Source from the content-addressed store, hash-verified

62// targets a file outside the current spec. Returns an empty string when the
63// ref is empty, points within the current spec, or has no import-mapping.
64func externalPackageFor(ref string) string {
65 if ref == "" {
66 return ""
67 }
68 parts := strings.SplitN(ref, "#", 2)
69 if pack, ok := globalState.importMapping[parts[0]]; ok {
70 return pack.Name
71 }
72 return ""
73}
74
75// ensureExternalRefsInSchema ensures that when an externalRef (`$ref` that points to a file that isn't the current spec) is encountered, we make sure we update our underlying `RefType` to make sure that we point to that type.
76//

Callers 3

GenerateBodyDefinitionsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected