diff --git a/circular_test.go b/circular_test.go index 4e11a7a..1718047 100644 --- a/circular_test.go +++ b/circular_test.go @@ -195,11 +195,12 @@ func TestExpandCircular_RemoteCircularID(t *testing.T) { }) t.Run("withID", func(t *testing.T) { + t.SkipNow() // TODO(fred) Debug = true - t.SkipNow() // TODO(fredbi) const fixturePath = "fixtures/more_circulars/with-id.json" jazon := expandThisOrDieTrying(t, fixturePath) t.Log(jazon) + Debug = false // cannot guarantee that the circular will always hook on the same $ref // but we can assert that thre is only one diff --git a/expander.go b/expander.go index 362a2a0..14c2eee 100644 --- a/expander.go +++ b/expander.go @@ -204,6 +204,7 @@ func expandSchema(target Schema, parentRefs []string, resolver *schemaLoader, ba if target.ID != "" { var parent string basePath, parent = resolver.setSchemaID(target, target.ID, basePath, pointer) + // TODO(fred): do we need this? resolver = resolver.transitiveResolver(basePath, MustCreateRef(parent)) // add normalized ID to the list of parents, in order to detect cycles parentRefs = append(parentRefs, parent) diff --git a/schema_loader.go b/schema_loader.go index 7e06711..f917e20 100644 --- a/schema_loader.go +++ b/schema_loader.go @@ -405,6 +405,8 @@ func (r *schemaLoader) setSchemaID(target interface{}, id, basePath, pointer str r.context.rootID = id } + // u, _ := url.Parse(refPath) + // remembers the schema id's encountered // r.context.ids[id] = true @@ -412,6 +414,8 @@ func (r *schemaLoader) setSchemaID(target interface{}, id, basePath, pointer str // * important: ID can be a relative path // * registers target to be fetchable from the new base proposed by this id newBasePath := normalizePaths(refPath, basePath) + debugLog("newBasePath: %s", newBasePath) + // debugLog("pointer: %s, %s", pointer, u.Path) // store found IDs for possible future reuse in $ref if _, found := r.cache.Get(newBasePath); !found {