swaggie 1.2.0 → 1.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/utils/documentLoader.js +16 -1
- package/package.json +1 -1
|
@@ -37,5 +37,20 @@ function readLocalFile(filePath) {
|
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
function parseFileContents(contents, path) {
|
|
40
|
-
|
|
40
|
+
// If the path ends with .yaml or .yml, parse as YAML
|
|
41
|
+
if (/.ya?ml$/i.test(path)) {
|
|
42
|
+
return _jsyaml2.default.load(contents) ;
|
|
43
|
+
}
|
|
44
|
+
// If the path ends with .json, parse as JSON
|
|
45
|
+
if (/.json$/i.test(path)) {
|
|
46
|
+
return JSON.parse(contents);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// It is possible that the URL does not have an extension, so we need to check the contents
|
|
50
|
+
const firstChar = contents.trimStart()[0];
|
|
51
|
+
if (firstChar === '{') {
|
|
52
|
+
return JSON.parse(contents);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return _jsyaml2.default.load(contents) ;
|
|
41
56
|
}
|