Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/utils/getOpenApiSpec.ts
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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, {});
};