MCPcopy Create free account
hub / github.com/getkin/kin-openapi / resolveRefPath

Method resolveRefPath

openapi3/loader.go:332–360  ·  view source on GitHub ↗
(ref string, path *url.URL)

Source from the content-addressed store, hash-verified

330}
331
332func (loader *Loader) resolveRefPath(ref string, path *url.URL) (*url.URL, error) {
333 if ref != "" && ref[0] == '#' {
334 path = copyURI(path)
335 // Resolving internal refs of a doc loaded from memory
336 // has no path, so just set the Fragment.
337 if path == nil {
338 path = new(url.URL)
339 }
340
341 path.Fragment = ref
342 return path, nil
343 }
344
345 // IsExternalRefsAllowed is enforced here only when no custom ReadFromURIFunc
346 // is installed; otherwise the custom func owns the access policy (see the
347 // SECURITY note on the ReadFromURIFunc field).
348 if loader.ReadFromURIFunc == nil {
349 if err := loader.allowsExternalRefs(ref); err != nil {
350 return nil, err
351 }
352 }
353
354 resolvedPath, err := loader.resolvePathWithRef(ref, path)
355 if err != nil {
356 return nil, err
357 }
358
359 return resolvedPath, nil
360}
361
362func isSingleRefElement(ref string) bool {
363 return !strings.Contains(ref, "#")

Callers 10

resolveRefMethod · 0.95
resolveHeaderRefMethod · 0.95
resolveParameterRefMethod · 0.95
resolveRequestBodyRefMethod · 0.95
resolveResponseRefMethod · 0.95
resolveSchemaRefMethod · 0.95
resolveExampleRefMethod · 0.95
resolveCallbackRefMethod · 0.95
resolveLinkRefMethod · 0.95

Calls 3

allowsExternalRefsMethod · 0.95
resolvePathWithRefMethod · 0.95
copyURIFunction · 0.70

Tested by

no test coverage detected