From e5a1b835f1d6fb4bb52c95509b3cf8df91370223 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20Both=C3=A9n?= Date: Fri, 2 Jun 2023 15:40:05 +0200 Subject: [PATCH] fix: External refs with overrides --- lib/resolve-external.ts | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/lib/resolve-external.ts b/lib/resolve-external.ts index 7b9dce63..99f36334 100644 --- a/lib/resolve-external.ts +++ b/lib/resolve-external.ts @@ -64,18 +64,19 @@ function crawl( seen.add(obj); // Track previously seen objects to avoid infinite recursion if ($Ref.isExternal$Ref(obj)) { promises.push(resolve$Ref(obj, path, $refs, options)); - } else { - for (const key of Object.keys(obj)) { - const keyPath = Pointer.join(path, key); - const value = obj[key] as string | JSONSchema | Buffer | undefined; - - if ($Ref.isExternal$Ref(value)) { - promises.push(resolve$Ref(value, keyPath, $refs, options)); - } else { - promises = promises.concat(crawl(value, keyPath, $refs, options, seen)); - } + } + + for (const key of Object.keys(obj)) { + const keyPath = Pointer.join(path, key); + const value = obj[key] as string | JSONSchema | Buffer | undefined; + + if ($Ref.isExternal$Ref(value)) { + promises.push(resolve$Ref(value, keyPath, $refs, options)); } + + promises = promises.concat(crawl(value, keyPath, $refs, options, seen)); } + } return promises;