@apidevtools/json-schema-ref-parser 11.7.3 → 11.8.2
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 +4 -8
- package/cjs/bundle.js +304 -0
- package/cjs/dereference.js +258 -0
- package/cjs/index.js +603 -0
- package/cjs/normalize-args.js +64 -0
- package/cjs/options.js +125 -0
- package/cjs/package.json +3 -0
- package/cjs/parse.js +338 -0
- package/cjs/parsers/binary.js +54 -0
- package/cjs/parsers/json.js +199 -0
- package/cjs/parsers/text.js +61 -0
- package/cjs/parsers/yaml.js +239 -0
- package/cjs/pointer.js +290 -0
- package/cjs/ref.js +333 -0
- package/cjs/refs.js +214 -0
- package/cjs/resolve-external.js +333 -0
- package/cjs/resolvers/file.js +106 -0
- package/cjs/resolvers/http.js +184 -0
- package/cjs/util/errors.js +401 -0
- package/cjs/util/plugins.js +159 -0
- package/cjs/util/projectDir.cjs +6 -0
- package/cjs/util/url.js +228 -0
- package/dist/lib/dereference.js +3 -1
- package/dist/lib/index.d.ts +6 -6
- package/dist/lib/options.d.ts +7 -0
- package/dist/lib/pointer.js +7 -1
- package/dist/lib/util/errors.d.ts +5 -1
- package/dist/lib/util/errors.js +5 -1
- package/dist/lib/util/plugins.d.ts +2 -2
- package/dist/lib/util/url.js +3 -2
- package/lib/dereference.ts +4 -1
- package/lib/index.ts +6 -12
- package/lib/options.ts +7 -0
- package/lib/pointer.ts +12 -1
- package/lib/util/errors.ts +10 -1
- package/lib/util/plugins.ts +6 -7
- package/lib/util/url.ts +3 -2
- package/package.json +27 -27
package/lib/util/errors.ts
CHANGED
|
@@ -123,8 +123,17 @@ export class UnmatchedResolverError extends JSONParserError {
|
|
|
123
123
|
export class MissingPointerError extends JSONParserError {
|
|
124
124
|
code = "EMISSINGPOINTER" as JSONParserErrorType;
|
|
125
125
|
name = "MissingPointerError";
|
|
126
|
-
|
|
126
|
+
public targetToken: any;
|
|
127
|
+
public targetRef: string;
|
|
128
|
+
public targetFound: string;
|
|
129
|
+
public parentPath: string;
|
|
130
|
+
constructor(token: any, path: any, targetRef: any, targetFound: any, parentPath: any) {
|
|
127
131
|
super(`Missing $ref pointer "${getHash(path)}". Token "${token}" does not exist.`, stripHash(path));
|
|
132
|
+
|
|
133
|
+
this.targetToken = token;
|
|
134
|
+
this.targetRef = targetRef;
|
|
135
|
+
this.targetFound = targetFound;
|
|
136
|
+
this.parentPath = parentPath;
|
|
128
137
|
}
|
|
129
138
|
}
|
|
130
139
|
|
package/lib/util/plugins.ts
CHANGED
|
@@ -45,8 +45,7 @@ export function sort(plugins: Plugin[]) {
|
|
|
45
45
|
});
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
|
|
49
|
-
export interface PluginResult<S extends object = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>> {
|
|
48
|
+
export interface PluginResult<S extends object = JSONSchema> {
|
|
50
49
|
plugin: Plugin;
|
|
51
50
|
result?: string | Buffer | S;
|
|
52
51
|
error?: any;
|
|
@@ -67,10 +66,10 @@ export async function run<S extends object = JSONSchema, O extends ParserOptions
|
|
|
67
66
|
$refs: $Refs<S, O>,
|
|
68
67
|
) {
|
|
69
68
|
let plugin: Plugin;
|
|
70
|
-
let lastError: PluginResult<S
|
|
69
|
+
let lastError: PluginResult<S>;
|
|
71
70
|
let index = 0;
|
|
72
71
|
|
|
73
|
-
return new Promise<PluginResult<S
|
|
72
|
+
return new Promise<PluginResult<S>>((resolve, reject) => {
|
|
74
73
|
runNextPlugin();
|
|
75
74
|
|
|
76
75
|
function runNextPlugin() {
|
|
@@ -97,7 +96,7 @@ export async function run<S extends object = JSONSchema, O extends ParserOptions
|
|
|
97
96
|
}
|
|
98
97
|
}
|
|
99
98
|
|
|
100
|
-
function callback(err: PluginResult<S
|
|
99
|
+
function callback(err: PluginResult<S>["error"], result: PluginResult<S>["result"]) {
|
|
101
100
|
if (err) {
|
|
102
101
|
onError(err);
|
|
103
102
|
} else {
|
|
@@ -105,7 +104,7 @@ export async function run<S extends object = JSONSchema, O extends ParserOptions
|
|
|
105
104
|
}
|
|
106
105
|
}
|
|
107
106
|
|
|
108
|
-
function onSuccess(result: PluginResult<S
|
|
107
|
+
function onSuccess(result: PluginResult<S>["result"]) {
|
|
109
108
|
// console.log(' success');
|
|
110
109
|
resolve({
|
|
111
110
|
plugin,
|
|
@@ -113,7 +112,7 @@ export async function run<S extends object = JSONSchema, O extends ParserOptions
|
|
|
113
112
|
});
|
|
114
113
|
}
|
|
115
114
|
|
|
116
|
-
function onError(error: PluginResult<S
|
|
115
|
+
function onError(error: PluginResult<S>["error"]) {
|
|
117
116
|
// console.log(' %s', err.message || err);
|
|
118
117
|
lastError = {
|
|
119
118
|
plugin,
|
package/lib/util/url.ts
CHANGED
|
@@ -26,10 +26,11 @@ export const parse = (u: string | URL) => new URL(u);
|
|
|
26
26
|
* @returns
|
|
27
27
|
*/
|
|
28
28
|
export function resolve(from: string, to: string) {
|
|
29
|
-
|
|
29
|
+
// we use a non-existent URL to check if its a relative URL
|
|
30
|
+
const fromUrl = new URL(convertPathToPosix(from), "https://aaa.nonexistanturl.com");
|
|
30
31
|
const resolvedUrl = new URL(convertPathToPosix(to), fromUrl);
|
|
31
32
|
const endSpaces = to.match(/(\s*)$/)?.[1] || "";
|
|
32
|
-
if (resolvedUrl.
|
|
33
|
+
if (resolvedUrl.hostname === "aaa.nonexistanturl.com") {
|
|
33
34
|
// `from` is a relative URL.
|
|
34
35
|
const { pathname, search, hash } = resolvedUrl;
|
|
35
36
|
return pathname + search + hash + endSpaces;
|
package/package.json
CHANGED
|
@@ -1,7 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@apidevtools/json-schema-ref-parser",
|
|
3
|
-
"version": "11.
|
|
3
|
+
"version": "11.8.2",
|
|
4
4
|
"description": "Parse, Resolve, and Dereference JSON Schema $ref pointers",
|
|
5
|
+
"scripts": {
|
|
6
|
+
"prepublishOnly": "yarn build",
|
|
7
|
+
"lint": "eslint lib",
|
|
8
|
+
"build": "rimraf dist && tsc",
|
|
9
|
+
"typecheck": "tsc --noEmit",
|
|
10
|
+
"prettier": "prettier --write \"**/*.+(js|jsx|ts|tsx|har||json|css|md)\"",
|
|
11
|
+
"test": "vitest --coverage",
|
|
12
|
+
"test:node": "yarn test",
|
|
13
|
+
"test:browser": "cross-env BROWSER=\"true\" yarn test",
|
|
14
|
+
"test:update": "vitest -u",
|
|
15
|
+
"test:watch": "vitest -w"
|
|
16
|
+
},
|
|
5
17
|
"keywords": [
|
|
6
18
|
"json",
|
|
7
19
|
"schema",
|
|
@@ -54,42 +66,30 @@
|
|
|
54
66
|
"dist",
|
|
55
67
|
"cjs"
|
|
56
68
|
],
|
|
57
|
-
"scripts": {
|
|
58
|
-
"prepublishOnly": "yarn build",
|
|
59
|
-
"lint": "eslint lib",
|
|
60
|
-
"build": "rimraf dist && tsc",
|
|
61
|
-
"typecheck": "tsc --noEmit",
|
|
62
|
-
"prettier": "prettier --write \"**/*.+(js|jsx|ts|tsx|har||json|css|md)\"",
|
|
63
|
-
"test": "vitest --coverage",
|
|
64
|
-
"test:node": "yarn test",
|
|
65
|
-
"test:browser": "cross-env BROWSER=\"true\" yarn test",
|
|
66
|
-
"test:update": "vitest -u",
|
|
67
|
-
"test:watch": "vitest -w"
|
|
68
|
-
},
|
|
69
69
|
"devDependencies": {
|
|
70
|
-
"@eslint/compat": "^1.2.
|
|
71
|
-
"@eslint/js": "^9.
|
|
72
|
-
"@types/eslint": "9.6.1",
|
|
70
|
+
"@eslint/compat": "^1.2.5",
|
|
71
|
+
"@eslint/js": "^9.18.0",
|
|
72
|
+
"@types/eslint": "^9.6.1",
|
|
73
73
|
"@types/js-yaml": "^4.0.9",
|
|
74
74
|
"@types/node": "^22",
|
|
75
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
76
|
-
"@typescript-eslint/parser": "^8.
|
|
77
|
-
"@vitest/coverage-v8": "^
|
|
75
|
+
"@typescript-eslint/eslint-plugin": "^8.21.0",
|
|
76
|
+
"@typescript-eslint/parser": "^8.21.0",
|
|
77
|
+
"@vitest/coverage-v8": "^3.0.4",
|
|
78
78
|
"cross-env": "^7.0.3",
|
|
79
|
-
"eslint": "^9.
|
|
80
|
-
"eslint-config-prettier": "^
|
|
79
|
+
"eslint": "^9.18.0",
|
|
80
|
+
"eslint-config-prettier": "^10.0.1",
|
|
81
81
|
"eslint-config-standard": "^17.1.0",
|
|
82
82
|
"eslint-plugin-import": "^2.31.0",
|
|
83
|
-
"eslint-plugin-prettier": "^5.2.
|
|
83
|
+
"eslint-plugin-prettier": "^5.2.3",
|
|
84
84
|
"eslint-plugin-promise": "^7.2.1",
|
|
85
85
|
"eslint-plugin-unused-imports": "^4.1.4",
|
|
86
|
-
"globals": "^15.
|
|
87
|
-
"jsdom": "^
|
|
86
|
+
"globals": "^15.14.0",
|
|
87
|
+
"jsdom": "^26.0.0",
|
|
88
88
|
"prettier": "^3.4.2",
|
|
89
89
|
"rimraf": "^6.0.1",
|
|
90
|
-
"typescript": "^5.7.
|
|
91
|
-
"typescript-eslint": "^8.
|
|
92
|
-
"vitest": "^
|
|
90
|
+
"typescript": "^5.7.3",
|
|
91
|
+
"typescript-eslint": "^8.21.0",
|
|
92
|
+
"vitest": "^3.0.4"
|
|
93
93
|
},
|
|
94
94
|
"dependencies": {
|
|
95
95
|
"@jsdevtools/ono": "^7.1.3",
|