Skip to content

Commit

Permalink
Fix $ref issue with special characters (#183)
Browse files Browse the repository at this point in the history
  • Loading branch information
jy95 committed Dec 16, 2019
1 parent c167310 commit 539870e
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/framework/index.ts
Expand Up @@ -72,6 +72,8 @@ export class OpenAPIFramework {
}

private loadSpec(filePath: string | object): Promise<OpenAPIV3.Document> {
// 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));
Expand All @@ -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);
}
Expand All @@ -94,7 +96,7 @@ export class OpenAPIFramework {
);
}
}
return $RefParser.bundle(filePath);
return $RefParser.dereference(filePath);
}

private copy<T>(obj: T): T {
Expand Down

0 comments on commit 539870e

Please sign in to comment.