From 539870ec08f8f96c4a794dae97066a8b88d442f5 Mon Sep 17 00:00:00 2001 From: Jacques Yakoub Date: Mon, 16 Dec 2019 22:38:31 +0100 Subject: [PATCH] Fix $ref issue with special characters (#183) --- src/framework/index.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/framework/index.ts b/src/framework/index.ts index ff2e934c..e1ffdbb3 100644 --- a/src/framework/index.ts +++ b/src/framework/index.ts @@ -72,6 +72,8 @@ export class OpenAPIFramework { } private loadSpec(filePath: string | object): Promise { + // Because of this issue ( https://github.com/APIDevTools/json-schema-ref-parser/issues/101#issuecomment-421755168 ) + // We need this workaround ( use '$RefParser.dereference' instead of '$RefParser.bundle' ) if (typeof filePath === 'string') { const origCwd = process.cwd(); const specDir = path.resolve(origCwd, path.dirname(filePath)); @@ -84,7 +86,7 @@ export class OpenAPIFramework { fs.readFileSync(absolutePath, 'utf8'), { json: true }, ); - return $RefParser.bundle(docWithRefs); + return $RefParser.dereference(docWithRefs); } finally { process.chdir(origCwd); } @@ -94,7 +96,7 @@ export class OpenAPIFramework { ); } } - return $RefParser.bundle(filePath); + return $RefParser.dereference(filePath); } private copy(obj: T): T {