From b9cf08639a3132c3a38dca998aa5e9996bee0c57 Mon Sep 17 00:00:00 2001 From: Alvaro Cabrera <pateketrueke@gmail.com> Date: Sat, 24 Jun 2017 04:26:56 -0500 Subject: [PATCH] Lookup missing paths for references; fix #294 (async) --- ts/index.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/ts/index.ts b/ts/index.ts index 1b4778c2..5b46b545 100644 --- a/ts/index.ts +++ b/ts/index.ts @@ -41,8 +41,22 @@ jsf.resolve = <jsfAPI>function(schema: JsonSchema, refs?: any, cwd?: string) { cwd = cwd || (typeof process !== 'undefined' ? process.cwd() : ''); cwd = cwd.replace(/\/+$/, '') + '/'; + var $refs = getRefs(refs); + + // identical setup as json-schema-sequelizer + const fixedRefs = { + order: 300, + canRead: true, + read(file, callback) { + callback(null, deref.util.findByRef(cwd !== '/' + ? file.url.replace(cwd, '') + : file.url, $refs)); + }, + }; + return $RefParser .dereference(cwd, schema, { + resolve: { fixedRefs }, dereference: { circular: 'ignore', }, -- GitLab