@apidevtools/json-schema-ref-parser 11.4.2 → 11.5.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/lib/bundle.d.ts +5 -2
- package/dist/lib/bundle.js +4 -4
- package/dist/lib/dereference.d.ts +4 -1
- package/dist/lib/dereference.js +6 -7
- package/dist/lib/index.d.ts +54 -53
- package/dist/lib/normalize-args.d.ts +6 -6
- package/dist/lib/normalize-args.js +4 -1
- package/dist/lib/options.d.ts +610 -46
- package/dist/lib/parse.d.ts +3 -2
- package/dist/lib/parse.js +3 -2
- package/dist/lib/pointer.d.ts +6 -5
- package/dist/lib/ref.d.ts +9 -8
- package/dist/lib/ref.js +1 -1
- package/dist/lib/refs.d.ts +14 -14
- package/dist/lib/refs.js +1 -1
- package/dist/lib/resolve-external.d.ts +4 -3
- package/dist/lib/resolve-external.js +4 -4
- package/dist/lib/resolvers/file.d.ts +2 -2
- package/dist/lib/resolvers/http.d.ts +2 -2
- package/dist/lib/types/index.d.ts +5 -5
- package/dist/lib/util/errors.d.ts +6 -4
- package/dist/lib/util/plugins.d.ts +5 -6
- package/lib/bundle.ts +23 -19
- package/lib/dereference.ts +21 -17
- package/lib/index.ts +165 -102
- package/lib/normalize-args.ts +13 -8
- package/lib/options.ts +54 -50
- package/lib/parse.ts +22 -10
- package/lib/pointer.ts +6 -5
- package/lib/ref.ts +12 -11
- package/lib/refs.ts +13 -13
- package/lib/resolve-external.ts +21 -14
- package/lib/resolvers/file.ts +2 -2
- package/lib/resolvers/http.ts +8 -4
- package/lib/types/index.ts +5 -5
- package/lib/util/errors.ts +14 -6
- package/lib/util/plugins.ts +15 -16
- package/package.json +2 -2
package/dist/lib/bundle.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
import type $RefParser from "./index";
|
|
2
|
+
import type { ParserOptions } from "./index";
|
|
3
|
+
import type { JSONSchema } from "./index";
|
|
2
4
|
/**
|
|
3
5
|
* Bundles all external JSON references into the main JSON schema, thus resulting in a schema that
|
|
4
6
|
* only has *internal* references, not any *external* references.
|
|
@@ -7,4 +9,5 @@ export default bundle;
|
|
|
7
9
|
* @param parser
|
|
8
10
|
* @param options
|
|
9
11
|
*/
|
|
10
|
-
declare function bundle(parser:
|
|
12
|
+
declare function bundle<S extends JSONSchema = JSONSchema, O extends ParserOptions = ParserOptions>(parser: $RefParser<S, O>, options: O): void;
|
|
13
|
+
export default bundle;
|
package/dist/lib/bundle.js
CHANGED
|
@@ -29,7 +29,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
29
29
|
const ref_js_1 = __importDefault(require("./ref.js"));
|
|
30
30
|
const pointer_js_1 = __importDefault(require("./pointer.js"));
|
|
31
31
|
const url = __importStar(require("./util/url.js"));
|
|
32
|
-
exports.default = bundle;
|
|
33
32
|
/**
|
|
34
33
|
* Bundles all external JSON references into the main JSON schema, thus resulting in a schema that
|
|
35
34
|
* only has *internal* references, not any *external* references.
|
|
@@ -53,6 +52,7 @@ function bundle(parser, options) {
|
|
|
53
52
|
* @param key - The property key of `parent` to be crawled
|
|
54
53
|
* @param path - The full path of the property being crawled, possibly with a JSON Pointer in the hash
|
|
55
54
|
* @param pathFromRoot - The path of the property being crawled, from the schema root
|
|
55
|
+
* @param indirections
|
|
56
56
|
* @param inventory - An array of already-inventoried $ref pointers
|
|
57
57
|
* @param $refs
|
|
58
58
|
* @param options
|
|
@@ -251,9 +251,8 @@ function remap(inventory) {
|
|
|
251
251
|
* TODO
|
|
252
252
|
*/
|
|
253
253
|
function findInInventory(inventory, $refParent, $refKey) {
|
|
254
|
-
for (
|
|
255
|
-
|
|
256
|
-
if (existingEntry.parent === $refParent && existingEntry.key === $refKey) {
|
|
254
|
+
for (const existingEntry of inventory) {
|
|
255
|
+
if (existingEntry && existingEntry.parent === $refParent && existingEntry.key === $refKey) {
|
|
257
256
|
return existingEntry;
|
|
258
257
|
}
|
|
259
258
|
}
|
|
@@ -262,3 +261,4 @@ function removeFromInventory(inventory, entry) {
|
|
|
262
261
|
const index = inventory.indexOf(entry);
|
|
263
262
|
inventory.splice(index, 1);
|
|
264
263
|
}
|
|
264
|
+
exports.default = bundle;
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import type { ParserOptions } from "./options.js";
|
|
2
|
+
import type { JSONSchema } from "./types";
|
|
3
|
+
import type $RefParser from "./index";
|
|
1
4
|
export default dereference;
|
|
2
5
|
/**
|
|
3
6
|
* Crawls the JSON schema, finds all JSON references, and dereferences them.
|
|
@@ -6,4 +9,4 @@ export default dereference;
|
|
|
6
9
|
* @param parser
|
|
7
10
|
* @param options
|
|
8
11
|
*/
|
|
9
|
-
declare function dereference(parser:
|
|
12
|
+
declare function dereference<S extends JSONSchema = JSONSchema, O extends ParserOptions = ParserOptions>(parser: $RefParser<S, O>, options: O): void;
|
package/dist/lib/dereference.js
CHANGED
|
@@ -63,8 +63,9 @@ function crawl(obj, path, pathFromRoot, parents, processedObjects, dereferencedC
|
|
|
63
63
|
value: obj,
|
|
64
64
|
circular: false,
|
|
65
65
|
};
|
|
66
|
-
const
|
|
67
|
-
|
|
66
|
+
const derefOptions = (options.dereference || {});
|
|
67
|
+
const isExcludedPath = derefOptions.excludedPathMatcher || (() => false);
|
|
68
|
+
if (derefOptions?.circular === "ignore" || !processedObjects.has(obj)) {
|
|
68
69
|
if (obj && typeof obj === "object" && !ArrayBuffer.isView(obj) && !isExcludedPath(pathFromRoot)) {
|
|
69
70
|
parents.add(obj);
|
|
70
71
|
processedObjects.add(obj);
|
|
@@ -88,9 +89,7 @@ function crawl(obj, path, pathFromRoot, parents, processedObjects, dereferencedC
|
|
|
88
89
|
// Avoid pointless mutations; breaks frozen objects to no profit
|
|
89
90
|
if (obj[key] !== dereferenced.value) {
|
|
90
91
|
obj[key] = dereferenced.value;
|
|
91
|
-
|
|
92
|
-
options.dereference.onDereference(value.$ref, obj[key], obj, key);
|
|
93
|
-
}
|
|
92
|
+
derefOptions?.onDereference?.(value.$ref, obj[key], obj, key);
|
|
94
93
|
}
|
|
95
94
|
}
|
|
96
95
|
else {
|
|
@@ -130,7 +129,7 @@ function crawl(obj, path, pathFromRoot, parents, processedObjects, dereferencedC
|
|
|
130
129
|
*/
|
|
131
130
|
function dereference$Ref($ref, path, pathFromRoot, parents, processedObjects, dereferencedCache, $refs, options) {
|
|
132
131
|
const isExternalRef = ref_js_1.default.isExternal$Ref($ref);
|
|
133
|
-
const shouldResolveOnCwd = isExternalRef && options?.dereference
|
|
132
|
+
const shouldResolveOnCwd = isExternalRef && options?.dereference?.externalReferenceResolution === "root";
|
|
134
133
|
const $refPath = url.resolve(shouldResolveOnCwd ? url.cwd() : path, $ref.$ref);
|
|
135
134
|
const cache = dereferencedCache.get($refPath);
|
|
136
135
|
if (cache) {
|
|
@@ -170,7 +169,7 @@ function dereference$Ref($ref, path, pathFromRoot, parents, processedObjects, de
|
|
|
170
169
|
circular = dereferenced.circular;
|
|
171
170
|
dereferencedValue = dereferenced.value;
|
|
172
171
|
}
|
|
173
|
-
if (circular && !directCircular && options.dereference
|
|
172
|
+
if (circular && !directCircular && options.dereference?.circular === "ignore") {
|
|
174
173
|
// The user has chosen to "ignore" circular references, so don't change the value
|
|
175
174
|
dereferencedValue = $ref;
|
|
176
175
|
}
|
package/dist/lib/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import $Refs from "./refs.js";
|
|
2
2
|
import { JSONParserError, InvalidPointerError, MissingPointerError, ResolverError, ParserError, UnmatchedParserError, UnmatchedResolverError, isHandledError, JSONParserErrorGroup } from "./util/errors.js";
|
|
3
3
|
import type { ParserOptions } from "./options.js";
|
|
4
|
-
import type { $RefsCallback, JSONSchema, SchemaCallback } from "./types/index.js";
|
|
4
|
+
import type { $RefsCallback, JSONSchema, SchemaCallback, FileInfo, Plugin, ResolverOptions, HTTPResolverOptions } from "./types/index.js";
|
|
5
5
|
export type RefParserSchema = string | JSONSchema;
|
|
6
6
|
/**
|
|
7
7
|
* This class parses a JSON schema, builds a map of its JSON references and their resolved values,
|
|
@@ -9,21 +9,21 @@ export type RefParserSchema = string | JSONSchema;
|
|
|
9
9
|
*
|
|
10
10
|
* @class
|
|
11
11
|
*/
|
|
12
|
-
export declare class $RefParser {
|
|
12
|
+
export declare class $RefParser<S extends JSONSchema = JSONSchema, O extends ParserOptions = ParserOptions> {
|
|
13
13
|
/**
|
|
14
14
|
* The parsed (and possibly dereferenced) JSON schema object
|
|
15
15
|
*
|
|
16
16
|
* @type {object}
|
|
17
17
|
* @readonly
|
|
18
18
|
*/
|
|
19
|
-
schema:
|
|
19
|
+
schema: S | null;
|
|
20
20
|
/**
|
|
21
21
|
* The resolved JSON references
|
|
22
22
|
*
|
|
23
23
|
* @type {$Refs}
|
|
24
24
|
* @readonly
|
|
25
25
|
*/
|
|
26
|
-
$refs: $Refs
|
|
26
|
+
$refs: $Refs<S>;
|
|
27
27
|
/**
|
|
28
28
|
* Parses the given JSON schema.
|
|
29
29
|
* This method does not resolve any JSON references.
|
|
@@ -35,18 +35,18 @@ export declare class $RefParser {
|
|
|
35
35
|
* @param [callback] - An error-first callback. The second parameter is the parsed JSON schema object.
|
|
36
36
|
* @returns - The returned promise resolves with the parsed JSON schema object.
|
|
37
37
|
*/
|
|
38
|
-
parse(schema:
|
|
39
|
-
parse(schema:
|
|
40
|
-
parse(schema:
|
|
41
|
-
parse(schema:
|
|
42
|
-
parse(baseUrl: string, schema:
|
|
43
|
-
parse(baseUrl: string, schema:
|
|
44
|
-
static parse(schema:
|
|
45
|
-
static parse(schema:
|
|
46
|
-
static parse(schema:
|
|
47
|
-
static parse(schema:
|
|
48
|
-
static parse(baseUrl: string, schema:
|
|
49
|
-
static parse(baseUrl: string, schema:
|
|
38
|
+
parse(schema: S | string): Promise<S>;
|
|
39
|
+
parse(schema: S | string, callback: SchemaCallback<S>): Promise<void>;
|
|
40
|
+
parse(schema: S | string, options: O): Promise<S>;
|
|
41
|
+
parse(schema: S | string, options: O, callback: SchemaCallback<S>): Promise<void>;
|
|
42
|
+
parse(baseUrl: string, schema: S | string, options: O): Promise<S>;
|
|
43
|
+
parse(baseUrl: string, schema: S | string, options: O, callback: SchemaCallback<S>): Promise<void>;
|
|
44
|
+
static parse<S extends JSONSchema = JSONSchema>(schema: S | string): Promise<S>;
|
|
45
|
+
static parse<S extends JSONSchema = JSONSchema>(schema: S | string, callback: SchemaCallback<S>): Promise<void>;
|
|
46
|
+
static parse<S extends JSONSchema = JSONSchema, O extends ParserOptions = ParserOptions>(schema: S | string, options: O): Promise<S>;
|
|
47
|
+
static parse<S extends JSONSchema = JSONSchema, O extends ParserOptions = ParserOptions>(schema: S | string, options: O, callback: SchemaCallback<S>): Promise<void>;
|
|
48
|
+
static parse<S extends JSONSchema = JSONSchema, O extends ParserOptions = ParserOptions>(baseUrl: string, schema: S | string, options: O): Promise<S>;
|
|
49
|
+
static parse<S extends JSONSchema = JSONSchema, O extends ParserOptions = ParserOptions>(baseUrl: string, schema: S | string, options: O, callback: SchemaCallback<S>): Promise<void>;
|
|
50
50
|
/**
|
|
51
51
|
* *This method is used internally by other methods, such as `bundle` and `dereference`. You probably won't need to call this method yourself.*
|
|
52
52
|
*
|
|
@@ -58,12 +58,12 @@ export declare class $RefParser {
|
|
|
58
58
|
* @param options (optional)
|
|
59
59
|
* @param callback (optional) A callback that will receive a `$Refs` object
|
|
60
60
|
*/
|
|
61
|
-
resolve(schema:
|
|
62
|
-
resolve(schema:
|
|
63
|
-
resolve(schema:
|
|
64
|
-
resolve(schema:
|
|
65
|
-
resolve(baseUrl: string, schema:
|
|
66
|
-
resolve(baseUrl: string, schema:
|
|
61
|
+
resolve(schema: S | string): Promise<$Refs<S>>;
|
|
62
|
+
resolve(schema: S | string, callback: $RefsCallback<S>): Promise<void>;
|
|
63
|
+
resolve(schema: S | string, options: O): Promise<$Refs<S>>;
|
|
64
|
+
resolve(schema: S | string, options: O, callback: $RefsCallback<S>): Promise<void>;
|
|
65
|
+
resolve(baseUrl: string, schema: S | string, options: O): Promise<$Refs<S>>;
|
|
66
|
+
resolve(baseUrl: string, schema: S | string, options: O, callback: $RefsCallback<S>): Promise<void>;
|
|
67
67
|
/**
|
|
68
68
|
* *This method is used internally by other methods, such as `bundle` and `dereference`. You probably won't need to call this method yourself.*
|
|
69
69
|
*
|
|
@@ -75,12 +75,12 @@ export declare class $RefParser {
|
|
|
75
75
|
* @param options (optional)
|
|
76
76
|
* @param callback (optional) A callback that will receive a `$Refs` object
|
|
77
77
|
*/
|
|
78
|
-
static resolve(schema:
|
|
79
|
-
static resolve(schema:
|
|
80
|
-
static resolve(schema:
|
|
81
|
-
static resolve(schema:
|
|
82
|
-
static resolve(baseUrl: string, schema:
|
|
83
|
-
static resolve(baseUrl: string, schema:
|
|
78
|
+
static resolve<S extends JSONSchema = JSONSchema>(schema: S | string): Promise<$Refs<S>>;
|
|
79
|
+
static resolve<S extends JSONSchema = JSONSchema>(schema: S | string, callback: $RefsCallback<S>): Promise<void>;
|
|
80
|
+
static resolve<S extends JSONSchema = JSONSchema, O extends ParserOptions = ParserOptions>(schema: S | string, options: O): Promise<$Refs<S>>;
|
|
81
|
+
static resolve<S extends JSONSchema = JSONSchema, O extends ParserOptions = ParserOptions>(schema: S | string, options: O, callback: $RefsCallback<S>): Promise<void>;
|
|
82
|
+
static resolve<S extends JSONSchema = JSONSchema, O extends ParserOptions = ParserOptions>(baseUrl: string, schema: S | string, options: O): Promise<$Refs<S>>;
|
|
83
|
+
static resolve<S extends JSONSchema = JSONSchema, O extends ParserOptions = ParserOptions>(baseUrl: string, schema: S | string, options: O, callback: $RefsCallback<S>): Promise<void>;
|
|
84
84
|
/**
|
|
85
85
|
* Bundles all referenced files/URLs into a single schema that only has internal `$ref` pointers. This lets you split-up your schema however you want while you're building it, but easily combine all those files together when it's time to package or distribute the schema to other people. The resulting schema size will be small, since it will still contain internal JSON references rather than being fully-dereferenced.
|
|
86
86
|
*
|
|
@@ -92,12 +92,12 @@ export declare class $RefParser {
|
|
|
92
92
|
* @param options (optional)
|
|
93
93
|
* @param callback (optional) A callback that will receive the bundled schema object
|
|
94
94
|
*/
|
|
95
|
-
static bundle(schema:
|
|
96
|
-
static bundle(schema:
|
|
97
|
-
static bundle(schema:
|
|
98
|
-
static bundle(schema:
|
|
99
|
-
static bundle(baseUrl: string, schema:
|
|
100
|
-
static bundle(baseUrl: string, schema:
|
|
95
|
+
static bundle<S extends JSONSchema = JSONSchema, O extends ParserOptions = ParserOptions>(schema: S | string): Promise<S>;
|
|
96
|
+
static bundle<S extends JSONSchema = JSONSchema, O extends ParserOptions = ParserOptions>(schema: S | string, callback: SchemaCallback<S>): Promise<void>;
|
|
97
|
+
static bundle<S extends JSONSchema = JSONSchema, O extends ParserOptions = ParserOptions>(schema: S | string, options: O): Promise<S>;
|
|
98
|
+
static bundle<S extends JSONSchema = JSONSchema, O extends ParserOptions = ParserOptions>(schema: S | string, options: O, callback: SchemaCallback<S>): Promise<void>;
|
|
99
|
+
static bundle<S extends JSONSchema = JSONSchema, O extends ParserOptions = ParserOptions>(baseUrl: string, schema: S | string, options: O): Promise<S>;
|
|
100
|
+
static bundle<S extends JSONSchema = JSONSchema, O extends ParserOptions = ParserOptions>(baseUrl: string, schema: S | string, options: O, callback: SchemaCallback<S>): Promise<S>;
|
|
101
101
|
/**
|
|
102
102
|
* Bundles all referenced files/URLs into a single schema that only has internal `$ref` pointers. This lets you split-up your schema however you want while you're building it, but easily combine all those files together when it's time to package or distribute the schema to other people. The resulting schema size will be small, since it will still contain internal JSON references rather than being fully-dereferenced.
|
|
103
103
|
*
|
|
@@ -109,12 +109,12 @@ export declare class $RefParser {
|
|
|
109
109
|
* @param options (optional)
|
|
110
110
|
* @param callback (optional) A callback that will receive the bundled schema object
|
|
111
111
|
*/
|
|
112
|
-
bundle(schema:
|
|
113
|
-
bundle(schema:
|
|
114
|
-
bundle(schema:
|
|
115
|
-
bundle(schema:
|
|
116
|
-
bundle(baseUrl: string, schema:
|
|
117
|
-
bundle(baseUrl: string, schema:
|
|
112
|
+
bundle(schema: S | string): Promise<S>;
|
|
113
|
+
bundle(schema: S | string, callback: SchemaCallback<S>): Promise<void>;
|
|
114
|
+
bundle(schema: S | string, options: O): Promise<S>;
|
|
115
|
+
bundle(schema: S | string, options: O, callback: SchemaCallback<S>): Promise<void>;
|
|
116
|
+
bundle(baseUrl: string, schema: S | string, options: O): Promise<S>;
|
|
117
|
+
bundle(baseUrl: string, schema: S | string, options: O, callback: SchemaCallback<S>): Promise<void>;
|
|
118
118
|
/**
|
|
119
119
|
* Dereferences all `$ref` pointers in the JSON Schema, replacing each reference with its resolved value. This results in a schema object that does not contain any `$ref` pointers. Instead, it's a normal JavaScript object tree that can easily be crawled and used just like any other JavaScript object. This is great for programmatic usage, especially when using tools that don't understand JSON references.
|
|
120
120
|
*
|
|
@@ -126,12 +126,12 @@ export declare class $RefParser {
|
|
|
126
126
|
* @param options (optional)
|
|
127
127
|
* @param callback (optional) A callback that will receive the dereferenced schema object
|
|
128
128
|
*/
|
|
129
|
-
static dereference(schema:
|
|
130
|
-
static dereference(schema:
|
|
131
|
-
static dereference(schema:
|
|
132
|
-
static dereference(schema:
|
|
133
|
-
static dereference(baseUrl: string, schema:
|
|
134
|
-
static dereference(baseUrl: string, schema:
|
|
129
|
+
static dereference<S extends JSONSchema = JSONSchema, O extends ParserOptions = ParserOptions>(schema: S | string): Promise<S>;
|
|
130
|
+
static dereference<S extends JSONSchema = JSONSchema, O extends ParserOptions = ParserOptions>(schema: S | string, callback: SchemaCallback<S>): Promise<void>;
|
|
131
|
+
static dereference<S extends JSONSchema = JSONSchema, O extends ParserOptions = ParserOptions>(schema: S | string, options: O): Promise<S>;
|
|
132
|
+
static dereference<S extends JSONSchema = JSONSchema, O extends ParserOptions = ParserOptions>(schema: S | string, options: O, callback: SchemaCallback<S>): Promise<void>;
|
|
133
|
+
static dereference<S extends JSONSchema = JSONSchema, O extends ParserOptions = ParserOptions>(baseUrl: string, schema: S | string, options: O): Promise<S>;
|
|
134
|
+
static dereference<S extends JSONSchema = JSONSchema, O extends ParserOptions = ParserOptions>(baseUrl: string, schema: S | string, options: O, callback: SchemaCallback<S>): Promise<void>;
|
|
135
135
|
/**
|
|
136
136
|
* Dereferences all `$ref` pointers in the JSON Schema, replacing each reference with its resolved value. This results in a schema object that does not contain any `$ref` pointers. Instead, it's a normal JavaScript object tree that can easily be crawled and used just like any other JavaScript object. This is great for programmatic usage, especially when using tools that don't understand JSON references.
|
|
137
137
|
*
|
|
@@ -139,20 +139,21 @@ export declare class $RefParser {
|
|
|
139
139
|
*
|
|
140
140
|
* See https://apitools.dev/json-schema-ref-parser/docs/ref-parser.html#dereferenceschema-options-callback
|
|
141
141
|
*
|
|
142
|
+
* @param baseUrl
|
|
142
143
|
* @param schema A JSON Schema object, or the file path or URL of a JSON Schema file. See the `parse` method for more info.
|
|
143
144
|
* @param options (optional)
|
|
144
145
|
* @param callback (optional) A callback that will receive the dereferenced schema object
|
|
145
146
|
*/
|
|
146
|
-
dereference(baseUrl: string, schema:
|
|
147
|
-
dereference(schema:
|
|
148
|
-
dereference(schema:
|
|
149
|
-
dereference(baseUrl: string, schema:
|
|
150
|
-
dereference(schema:
|
|
151
|
-
dereference(schema:
|
|
147
|
+
dereference(baseUrl: string, schema: S | string, options: O, callback: SchemaCallback<S>): Promise<void>;
|
|
148
|
+
dereference(schema: S | string, options: O, callback: SchemaCallback<S>): Promise<void>;
|
|
149
|
+
dereference(schema: S | string, callback: SchemaCallback<S>): Promise<void>;
|
|
150
|
+
dereference(baseUrl: string, schema: S | string, options: O): Promise<S>;
|
|
151
|
+
dereference(schema: S | string, options: O): Promise<S>;
|
|
152
|
+
dereference(schema: S | string): Promise<S>;
|
|
152
153
|
}
|
|
153
154
|
export default $RefParser;
|
|
154
155
|
export declare const parse: typeof $RefParser.parse;
|
|
155
156
|
export declare const resolve: typeof $RefParser.resolve;
|
|
156
157
|
export declare const bundle: typeof $RefParser.bundle;
|
|
157
158
|
export declare const dereference: typeof $RefParser.dereference;
|
|
158
|
-
export { UnmatchedResolverError, JSONParserError, JSONSchema, InvalidPointerError, MissingPointerError, ResolverError, ParserError, UnmatchedParserError, ParserOptions, $RefsCallback, isHandledError, JSONParserErrorGroup, SchemaCallback, };
|
|
159
|
+
export { UnmatchedResolverError, JSONParserError, JSONSchema, InvalidPointerError, MissingPointerError, ResolverError, ParserError, UnmatchedParserError, ParserOptions, $RefsCallback, isHandledError, JSONParserErrorGroup, SchemaCallback, FileInfo, Plugin, ResolverOptions, HTTPResolverOptions, };
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
+
import type { Options, ParserOptions } from "./options.js";
|
|
1
2
|
import type { JSONSchema, SchemaCallback } from "./types";
|
|
2
|
-
|
|
3
|
-
export interface NormalizedArguments<T = $RefParserOptions> {
|
|
3
|
+
export interface NormalizedArguments<S extends JSONSchema = JSONSchema, O extends ParserOptions = ParserOptions> {
|
|
4
4
|
path: string;
|
|
5
|
-
schema:
|
|
6
|
-
options:
|
|
7
|
-
callback: SchemaCallback
|
|
5
|
+
schema: S;
|
|
6
|
+
options: O & Options;
|
|
7
|
+
callback: SchemaCallback<S>;
|
|
8
8
|
}
|
|
9
9
|
/**
|
|
10
10
|
* Normalizes the given arguments, accounting for optional args.
|
|
11
11
|
*/
|
|
12
|
-
export declare function normalizeArgs<
|
|
12
|
+
export declare function normalizeArgs<S extends JSONSchema = JSONSchema, O extends ParserOptions = ParserOptions>(_args: Partial<IArguments>): NormalizedArguments<S, O>;
|
|
13
13
|
export default normalizeArgs;
|
|
@@ -6,7 +6,10 @@ const options_js_1 = require("./options.js");
|
|
|
6
6
|
* Normalizes the given arguments, accounting for optional args.
|
|
7
7
|
*/
|
|
8
8
|
function normalizeArgs(_args) {
|
|
9
|
-
let path
|
|
9
|
+
let path;
|
|
10
|
+
let schema;
|
|
11
|
+
let options;
|
|
12
|
+
let callback;
|
|
10
13
|
const args = Array.prototype.slice.call(_args);
|
|
11
14
|
if (typeof args[args.length - 1] === "function") {
|
|
12
15
|
// The last parameter is a callback function
|