oas-normalize 8.1.4 → 8.2.0
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/index.js +1 -1
- package/dist/lib/utils.d.ts +4 -0
- package/dist/lib/utils.js +11 -1
- package/package.json +1 -1
- package/src/index.ts +1 -1
- package/src/lib/utils.ts +10 -0
package/dist/index.js
CHANGED
|
@@ -122,7 +122,7 @@ var OASNormalize = /** @class */ (function () {
|
|
|
122
122
|
return [3 /*break*/, 6];
|
|
123
123
|
case 1: return [2 /*return*/, resolve(this.file)];
|
|
124
124
|
case 2: return [2 /*return*/, resolve(this.file.toString())];
|
|
125
|
-
case 3: return [4 /*yield*/, (0, node_fetch_1["default"])(this.file).then(function (res) { return res.text(); })];
|
|
125
|
+
case 3: return [4 /*yield*/, (0, node_fetch_1["default"])(utils.normalizeURL(this.file)).then(function (res) { return res.text(); })];
|
|
126
126
|
case 4:
|
|
127
127
|
resp = _b.sent();
|
|
128
128
|
return [2 /*return*/, resolve(resp)];
|
package/dist/lib/utils.d.ts
CHANGED
|
@@ -3,6 +3,10 @@
|
|
|
3
3
|
*
|
|
4
4
|
*/
|
|
5
5
|
export declare function isBuffer(obj: any): any;
|
|
6
|
+
/**
|
|
7
|
+
* Converts GitHub blob URLs to raw URLs
|
|
8
|
+
*/
|
|
9
|
+
export declare function normalizeURL(url: string): string;
|
|
6
10
|
/**
|
|
7
11
|
* Determine the type of a given variable. Returns `false` if unrecognized.
|
|
8
12
|
*
|
package/dist/lib/utils.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
exports.__esModule = true;
|
|
6
|
-
exports.getAPIDefinitionType = exports.isAPIDefinition = exports.stringToJSON = exports.isSwagger = exports.isPostman = exports.isOpenAPI = exports.getType = exports.isBuffer = void 0;
|
|
6
|
+
exports.getAPIDefinitionType = exports.isAPIDefinition = exports.stringToJSON = exports.isSwagger = exports.isPostman = exports.isOpenAPI = exports.getType = exports.normalizeURL = exports.isBuffer = void 0;
|
|
7
7
|
var js_yaml_1 = __importDefault(require("js-yaml"));
|
|
8
8
|
/**
|
|
9
9
|
* Determine if a given variable is a `Buffer`.
|
|
@@ -16,6 +16,16 @@ function isBuffer(obj) {
|
|
|
16
16
|
obj.constructor.isBuffer(obj));
|
|
17
17
|
}
|
|
18
18
|
exports.isBuffer = isBuffer;
|
|
19
|
+
/**
|
|
20
|
+
* Converts GitHub blob URLs to raw URLs
|
|
21
|
+
*/
|
|
22
|
+
function normalizeURL(url) {
|
|
23
|
+
if (url.startsWith('https://github.com/') && url.includes('/blob/')) {
|
|
24
|
+
return url.replace('github.com', 'raw.githubusercontent.com').replace('/blob/', '/');
|
|
25
|
+
}
|
|
26
|
+
return url;
|
|
27
|
+
}
|
|
28
|
+
exports.normalizeURL = normalizeURL;
|
|
19
29
|
/**
|
|
20
30
|
* Determine the type of a given variable. Returns `false` if unrecognized.
|
|
21
31
|
*
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -70,7 +70,7 @@ export default class OASNormalize {
|
|
|
70
70
|
return resolve(this.file.toString());
|
|
71
71
|
|
|
72
72
|
case 'url':
|
|
73
|
-
const resp = await fetch(this.file).then(res => res.text());
|
|
73
|
+
const resp = await fetch(utils.normalizeURL(this.file)).then(res => res.text());
|
|
74
74
|
return resolve(resp);
|
|
75
75
|
|
|
76
76
|
case 'path':
|
package/src/lib/utils.ts
CHANGED
|
@@ -13,6 +13,16 @@ export function isBuffer(obj: any) {
|
|
|
13
13
|
);
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
+
/**
|
|
17
|
+
* Converts GitHub blob URLs to raw URLs
|
|
18
|
+
*/
|
|
19
|
+
export function normalizeURL(url: string) {
|
|
20
|
+
if (url.startsWith('https://github.com/') && url.includes('/blob/')) {
|
|
21
|
+
return url.replace('github.com', 'raw.githubusercontent.com').replace('/blob/', '/');
|
|
22
|
+
}
|
|
23
|
+
return url;
|
|
24
|
+
}
|
|
25
|
+
|
|
16
26
|
/**
|
|
17
27
|
* Determine the type of a given variable. Returns `false` if unrecognized.
|
|
18
28
|
*
|