Skip to content

Commit 92ad2ae

Browse files
committed
- Removed yaml loader in favor of refparser
1 parent b3a08a7 commit 92ad2ae

File tree

3 files changed

+1
-55
lines changed

3 files changed

+1
-55
lines changed

package.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@
6666
"commander": "^8.0.0",
6767
"form-data": "^4.0.0",
6868
"handlebars": "^4.7.6",
69-
"js-yaml": "^4.0.0",
7069
"json-schema-ref-parser": "^9.0.7",
7170
"mkdirp": "^1.0.4",
7271
"node-fetch": "^2.6.5",
@@ -82,7 +81,6 @@
8281
"@types/express": "4.17.13",
8382
"@types/glob": "7.1.4",
8483
"@types/jest": "27.0.2",
85-
"@types/js-yaml": "4.0.3",
8684
"@types/node": "16.10.3",
8785
"@types/qs": "6.9.7",
8886
"@typescript-eslint/eslint-plugin": "4.33.0",

src/utils/getOpenApiSpec.spec.ts

Lines changed: 0 additions & 27 deletions
This file was deleted.

src/utils/getOpenApiSpec.ts

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
1-
import { load } from 'js-yaml';
21
import RefParser from 'json-schema-ref-parser';
3-
import { extname } from 'path';
4-
5-
import { readSpec } from './readSpec';
62

73
/**
84
* Load and parse te open api spec. If the file extension is ".yml" or ".yaml"
@@ -11,26 +7,5 @@ import { readSpec } from './readSpec';
117
* @param input
128
*/
139
export async function getOpenApiSpec(input: string): Promise<any> {
14-
const extension = extname(input).toLowerCase();
15-
const content = await readSpec(input);
16-
let rootObject: any;
17-
switch (extension) {
18-
case '.yml':
19-
case '.yaml':
20-
try {
21-
rootObject = load(content);
22-
} catch (e) {
23-
throw new Error(`Could not parse OpenApi YAML: "${input}"`);
24-
}
25-
break;
26-
27-
default:
28-
try {
29-
rootObject = JSON.parse(content);
30-
} catch (e) {
31-
throw new Error(`Could not parse OpenApi JSON: "${input}"`);
32-
}
33-
break;
34-
}
35-
return await RefParser.bundle(rootObject);
10+
return await RefParser.bundle(input);
3611
}

0 commit comments

Comments
 (0)