Skip to content

Commit 89c3074

Browse files
committed
work on remaining bug with nested schema ID
Signed-off-by: Frederic BIDON <[email protected]>
1 parent 55dd5ff commit 89c3074

File tree

3 files changed

+7
-1
lines changed

3 files changed

+7
-1
lines changed

circular_test.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -195,11 +195,12 @@ func TestExpandCircular_RemoteCircularID(t *testing.T) {
195195
})
196196

197197
t.Run("withID", func(t *testing.T) {
198+
t.SkipNow() // TODO(fred)
198199
Debug = true
199-
t.SkipNow() // TODO(fredbi)
200200
const fixturePath = "fixtures/more_circulars/with-id.json"
201201
jazon := expandThisOrDieTrying(t, fixturePath)
202202
t.Log(jazon)
203+
Debug = false
203204

204205
// cannot guarantee that the circular will always hook on the same $ref
205206
// but we can assert that thre is only one

expander.go

+1
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,7 @@ func expandSchema(target Schema, parentRefs []string, resolver *schemaLoader, ba
204204
if target.ID != "" {
205205
var parent string
206206
basePath, parent = resolver.setSchemaID(target, target.ID, basePath, pointer)
207+
// TODO(fred): do we need this? resolver = resolver.transitiveResolver(basePath, MustCreateRef(parent))
207208

208209
// add normalized ID to the list of parents, in order to detect cycles
209210
parentRefs = append(parentRefs, parent)

schema_loader.go

+4
Original file line numberDiff line numberDiff line change
@@ -405,13 +405,17 @@ func (r *schemaLoader) setSchemaID(target interface{}, id, basePath, pointer str
405405
r.context.rootID = id
406406
}
407407

408+
// u, _ := url.Parse(refPath)
409+
408410
// remembers the schema id's encountered
409411
// r.context.ids[id] = true
410412

411413
// updates the current base path
412414
// * important: ID can be a relative path
413415
// * registers target to be fetchable from the new base proposed by this id
414416
newBasePath := normalizePaths(refPath, basePath)
417+
debugLog("newBasePath: %s", newBasePath)
418+
// debugLog("pointer: %s, %s", pointer, u.Path)
415419

416420
// store found IDs for possible future reuse in $ref
417421
if _, found := r.cache.Get(newBasePath); !found {

0 commit comments

Comments
 (0)