Merge pull request #2053 from tajnymag/bugfix/issue-2052

Fixed issue 2052
This commit is contained in:
Ferdi Koomen 2024-03-17 20:47:32 +01:00 committed by GitHub
commit 800d969a2f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,4 +1,7 @@
import RefParser from '@apidevtools/json-schema-ref-parser';
import { resolve } from 'path';
import { exists } from './fileSystem';
/**
* Load and parse te open api spec. If the file extension is ".yml" or ".yaml"
@ -7,5 +10,6 @@ import RefParser from '@apidevtools/json-schema-ref-parser';
* @param location: Path or url
*/
export const getOpenApiSpec = async (location: string): Promise<any> => {
return await RefParser.bundle(location, location, {});
const absolutePathOrUrl = (await exists(location)) ? resolve(location) : location;
return await RefParser.bundle(absolutePathOrUrl, absolutePathOrUrl, {});
};