@@ -92,7 +92,7 @@ type resolverContext struct {
92
92
rootID string
93
93
// ids holds all inherited $id for the current schema.
94
94
// This is used to try alternate paths to resolve $ref.
95
- //ids map[string]bool
95
+ // ids map[string]bool
96
96
}
97
97
98
98
func newResolverContext (expandOptions * ExpandOptions ) * resolverContext {
@@ -185,14 +185,12 @@ func (r *schemaLoader) resolveRef(ref *Ref, target interface{}, basePath, pointe
185
185
if (ref .IsRoot () || ref .HasFragmentOnly ) && root == nil {
186
186
if basePath != "" {
187
187
debugLog ("fetch from basePath: %s" , basePath )
188
- if baseRef , erb := NewRef (basePath ); erb == nil {
189
- root , _ , _ , _ = r .load (baseRef .GetURL ())
190
- }
188
+ baseRef := MustCreateRef (basePath )
189
+ root , _ = r .load (baseRef .GetURL ())
191
190
} else {
192
191
debugLog ("fetch from root in RelativeBase: %s" , r .options .RelativeBase )
193
- if baseRef , erb := NewRef (r .options .RelativeBase ); erb == nil {
194
- root , _ , _ , _ = r .load (baseRef .GetURL ())
195
- }
192
+ baseRef := MustCreateRef (r .options .RelativeBase )
193
+ root , _ = r .load (baseRef .GetURL ())
196
194
}
197
195
}
198
196
@@ -202,7 +200,7 @@ func (r *schemaLoader) resolveRef(ref *Ref, target interface{}, basePath, pointe
202
200
if (ref .IsRoot () || ref .HasFragmentOnly ) && root != nil {
203
201
data = root
204
202
} else {
205
- data , _ , _ , err = r .load (baseRef .GetURL ())
203
+ data , err = r .load (baseRef .GetURL ())
206
204
if err != nil {
207
205
return err
208
206
}
@@ -244,7 +242,7 @@ func (r *schemaLoader) resolveRef(ref *Ref, target interface{}, basePath, pointe
244
242
return swag .DynamicJSONToStruct (res , target )
245
243
}
246
244
247
- func (r * schemaLoader ) load (refURL * url.URL ) (interface {}, url. URL , bool , error ) { // TODO: simplify return values
245
+ func (r * schemaLoader ) load (refURL * url.URL ) (interface {}, error ) {
248
246
debugLog ("loading schema from url: %s" , refURL )
249
247
toFetch := * refURL
250
248
toFetch .Fragment = ""
@@ -254,7 +252,7 @@ func (r *schemaLoader) load(refURL *url.URL) (interface{}, url.URL, bool, error)
254
252
if pth == rootBase {
255
253
pth , err = absPath (rootBase )
256
254
if err != nil {
257
- return nil , url. URL {}, false , err
255
+ return nil , err
258
256
}
259
257
}
260
258
normalized := normalizeAbsPath (pth )
@@ -263,20 +261,20 @@ func (r *schemaLoader) load(refURL *url.URL) (interface{}, url.URL, bool, error)
263
261
if ! fromCache {
264
262
b , err := r .context .loadDoc (normalized )
265
263
if err != nil {
266
- return nil , url. URL {}, false , fmt .Errorf ("%s [%s]: %w" , pth , normalized , err )
264
+ return nil , fmt .Errorf ("%s [normalized: %s]: %w" , pth , normalized , err )
267
265
}
268
266
269
267
var doc interface {}
270
268
if err := json .Unmarshal (b , & doc ); err != nil {
271
- return nil , url. URL {}, false , err
269
+ return nil , err
272
270
}
273
271
274
272
r .cache .Set (normalized , doc )
275
273
276
- return doc , toFetch , fromCache , nil
274
+ return doc , nil
277
275
}
278
276
279
- return data , toFetch , fromCache , nil
277
+ return data , nil
280
278
}
281
279
282
280
// isCircular detects cycles in sequences of $ref.
@@ -408,7 +406,7 @@ func (r *schemaLoader) setSchemaID(target interface{}, id, basePath, pointer str
408
406
}
409
407
410
408
// remembers the schema id's encountered
411
- //r.context.ids[id] = true
409
+ // r.context.ids[id] = true
412
410
413
411
// updates the current base path
414
412
// * important: ID can be a relative path
0 commit comments