MCPcopy Create free account
hub / github.com/go-openapi/spec / load

Method load

schema_loader.go:163–189  ·  view source on GitHub ↗
(refURL *url.URL)

Source from the content-addressed store, hash-verified

161}
162
163func (r *schemaLoader) load(refURL *url.URL) (any, error) {
164 debugLog("loading schema from url: %s", refURL)
165 toFetch := *refURL
166 toFetch.Fragment = ""
167
168 pth := toFetch.String()
169 normalized := normalizeBase(pth)
170 debugLog("loading doc from: %s", normalized)
171
172 data, fromCache := r.cache.Get(normalized)
173 if fromCache {
174 return data, nil
175 }
176
177 b, err := r.context.loadDoc(normalized)
178 if err != nil {
179 return nil, err
180 }
181
182 var doc any
183 if err := json.Unmarshal(b, &doc); err != nil {
184 return nil, err
185 }
186 r.cache.Set(normalized, doc)
187
188 return doc, nil
189}
190
191// isCircular detects cycles in sequences of $ref.
192//

Callers 1

resolveRefMethod · 0.95

Calls 4

debugLogFunction · 0.85
normalizeBaseFunction · 0.85
GetMethod · 0.65
SetMethod · 0.65

Tested by

no test coverage detected