MCPcopy Index your code
hub / github.com/getkin/kin-openapi / ResolveRefsIn

Method ResolveRefsIn

openapi3/loader.go:215–296  ·  view source on GitHub ↗

ResolveRefsIn expands references if for instance spec was just unmarshaled

(doc *T, location *url.URL)

Source from the content-addressed store, hash-verified

213
214// ResolveRefsIn expands references if for instance spec was just unmarshaled
215func (loader *Loader) ResolveRefsIn(doc *T, location *url.URL) (err error) {
216 if loader.Context == nil {
217 loader.Context = context.Background()
218 }
219
220 if loader.visitedPathItemRefs == nil {
221 loader.resetVisitedPathItemRefs()
222 }
223
224 if components := doc.Components; components != nil {
225 for _, name := range componentNames(components.Headers) {
226 component := components.Headers[name]
227 if err = loader.resolveHeaderRef(doc, component, location); err != nil {
228 return
229 }
230 }
231 for _, name := range componentNames(components.Parameters) {
232 component := components.Parameters[name]
233 if err = loader.resolveParameterRef(doc, component, location); err != nil {
234 return
235 }
236 }
237 for _, name := range componentNames(components.RequestBodies) {
238 component := components.RequestBodies[name]
239 if err = loader.resolveRequestBodyRef(doc, component, location); err != nil {
240 return
241 }
242 }
243 for _, name := range componentNames(components.Responses) {
244 component := components.Responses[name]
245 if err = loader.resolveResponseRef(doc, component, location); err != nil {
246 return
247 }
248 }
249 for _, name := range componentNames(components.Schemas) {
250 component := components.Schemas[name]
251 if err = loader.resolveSchemaRef(doc, component, location, []string{}); err != nil {
252 return
253 }
254 }
255 for _, name := range componentNames(components.SecuritySchemes) {
256 component := components.SecuritySchemes[name]
257 if err = loader.resolveSecuritySchemeRef(doc, component, location); err != nil {
258 return
259 }
260 }
261 for _, name := range componentNames(components.Examples) {
262 component := components.Examples[name]
263 if err = loader.resolveExampleRef(doc, component, location); err != nil {
264 return
265 }
266 }
267 for _, name := range componentNames(components.Callbacks) {
268 component := components.Callbacks[name]
269 if err = loader.resolveCallbackRef(doc, component, location); err != nil {
270 return
271 }
272 }

Callers 8

TestIssue341Function · 0.95
LoadFromDataMethod · 0.95
TestRefsJSONFunction · 0.95
TestRefsYAMLFunction · 0.95
TestConvOpenAPIV3ToV2Function · 0.95
ToV3WithLoaderFunction · 0.80

Calls 12

resolveHeaderRefMethod · 0.95
resolveParameterRefMethod · 0.95
resolveRequestBodyRefMethod · 0.95
resolveResponseRefMethod · 0.95
resolveSchemaRefMethod · 0.95
resolveExampleRefMethod · 0.95
resolveCallbackRefMethod · 0.95
resolvePathItemRefMethod · 0.95
componentNamesFunction · 0.85
MapMethod · 0.45

Tested by 5

TestIssue341Function · 0.76
TestRefsJSONFunction · 0.76
TestRefsYAMLFunction · 0.76
TestConvOpenAPIV3ToV2Function · 0.76