@apidevtools/json-schema-ref-parser 9.0.9 → 9.1.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/README.md +11 -2
- package/lib/bundle.js +1 -1
- package/lib/dereference.js +11 -1
- package/lib/index.d.ts +17 -1
- package/lib/options.js +10 -1
- package/lib/parsers/yaml.js +2 -1
- package/lib/pointer.js +1 -1
- package/lib/ref.js +1 -1
- package/lib/refs.js +5 -2
- package/lib/resolve-external.js +1 -1
- package/lib/resolvers/http.js +43 -66
- package/lib/util/url.js +30 -6
- package/package.json +18 -18
- package/CHANGELOG.md +0 -182
package/README.md
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
JSON Schema $Ref Parser
|
|
2
|
-
|
|
1
|
+
# JSON Schema $Ref Parser
|
|
2
|
+
|
|
3
|
+
_**This package needs [a new maintainer](https://github.com/APIDevTools/json-schema-ref-parser/issues/285) or at least some contributors, or a decent number of sponsors so I can hire contractors to do the work. For more information [please read this article](https://phil.tech/2022/bundling-openapi-with-javascript/). I'll mark the repo as read-only and unmaintained on January 15th 2023 along with a bunch of other @apidevtools packages like swagger-parser, so I can focus on scaling up my [reforestation charity](https://protect.earth/) instead of burning myself out trying to maintain a whole load of OSS projects I don't use in my vanishingly small spare time.** - [Phil Sturgeon](https://github.com/philsturgeon)_
|
|
4
|
+
|
|
3
5
|
#### Parse, Resolve, and Dereference JSON Schema $ref pointers
|
|
4
6
|
|
|
5
7
|
[](https://github.com/APIDevTools/json-schema-ref-parser/actions)
|
|
@@ -111,6 +113,13 @@ When using a transpiler such as [Babel](https://babeljs.io/) or [TypeScript](htt
|
|
|
111
113
|
import $RefParser from "@apidevtools/json-schema-ref-parser";
|
|
112
114
|
```
|
|
113
115
|
|
|
116
|
+
If you are using Node.js < 18, you'll need a polyfill for `fetch`, like [node-fetch](https://github.com/node-fetch/node-fetch):
|
|
117
|
+
```javascript
|
|
118
|
+
import fetch from "node-fetch";
|
|
119
|
+
|
|
120
|
+
globalThis.fetch = fetch;
|
|
121
|
+
```
|
|
122
|
+
|
|
114
123
|
|
|
115
124
|
|
|
116
125
|
Browser support
|
package/lib/bundle.js
CHANGED
|
@@ -135,7 +135,7 @@ function inventory$Ref ($refParent, $refKey, path, pathFromRoot, indirections, i
|
|
|
135
135
|
});
|
|
136
136
|
|
|
137
137
|
// Recursively crawl the resolved value
|
|
138
|
-
if (!existingEntry) {
|
|
138
|
+
if (!existingEntry || external) {
|
|
139
139
|
crawl(pointer.value, null, pointer.path, pathFromRoot, indirections + 1, inventory, $refs, options);
|
|
140
140
|
}
|
|
141
141
|
}
|
package/lib/dereference.js
CHANGED
|
@@ -41,8 +41,10 @@ function crawl (obj, path, pathFromRoot, parents, processedObjects, dereferenced
|
|
|
41
41
|
circular: false
|
|
42
42
|
};
|
|
43
43
|
|
|
44
|
+
let isExcludedPath = options.dereference.excludedPathMatcher;
|
|
45
|
+
|
|
44
46
|
if (options.dereference.circular === "ignore" || !processedObjects.has(obj)) {
|
|
45
|
-
if (obj && typeof obj === "object" && !ArrayBuffer.isView(obj)) {
|
|
47
|
+
if (obj && typeof obj === "object" && !ArrayBuffer.isView(obj) && !isExcludedPath(pathFromRoot)) {
|
|
46
48
|
parents.add(obj);
|
|
47
49
|
processedObjects.add(obj);
|
|
48
50
|
|
|
@@ -55,6 +57,11 @@ function crawl (obj, path, pathFromRoot, parents, processedObjects, dereferenced
|
|
|
55
57
|
for (const key of Object.keys(obj)) {
|
|
56
58
|
let keyPath = Pointer.join(path, key);
|
|
57
59
|
let keyPathFromRoot = Pointer.join(pathFromRoot, key);
|
|
60
|
+
|
|
61
|
+
if (isExcludedPath(keyPathFromRoot)) {
|
|
62
|
+
continue;
|
|
63
|
+
}
|
|
64
|
+
|
|
58
65
|
let value = obj[key];
|
|
59
66
|
let circular = false;
|
|
60
67
|
|
|
@@ -64,6 +71,9 @@ function crawl (obj, path, pathFromRoot, parents, processedObjects, dereferenced
|
|
|
64
71
|
// Avoid pointless mutations; breaks frozen objects to no profit
|
|
65
72
|
if (obj[key] !== dereferenced.value) {
|
|
66
73
|
obj[key] = dereferenced.value;
|
|
74
|
+
if (options.dereference.onDereference) {
|
|
75
|
+
options.dereference.onDereference(value.$ref, obj[key]);
|
|
76
|
+
}
|
|
67
77
|
}
|
|
68
78
|
}
|
|
69
79
|
else {
|
package/lib/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { JSONSchema4, JSONSchema4Type, JSONSchema6, JSONSchema6Type, JSONSchema7, JSONSchema7Type } from "json-schema";
|
|
1
|
+
import { JSONSchema4, JSONSchema4Object, JSONSchema4Type, JSONSchema6, JSONSchema6Object, JSONSchema6Type, JSONSchema7, JSONSchema7Object, JSONSchema7Type } from "json-schema";
|
|
2
2
|
|
|
3
3
|
export = $RefParser;
|
|
4
4
|
|
|
@@ -174,6 +174,7 @@ declare class $RefParser {
|
|
|
174
174
|
declare namespace $RefParser {
|
|
175
175
|
|
|
176
176
|
export type JSONSchema = JSONSchema4 | JSONSchema6 | JSONSchema7;
|
|
177
|
+
export type JSONSchemaObject = JSONSchema4Object | JSONSchema6Object | JSONSchema7Object;
|
|
177
178
|
export type SchemaCallback = (err: Error | null, schema?: JSONSchema) => any;
|
|
178
179
|
export type $RefsCallback = (err: Error | null, $refs?: $Refs) => any;
|
|
179
180
|
|
|
@@ -231,6 +232,21 @@ declare namespace $RefParser {
|
|
|
231
232
|
* If set to `"ignore"`, then circular references will simply be ignored. No error will be thrown, but the `$Refs.circular` property will still be set to `true`.
|
|
232
233
|
*/
|
|
233
234
|
circular?: boolean | "ignore";
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* A function, called for each path, which can return true to stop this path and all
|
|
238
|
+
* subpaths from being dereferenced further. This is useful in schemas where some
|
|
239
|
+
* subpaths contain literal $ref keys that should not be dereferenced.
|
|
240
|
+
*/
|
|
241
|
+
excludedPathMatcher?(path: string): boolean;
|
|
242
|
+
|
|
243
|
+
/**
|
|
244
|
+
* Callback invoked during dereferencing.
|
|
245
|
+
*
|
|
246
|
+
* @argument {string} path The path being dereferenced (ie. the `$ref` string).
|
|
247
|
+
* @argument {JSONSchemaObject} object The JSON-Schema that the `$ref` resolved to.
|
|
248
|
+
*/
|
|
249
|
+
onDereference(path: string, value: JSONSchemaObject): void;
|
|
234
250
|
};
|
|
235
251
|
}
|
|
236
252
|
|
package/lib/options.js
CHANGED
|
@@ -73,7 +73,16 @@ $RefParserOptions.defaults = {
|
|
|
73
73
|
*
|
|
74
74
|
* @type {boolean|string}
|
|
75
75
|
*/
|
|
76
|
-
circular: true
|
|
76
|
+
circular: true,
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* A function, called for each path, which can return true to stop this path and all
|
|
80
|
+
* subpaths from being dereferenced further. This is useful in schemas where some
|
|
81
|
+
* subpaths contain literal $ref keys that should not be dereferenced.
|
|
82
|
+
*
|
|
83
|
+
* @type {function}
|
|
84
|
+
*/
|
|
85
|
+
excludedPathMatcher: () => false
|
|
77
86
|
},
|
|
78
87
|
};
|
|
79
88
|
|
package/lib/parsers/yaml.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
const { ParserError } = require("../util/errors");
|
|
4
4
|
const yaml = require("js-yaml");
|
|
5
|
+
const { JSON_SCHEMA } = require("js-yaml");
|
|
5
6
|
|
|
6
7
|
module.exports = {
|
|
7
8
|
/**
|
|
@@ -45,7 +46,7 @@ module.exports = {
|
|
|
45
46
|
|
|
46
47
|
if (typeof data === "string") {
|
|
47
48
|
try {
|
|
48
|
-
return yaml.load(data);
|
|
49
|
+
return yaml.load(data, { schema: JSON_SCHEMA });
|
|
49
50
|
}
|
|
50
51
|
catch (e) {
|
|
51
52
|
throw new ParserError(e.message, file.url);
|
package/lib/pointer.js
CHANGED
|
@@ -91,7 +91,7 @@ Pointer.prototype.resolve = function (obj, options, pathFromRoot) {
|
|
|
91
91
|
let token = tokens[i];
|
|
92
92
|
if (this.value[token] === undefined || this.value[token] === null) {
|
|
93
93
|
this.value = null;
|
|
94
|
-
throw new MissingPointerError(token, this.originalPath);
|
|
94
|
+
throw new MissingPointerError(token, decodeURI(this.originalPath));
|
|
95
95
|
}
|
|
96
96
|
else {
|
|
97
97
|
this.value = this.value[token];
|
package/lib/ref.js
CHANGED
|
@@ -135,7 +135,7 @@ $Ref.prototype.resolve = function (path, options, friendlyPath, pathFromRoot) {
|
|
|
135
135
|
if (err instanceof InvalidPointerError) {
|
|
136
136
|
// this is a special case - InvalidPointerError is thrown when dereferencing external file,
|
|
137
137
|
// but the issue is caused by the source file that referenced the file that undergoes dereferencing
|
|
138
|
-
err.source = stripHash(pathFromRoot);
|
|
138
|
+
err.source = decodeURI(stripHash(pathFromRoot));
|
|
139
139
|
}
|
|
140
140
|
|
|
141
141
|
this.addError(err);
|
package/lib/refs.js
CHANGED
|
@@ -4,6 +4,9 @@ const { ono } = require("@jsdevtools/ono");
|
|
|
4
4
|
const $Ref = require("./ref");
|
|
5
5
|
const url = require("./util/url");
|
|
6
6
|
|
|
7
|
+
const isWindows = /^win/.test(globalThis.process ? globalThis.process.platform : undefined);
|
|
8
|
+
const getPathFromOs = filePath => isWindows ? filePath.replace(/\\/g, "/") : filePath;
|
|
9
|
+
|
|
7
10
|
module.exports = $Refs;
|
|
8
11
|
|
|
9
12
|
/**
|
|
@@ -44,7 +47,7 @@ function $Refs () {
|
|
|
44
47
|
$Refs.prototype.paths = function (types) { // eslint-disable-line no-unused-vars
|
|
45
48
|
let paths = getPaths(this._$refs, arguments);
|
|
46
49
|
return paths.map((path) => {
|
|
47
|
-
return path.decoded;
|
|
50
|
+
return getPathFromOs(path.decoded);
|
|
48
51
|
});
|
|
49
52
|
};
|
|
50
53
|
|
|
@@ -58,7 +61,7 @@ $Refs.prototype.values = function (types) { // eslint-disable-line no-unused-v
|
|
|
58
61
|
let $refs = this._$refs;
|
|
59
62
|
let paths = getPaths($refs, arguments);
|
|
60
63
|
return paths.reduce((obj, path) => {
|
|
61
|
-
obj[path.decoded] = $refs[path.encoded].value;
|
|
64
|
+
obj[getPathFromOs(path.decoded)] = $refs[path.encoded].value;
|
|
62
65
|
return obj;
|
|
63
66
|
}, {});
|
|
64
67
|
};
|
package/lib/resolve-external.js
CHANGED
|
@@ -120,7 +120,7 @@ async function resolve$Ref ($ref, path, $refs, options) {
|
|
|
120
120
|
}
|
|
121
121
|
|
|
122
122
|
if ($refs._$refs[withoutHash]) {
|
|
123
|
-
err.source = url.stripHash(path);
|
|
123
|
+
err.source = decodeURI(url.stripHash(path));
|
|
124
124
|
err.path = url.safePointerToPath(url.getHash(path));
|
|
125
125
|
}
|
|
126
126
|
|
package/lib/resolvers/http.js
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
const http = require("http");
|
|
4
|
-
const https = require("https");
|
|
5
3
|
const { ono } = require("@jsdevtools/ono");
|
|
6
4
|
const url = require("../util/url");
|
|
7
5
|
const { ResolverError } = require("../util/errors");
|
|
@@ -75,7 +73,7 @@ module.exports = {
|
|
|
75
73
|
read (file) {
|
|
76
74
|
let u = url.parse(file.url);
|
|
77
75
|
|
|
78
|
-
if (
|
|
76
|
+
if (typeof window !== "undefined" && !u.protocol) {
|
|
79
77
|
// Use the protocol of the current page
|
|
80
78
|
u.protocol = url.parse(location.href).protocol;
|
|
81
79
|
}
|
|
@@ -95,38 +93,36 @@ module.exports = {
|
|
|
95
93
|
* The promise resolves with the raw downloaded data, or rejects if there is an HTTP error.
|
|
96
94
|
*/
|
|
97
95
|
function download (u, httpOptions, redirects) {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
96
|
+
u = url.parse(u);
|
|
97
|
+
redirects = redirects || [];
|
|
98
|
+
redirects.push(u.href);
|
|
99
|
+
|
|
100
|
+
return get(u, httpOptions)
|
|
101
|
+
.then((res) => {
|
|
102
|
+
if (res.status >= 400) {
|
|
103
|
+
throw ono({ status: res.statusCode }, `HTTP ERROR ${res.status}`);
|
|
104
|
+
}
|
|
105
|
+
else if (res.status >= 300) {
|
|
106
|
+
if (redirects.length > httpOptions.redirects) {
|
|
107
|
+
throw new ResolverError(ono({ status: res.status },
|
|
108
|
+
`Error downloading ${redirects[0]}. \nToo many redirects: \n ${redirects.join(" \n ")}`));
|
|
107
109
|
}
|
|
108
|
-
else if (res.
|
|
109
|
-
|
|
110
|
-
reject(new ResolverError(ono({ status: res.statusCode },
|
|
111
|
-
`Error downloading ${redirects[0]}. \nToo many redirects: \n ${redirects.join(" \n ")}`)));
|
|
112
|
-
}
|
|
113
|
-
else if (!res.headers.location) {
|
|
114
|
-
throw ono({ status: res.statusCode }, `HTTP ${res.statusCode} redirect with no location header`);
|
|
115
|
-
}
|
|
116
|
-
else {
|
|
117
|
-
// console.log('HTTP %d redirect %s -> %s', res.statusCode, u.href, res.headers.location);
|
|
118
|
-
let redirectTo = url.resolve(u, res.headers.location);
|
|
119
|
-
download(redirectTo, httpOptions, redirects).then(resolve, reject);
|
|
120
|
-
}
|
|
110
|
+
else if (!res.headers.location) {
|
|
111
|
+
throw ono({ status: res.status }, `HTTP ${res.status} redirect with no location header`);
|
|
121
112
|
}
|
|
122
113
|
else {
|
|
123
|
-
|
|
114
|
+
// console.log('HTTP %d redirect %s -> %s', res.status, u.href, res.headers.location);
|
|
115
|
+
let redirectTo = url.resolve(u, res.headers.location);
|
|
116
|
+
return download(redirectTo, httpOptions, redirects);
|
|
124
117
|
}
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
}
|
|
129
|
-
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
120
|
+
return res.body ? res.arrayBuffer().then(buf => Buffer.from(buf)) : Buffer.alloc(0);
|
|
121
|
+
}
|
|
122
|
+
})
|
|
123
|
+
.catch((err) => {
|
|
124
|
+
throw new ResolverError(ono(err, `Error downloading ${u.href}`), u.href);
|
|
125
|
+
});
|
|
130
126
|
}
|
|
131
127
|
|
|
132
128
|
/**
|
|
@@ -139,42 +135,23 @@ function download (u, httpOptions, redirects) {
|
|
|
139
135
|
* The promise resolves with the HTTP Response object.
|
|
140
136
|
*/
|
|
141
137
|
function get (u, httpOptions) {
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
port: u.port,
|
|
149
|
-
path: u.path,
|
|
150
|
-
auth: u.auth,
|
|
151
|
-
protocol: u.protocol,
|
|
152
|
-
headers: httpOptions.headers || {},
|
|
153
|
-
withCredentials: httpOptions.withCredentials
|
|
154
|
-
});
|
|
138
|
+
let controller;
|
|
139
|
+
let timeoutId;
|
|
140
|
+
if (httpOptions.timeout) {
|
|
141
|
+
controller = new AbortController();
|
|
142
|
+
timeoutId = setTimeout(() => controller.abort(), httpOptions.timeout);
|
|
143
|
+
}
|
|
155
144
|
|
|
156
|
-
|
|
157
|
-
|
|
145
|
+
return fetch(u, {
|
|
146
|
+
method: "GET",
|
|
147
|
+
headers: httpOptions.headers || {},
|
|
148
|
+
credentials: httpOptions.withCredentials ? "include" : "same-origin",
|
|
149
|
+
signal: controller ? controller.signal : null,
|
|
150
|
+
}).then(response => {
|
|
151
|
+
if (timeoutId) {
|
|
152
|
+
clearTimeout(timeoutId);
|
|
158
153
|
}
|
|
159
154
|
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
});
|
|
163
|
-
|
|
164
|
-
req.on("error", reject);
|
|
165
|
-
|
|
166
|
-
req.once("response", (res) => {
|
|
167
|
-
res.body = Buffer.alloc(0);
|
|
168
|
-
|
|
169
|
-
res.on("data", (data) => {
|
|
170
|
-
res.body = Buffer.concat([res.body, Buffer.from(data)]);
|
|
171
|
-
});
|
|
172
|
-
|
|
173
|
-
res.on("error", reject);
|
|
174
|
-
|
|
175
|
-
res.on("end", () => {
|
|
176
|
-
resolve(res);
|
|
177
|
-
});
|
|
178
|
-
});
|
|
179
|
-
}));
|
|
155
|
+
return response;
|
|
156
|
+
});
|
|
180
157
|
}
|
package/lib/util/url.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
const nodePath = require("path");
|
|
4
|
+
const projectDir = nodePath.resolve(__dirname, "..", "..");
|
|
5
|
+
|
|
6
|
+
let isWindows = /^win/.test(globalThis.process ? globalThis.process.platform : undefined),
|
|
4
7
|
forwardSlashPattern = /\//g,
|
|
5
8
|
protocolPattern = /^(\w{2,}):\/\//i,
|
|
6
9
|
url = module.exports,
|
|
@@ -22,8 +25,22 @@ let urlDecodePatterns = [
|
|
|
22
25
|
/\%40/g, "@"
|
|
23
26
|
];
|
|
24
27
|
|
|
25
|
-
exports.parse =
|
|
26
|
-
|
|
28
|
+
exports.parse = (u) => new URL(u);
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Returns resolved target URL relative to a base URL in a manner similar to that of a Web browser resolving an anchor tag HREF.
|
|
32
|
+
*
|
|
33
|
+
* @return {string}
|
|
34
|
+
*/
|
|
35
|
+
exports.resolve = function resolve (from, to) {
|
|
36
|
+
let resolvedUrl = new URL(to, new URL(from, "resolve://"));
|
|
37
|
+
if (resolvedUrl.protocol === "resolve:") {
|
|
38
|
+
// `from` is a relative URL.
|
|
39
|
+
let { pathname, search, hash } = resolvedUrl;
|
|
40
|
+
return pathname + search + hash;
|
|
41
|
+
}
|
|
42
|
+
return resolvedUrl.toString();
|
|
43
|
+
};
|
|
27
44
|
|
|
28
45
|
/**
|
|
29
46
|
* Returns the current working directory (in Node) or the current page URL (in browsers).
|
|
@@ -31,7 +48,7 @@ exports.resolve = require("url").resolve;
|
|
|
31
48
|
* @returns {string}
|
|
32
49
|
*/
|
|
33
50
|
exports.cwd = function cwd () {
|
|
34
|
-
if (
|
|
51
|
+
if (typeof window !== "undefined") {
|
|
35
52
|
return location.href;
|
|
36
53
|
}
|
|
37
54
|
|
|
@@ -130,7 +147,7 @@ exports.isHttp = function isHttp (path) {
|
|
|
130
147
|
}
|
|
131
148
|
else if (protocol === undefined) {
|
|
132
149
|
// There is no protocol. If we're running in a browser, then assume it's HTTP.
|
|
133
|
-
return
|
|
150
|
+
return typeof window !== "undefined";
|
|
134
151
|
}
|
|
135
152
|
else {
|
|
136
153
|
// It's some other protocol, such as "ftp://", "mongodb://", etc.
|
|
@@ -176,7 +193,14 @@ exports.fromFileSystemPath = function fromFileSystemPath (path) {
|
|
|
176
193
|
// Step 1: On Windows, replace backslashes with forward slashes,
|
|
177
194
|
// rather than encoding them as "%5C"
|
|
178
195
|
if (isWindows) {
|
|
179
|
-
|
|
196
|
+
const hasProjectDir = path.toUpperCase().includes(projectDir.replace(/\\/g, "\\").toUpperCase());
|
|
197
|
+
const hasProjectUri = path.toUpperCase().includes(projectDir.replace(/\\/g, "/").toUpperCase());
|
|
198
|
+
if (hasProjectDir || hasProjectUri) {
|
|
199
|
+
path = path.replace(/\\/g, "/");
|
|
200
|
+
}
|
|
201
|
+
else {
|
|
202
|
+
path = `${projectDir}/${path}`.replace(/\\/g, "/");
|
|
203
|
+
}
|
|
180
204
|
}
|
|
181
205
|
|
|
182
206
|
// Step 2: `encodeURI` will take care of MOST characters
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@apidevtools/json-schema-ref-parser",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.1.1",
|
|
4
4
|
"description": "Parse, Resolve, and Dereference JSON Schema $ref pointers",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"json",
|
|
@@ -21,6 +21,10 @@
|
|
|
21
21
|
"name": "Boris Cherny",
|
|
22
22
|
"email": "boris@performancejs.com"
|
|
23
23
|
},
|
|
24
|
+
{
|
|
25
|
+
"name": "Phil Sturgeon",
|
|
26
|
+
"email": "phil@apisyouwonthate.com"
|
|
27
|
+
},
|
|
24
28
|
{
|
|
25
29
|
"name": "Jakub Rożek",
|
|
26
30
|
"email": "jakub@stoplight.io"
|
|
@@ -32,11 +36,15 @@
|
|
|
32
36
|
"url": "https://github.com/APIDevTools/json-schema-ref-parser.git"
|
|
33
37
|
},
|
|
34
38
|
"license": "MIT",
|
|
39
|
+
"funding": "https://github.com/sponsors/philsturgeon",
|
|
35
40
|
"main": "lib/index.js",
|
|
36
41
|
"typings": "lib/index.d.ts",
|
|
37
42
|
"browser": {
|
|
38
43
|
"fs": false
|
|
39
44
|
},
|
|
45
|
+
"engines": {
|
|
46
|
+
"node": ">= 17"
|
|
47
|
+
},
|
|
40
48
|
"files": [
|
|
41
49
|
"lib"
|
|
42
50
|
],
|
|
@@ -46,7 +54,7 @@
|
|
|
46
54
|
"lint": "eslint lib test/fixtures test/specs",
|
|
47
55
|
"test": "npm run test:node && npm run test:typescript && npm run test:browser && npm run lint",
|
|
48
56
|
"test:node": "mocha",
|
|
49
|
-
"test:browser": "karma start --single-run",
|
|
57
|
+
"test:browser": "cross-env NODE_OPTIONS=--openssl-legacy-provider karma start --single-run",
|
|
50
58
|
"test:typescript": "tsc --noEmit --strict --lib esnext,dom test/specs/typescript-definition.spec.ts",
|
|
51
59
|
"coverage": "npm run coverage:node && npm run coverage:browser",
|
|
52
60
|
"coverage:node": "nyc node_modules/mocha/bin/mocha",
|
|
@@ -54,18 +62,22 @@
|
|
|
54
62
|
"upgrade": "npm-check -u && npm audit fix"
|
|
55
63
|
},
|
|
56
64
|
"devDependencies": {
|
|
57
|
-
"@amanda-mitchell/semantic-release-npm-multiple": "^2.5.0",
|
|
58
65
|
"@babel/polyfill": "^7.12.1",
|
|
66
|
+
"@chiragrupani/karma-chromium-edge-launcher": "^2.2.2",
|
|
59
67
|
"@jsdevtools/eslint-config": "^1.0.7",
|
|
60
68
|
"@jsdevtools/host-environment": "^2.1.2",
|
|
61
69
|
"@jsdevtools/karma-config": "^3.1.7",
|
|
62
70
|
"@types/node": "^14.14.21",
|
|
63
|
-
"chai-subset": "^1.6.0",
|
|
64
71
|
"chai": "^4.2.0",
|
|
72
|
+
"chai-subset": "^1.6.0",
|
|
73
|
+
"chokidar": "^3.5.3",
|
|
74
|
+
"cross-env": "^7.0.3",
|
|
65
75
|
"eslint": "^7.18.0",
|
|
66
|
-
"
|
|
76
|
+
"isomorphic-fetch": "^3.0.0",
|
|
67
77
|
"karma": "^5.0.2",
|
|
78
|
+
"karma-cli": "^2.0.0",
|
|
68
79
|
"mocha": "^8.2.1",
|
|
80
|
+
"node-abort-controller": "^3.0.1",
|
|
69
81
|
"npm-check": "^5.9.0",
|
|
70
82
|
"nyc": "^15.0.1",
|
|
71
83
|
"semantic-release-plugin-update-version-in-files": "^1.1.0",
|
|
@@ -94,19 +106,7 @@
|
|
|
94
106
|
"placeholder": "X.X.X"
|
|
95
107
|
}
|
|
96
108
|
],
|
|
97
|
-
|
|
98
|
-
"@amanda-mitchell/semantic-release-npm-multiple",
|
|
99
|
-
{
|
|
100
|
-
"registries": {
|
|
101
|
-
"scoped": {
|
|
102
|
-
"pkgRoot": "."
|
|
103
|
-
},
|
|
104
|
-
"unscoped": {
|
|
105
|
-
"pkgRoot": "dist"
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
],
|
|
109
|
+
"@semantic-release/npm",
|
|
110
110
|
"@semantic-release/github"
|
|
111
111
|
]
|
|
112
112
|
}
|
package/CHANGELOG.md
DELETED
|
@@ -1,182 +0,0 @@
|
|
|
1
|
-
Change Log
|
|
2
|
-
==========
|
|
3
|
-
|
|
4
|
-
See [GitHub Releases](https://github.com/APIDevTools/json-schema-ref-parser/releases) for more information on newer releases.
|
|
5
|
-
|
|
6
|
-
[v9.0.0](https://github.com/APIDevTools/json-schema-ref-parser/tree/v9.0.0) (2020-04-21)
|
|
7
|
-
----------------------------------------------------------------------------------------------------
|
|
8
|
-
|
|
9
|
-
#### Breaking Changes
|
|
10
|
-
|
|
11
|
-
- Removed the `YAML` export. We recommend using [`@stoplight/yaml`](https://www.npmjs.com/package/@stoplight/yaml) instead
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
#### Other Changes
|
|
15
|
-
|
|
16
|
-
- Added a new [`continueOnError` option](https://apitools.dev/json-schema-ref-parser/docs/options) that allows you to get all errors rather than just the first one
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
[Full Changelog](https://github.com/APIDevTools/json-schema-ref-parser/compare/v8.0.0...v9.0.0)
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
[v8.0.0](https://github.com/APIDevTools/json-schema-ref-parser/tree/v8.0.0) (2020-03-13)
|
|
24
|
-
----------------------------------------------------------------------------------------------------
|
|
25
|
-
|
|
26
|
-
- Moved JSON Schema $Ref Parser to the [@APIDevTools scope](https://www.npmjs.com/org/apidevtools) on NPM
|
|
27
|
-
|
|
28
|
-
- The "json-schema-ref-parser" NPM package is now just a wrapper around the scoped "@apidevtools/json-schema-ref-parser" package
|
|
29
|
-
|
|
30
|
-
[Full Changelog](https://github.com/APIDevTools/json-schema-ref-parser/compare/v7.1.4...v8.0.0)
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
[v7.1.0](https://github.com/APIDevTools/json-schema-ref-parser/tree/v7.1.0) (2019-06-21)
|
|
35
|
-
----------------------------------------------------------------------------------------------------
|
|
36
|
-
|
|
37
|
-
- Merged [PR #124](https://github.com/APIDevTools/json-schema-ref-parser/pull/124/), which provides more context to [custom resolvers](https://apitools.dev/json-schema-ref-parser/docs/plugins/resolvers.html).
|
|
38
|
-
|
|
39
|
-
[Full Changelog](https://github.com/APIDevTools/json-schema-ref-parser/compare/v7.0.1...v7.1.0)
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
[v7.0.0](https://github.com/APIDevTools/json-schema-ref-parser/tree/v7.0.0) (2019-06-11)
|
|
44
|
-
----------------------------------------------------------------------------------------------------
|
|
45
|
-
|
|
46
|
-
- Dropped support for Node 6
|
|
47
|
-
|
|
48
|
-
- Updated all code to ES6+ syntax (async/await, template literals, arrow functions, etc.)
|
|
49
|
-
|
|
50
|
-
- No longer including a pre-built bundle in the package. such as [Webpack](https://webpack.js.org/), [Rollup](https://rollupjs.org/), [Parcel](https://parceljs.org/), or [Browserify](http://browserify.org/) to include JSON Schema $Ref Parser in your app
|
|
51
|
-
|
|
52
|
-
[Full Changelog](https://github.com/APIDevTools/json-schema-ref-parser/compare/v6.1.0...v7.0.0)
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
[v6.0.0](https://github.com/APIDevTools/json-schema-ref-parser/tree/v6.0.0) (2018-10-04)
|
|
57
|
-
----------------------------------------------------------------------------------------------------
|
|
58
|
-
|
|
59
|
-
- Dropped support for [Bower](https://www.npmjs.com/package/bower), since it has been deprecated
|
|
60
|
-
|
|
61
|
-
- Removed the [`debug`](https://npmjs.com/package/debug) dependency
|
|
62
|
-
|
|
63
|
-
[Full Changelog](https://github.com/APIDevTools/json-schema-ref-parser/compare/v5.1.0...v6.0.0)
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
[v5.1.0](https://github.com/APIDevTools/json-schema-ref-parser/tree/v5.1.0) (2018-07-11)
|
|
68
|
-
----------------------------------------------------------------------------------------------------
|
|
69
|
-
|
|
70
|
-
- Improved the logic of the [`bundle()` method](https://github.com/APIDevTools/json-schema-ref-parser/blob/master/docs/ref-parser.md#bundleschema-options-callback) to produce shorter reference paths when possible. This is not a breaking change, since both the old reference paths and the new reference paths are valid. The new ones are just shorter. Big thanks to [@hipstersmoothie](https://github.com/hipstersmoothie) for [PR #68](https://github.com/APIDevTools/json-schema-ref-parser/pull/68), which helped a lot with this.
|
|
71
|
-
|
|
72
|
-
[Full Changelog](https://github.com/APIDevTools/json-schema-ref-parser/compare/v5.0.0...v5.1.0)
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
[v5.0.0](https://github.com/APIDevTools/json-schema-ref-parser/tree/v5.0.0) (2018-03-18)
|
|
77
|
-
----------------------------------------------------------------------------------------------------
|
|
78
|
-
|
|
79
|
-
This release contains two bug fixes related to file paths. They are _technically_ breaking changes — hence the major version bump — but they're both edge cases that probably won't affect most users.
|
|
80
|
-
|
|
81
|
-
- Fixed a bug in the [`$refs.paths()`](docs/refs.md#pathstypes) and [`$refs.values()`](docs/refs.md#valuestypes) methods that caused the path of the root schema file to always be represented as a URL, rather than a filesystem path (see [this commit](https://github.com/APIDevTools/json-schema-ref-parser/commit/a95cf50fdf16c864cc1c18d2021d9ce3ec35f5de))
|
|
82
|
-
|
|
83
|
-
- Merged [PR #75](https://github.com/APIDevTools/json-schema-ref-parser/pull/75), which resolves [issue #76](https://github.com/APIDevTools/swagger-parser/issues/76). Error messages no longer include the current working directory path when there is no file path.
|
|
84
|
-
|
|
85
|
-
[Full Changelog](https://github.com/APIDevTools/json-schema-ref-parser/compare/v4.1.1...v5.0.0)
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
[v4.1.0](https://github.com/APIDevTools/json-schema-ref-parser/tree/v4.1.0) (2018-01-17)
|
|
90
|
-
----------------------------------------------------------------------------------------------------
|
|
91
|
-
|
|
92
|
-
- Updated dependencies
|
|
93
|
-
|
|
94
|
-
- Improved the `bundle()` algorithm to favor direct references rather than indirect references (see [PR #62](https://github.com/APIDevTools/json-schema-ref-parser/pull/62) for details). This will produce different bundled output than previous versions for some schemas. Both the old output and the new output are valid, but the new output is arguably better.
|
|
95
|
-
|
|
96
|
-
[Full Changelog](https://github.com/APIDevTools/json-schema-ref-parser/compare/v4.0.0...v4.1.0)
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
[v4.0.0](https://github.com/APIDevTools/json-schema-ref-parser/tree/v4.0.0) (2017-10-13)
|
|
101
|
-
----------------------------------------------------------------------------------------------------
|
|
102
|
-
|
|
103
|
-
#### Breaking Changes
|
|
104
|
-
|
|
105
|
-
- To reduce the size of this library, it no longer includes polyfills for [Promises](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) and [TypedArrays](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray), which are natively supported in the latest versions of Node and web browsers. If you need to support older browsers (such as IE9), then just use [this `Promise` polyfill](https://github.com/stefanpenner/es6-promise) and [this `TypedArray` polyfill](https://github.com/inexorabletash/polyfill/blob/master/typedarray.js).
|
|
106
|
-
|
|
107
|
-
#### Minor Changes
|
|
108
|
-
|
|
109
|
-
- Updated dependencies
|
|
110
|
-
|
|
111
|
-
- [PR #53](https://github.com/APIDevTools/json-schema-ref-parser/pull/53) - Fixes [an edge-case bug](https://github.com/APIDevTools/json-schema-ref-parser/issues/52) with the `bundle()` method
|
|
112
|
-
|
|
113
|
-
[Full Changelog](https://github.com/APIDevTools/json-schema-ref-parser/compare/v3.3.0...v4.0.0)
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
[v3.3.0](https://github.com/APIDevTools/json-schema-ref-parser/tree/v3.3.0) (2017-08-09)
|
|
118
|
-
----------------------------------------------------------------------------------------------------
|
|
119
|
-
|
|
120
|
-
- Updated dependencies
|
|
121
|
-
|
|
122
|
-
- [PR #30](https://github.com/APIDevTools/json-schema-ref-parser/pull/30) - Added a `browser` field to the `package.json` file to support bundlers such as Browserify, Rollup, and Webpack
|
|
123
|
-
|
|
124
|
-
- [PR #45](https://github.com/APIDevTools/json-schema-ref-parser/pull/45) - Implemented a temporary workaround for [issue #42](https://github.com/APIDevTools/json-schema-ref-parser/issues/42). JSON Schema $Ref Parser does _not_ currently support [named internal references](http://json-schema.org/latest/json-schema-core.html#id-keyword), but support will be added in the next major release.
|
|
125
|
-
|
|
126
|
-
[Full Changelog](https://github.com/APIDevTools/json-schema-ref-parser/compare/v3.0.0...v3.3.0)
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
[v3.0.0](https://github.com/APIDevTools/json-schema-ref-parser/tree/v3.0.0) (2016-04-03)
|
|
131
|
-
----------------------------------------------------------------------------------------------------
|
|
132
|
-
|
|
133
|
-
#### Plug-ins !!!
|
|
134
|
-
That's the major new feature in this version. Originally requested in [PR #8](https://github.com/APIDevTools/json-schema-ref-parser/pull/8), and refined a few times over the past few months, the plug-in API is now finalized and ready to use. You can now define your own [resolvers](https://github.com/APIDevTools/json-schema-ref-parser/blob/v3.0.0/docs/plugins/resolvers.md) and [parsers](https://github.com/APIDevTools/json-schema-ref-parser/blob/v3.0.0/docs/plugins/parsers.md).
|
|
135
|
-
|
|
136
|
-
#### Breaking Changes
|
|
137
|
-
The available [options have changed](https://github.com/APIDevTools/json-schema-ref-parser/blob/v3.0.0/docs/options.md), mostly due to the new plug-in API. There's not a one-to-one mapping of old options to new options, so you'll have to read the docs and determine which options you need to set. If any. The out-of-the-box configuration works for most people.
|
|
138
|
-
|
|
139
|
-
All of the [caching options have been removed](https://github.com/APIDevTools/json-schema-ref-parser/commit/1f4260184bfd370e9cd385b523fb08c098fac6db). Instead, all files are now cached, and the entire cache is reset for each new parse operation. Caching options may come back in a future release, if there is enough demand for it. If you used the old caching options, please open an issue and explain your use-case and requirements. I need a better understanding of what caching functionality is actually needed by users.
|
|
140
|
-
|
|
141
|
-
#### Bug Fixes
|
|
142
|
-
Lots of little bug fixes. The only major bug fix is to [support root-level `$ref`s](https://github.com/APIDevTools/json-schema-ref-parser/issues/16)
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
[Full Changelog](https://github.com/APIDevTools/json-schema-ref-parser/compare/v2.2.0...v3.0.0)
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
[v2.2.0](https://github.com/APIDevTools/json-schema-ref-parser/tree/v2.2.0) (2016-01-03)
|
|
150
|
-
----------------------------------------------------------------------------------------------------
|
|
151
|
-
|
|
152
|
-
This version includes a **complete rewrite** of the [`bundle` method](https://github.com/APIDevTools/json-schema-ref-parser/blob/master/docs/ref-parser.md#bundleschema-options-callback) method, mostly to fix [this bug](https://github.com/APIDevTools/swagger-parser/issues/16), but also to address a few [edge-cases](https://github.com/APIDevTools/json-schema-ref-parser/commit/ca9b322879519e4bcb2dcf6e63f08ac254b90868) that weren't handled before. As a side-effect of this rewrite, there was also some pretty significant refactoring and code-cleanup done throughout the codebase.
|
|
153
|
-
|
|
154
|
-
Despite the significant code changes, there were no changes to any public-facing APIs, and [all tests are passing](https://apitools.dev/json-schema-ref-parser/test/) as expected.
|
|
155
|
-
|
|
156
|
-
[Full Changelog](https://github.com/APIDevTools/json-schema-ref-parser/compare/v2.1.0...v2.2.0)
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
[v2.1.0](https://github.com/APIDevTools/json-schema-ref-parser/tree/v2.1.0) (2015-12-31)
|
|
161
|
-
----------------------------------------------------------------------------------------------------
|
|
162
|
-
|
|
163
|
-
JSON Schema $Ref Parser now automatically follows HTTP redirects. This is especially great for servers that automatically "ugrade" your connection from HTTP to HTTPS via a 301 redirect. Now that won't break your code.
|
|
164
|
-
|
|
165
|
-
There are a few [new options](https://github.com/APIDevTools/json-schema-ref-parser/blob/master/docs/options.md) that allow you to set the number of redirects (default is 5) and a few other HTTP request properties.
|
|
166
|
-
|
|
167
|
-
[Full Changelog](https://github.com/APIDevTools/json-schema-ref-parser/compare/v2.0.0...v2.1.0)
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
[v2.0.0](https://github.com/APIDevTools/json-schema-ref-parser/tree/v2.0.0) (2015-12-31)
|
|
172
|
-
----------------------------------------------------------------------------------------------------
|
|
173
|
-
|
|
174
|
-
Bumping the major version number because [this change](https://github.com/APIDevTools/json-schema-ref-parser/pull/5) technically breaks backward-compatibility — although I doubt it will actually affect many people. Basically, if you're using JSON Schema $Ref Parser to download files from a CORS-enabled server that requires authentication, then you'll need to set the `http.withCredentials` option to `true`.
|
|
175
|
-
|
|
176
|
-
```javascript
|
|
177
|
-
$RefParser.dereference('http://some.server.com/file.json', {
|
|
178
|
-
http: { withCredentials: true }
|
|
179
|
-
});
|
|
180
|
-
```
|
|
181
|
-
|
|
182
|
-
[Full Changelog](https://github.com/APIDevTools/json-schema-ref-parser/compare/v1.4.1...v2.0.0)
|