@apidevtools/json-schema-ref-parser 11.4.1 → 11.4.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/dist/lib/index.d.ts +0 -42
- package/dist/lib/index.js +0 -13
- package/dist/lib/normalize-args.d.ts +4 -4
- package/dist/lib/normalize-args.js +3 -1
- package/lib/index.ts +0 -55
- package/lib/normalize-args.ts +5 -5
- package/package.json +1 -1
package/dist/lib/index.d.ts
CHANGED
|
@@ -81,17 +81,6 @@ export declare class $RefParser {
|
|
|
81
81
|
static resolve(schema: RefParserSchema, options: ParserOptions, callback: $RefsCallback): Promise<void>;
|
|
82
82
|
static resolve(baseUrl: string, schema: RefParserSchema, options: ParserOptions): Promise<$Refs>;
|
|
83
83
|
static resolve(baseUrl: string, schema: RefParserSchema, options: ParserOptions, callback: $RefsCallback): Promise<void>;
|
|
84
|
-
/**
|
|
85
|
-
* Parses the given JSON schema, resolves any JSON references, and bundles all external references
|
|
86
|
-
* into the main JSON schema. This produces a JSON schema that only has *internal* references,
|
|
87
|
-
* not any *external* references.
|
|
88
|
-
*
|
|
89
|
-
* @param [path] - The file path or URL of the JSON schema
|
|
90
|
-
* @param [schema] - A JSON schema object. This object will be used instead of reading from `path`.
|
|
91
|
-
* @param [options] - Options that determine how the schema is parsed, resolved, and dereferenced
|
|
92
|
-
* @param [callback] - An error-first callback. The second parameter is the bundled JSON schema object
|
|
93
|
-
* @returns - The returned promise resolves with the bundled JSON schema object.
|
|
94
|
-
*/
|
|
95
84
|
/**
|
|
96
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.
|
|
97
86
|
*
|
|
@@ -109,17 +98,6 @@ export declare class $RefParser {
|
|
|
109
98
|
static bundle(schema: RefParserSchema, options: ParserOptions, callback: SchemaCallback): Promise<void>;
|
|
110
99
|
static bundle(baseUrl: string, schema: RefParserSchema, options: ParserOptions): Promise<JSONSchema>;
|
|
111
100
|
static bundle(baseUrl: string, schema: RefParserSchema, options: ParserOptions, callback: SchemaCallback): Promise<JSONSchema>;
|
|
112
|
-
/**
|
|
113
|
-
* Parses the given JSON schema, resolves any JSON references, and bundles all external references
|
|
114
|
-
* into the main JSON schema. This produces a JSON schema that only has *internal* references,
|
|
115
|
-
* not any *external* references.
|
|
116
|
-
*
|
|
117
|
-
* @param [path] - The file path or URL of the JSON schema
|
|
118
|
-
* @param [schema] - A JSON schema object. This object will be used instead of reading from `path`.
|
|
119
|
-
* @param [options] - Options that determine how the schema is parsed, resolved, and dereferenced
|
|
120
|
-
* @param [callback] - An error-first callback. The second parameter is the bundled JSON schema object
|
|
121
|
-
* @returns - The returned promise resolves with the bundled JSON schema object.
|
|
122
|
-
*/
|
|
123
101
|
/**
|
|
124
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.
|
|
125
103
|
*
|
|
@@ -137,16 +115,6 @@ export declare class $RefParser {
|
|
|
137
115
|
bundle(schema: RefParserSchema, options: ParserOptions, callback: SchemaCallback): Promise<void>;
|
|
138
116
|
bundle(baseUrl: string, schema: RefParserSchema, options: ParserOptions): Promise<JSONSchema>;
|
|
139
117
|
bundle(baseUrl: string, schema: RefParserSchema, options: ParserOptions, callback: SchemaCallback): Promise<void>;
|
|
140
|
-
/**
|
|
141
|
-
* Parses the given JSON schema, resolves any JSON references, and dereferences the JSON schema.
|
|
142
|
-
* That is, all JSON references are replaced with their resolved values.
|
|
143
|
-
*
|
|
144
|
-
* @param [path] - The file path or URL of the JSON schema
|
|
145
|
-
* @param [schema] - A JSON schema object. This object will be used instead of reading from `path`.
|
|
146
|
-
* @param [options] - Options that determine how the schema is parsed, resolved, and dereferenced
|
|
147
|
-
* @param [callback] - An error-first callback. The second parameter is the dereferenced JSON schema object
|
|
148
|
-
* @returns - The returned promise resolves with the dereferenced JSON schema object.
|
|
149
|
-
*/
|
|
150
118
|
/**
|
|
151
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.
|
|
152
120
|
*
|
|
@@ -164,16 +132,6 @@ export declare class $RefParser {
|
|
|
164
132
|
static dereference(schema: RefParserSchema, options: ParserOptions, callback: SchemaCallback): Promise<void>;
|
|
165
133
|
static dereference(baseUrl: string, schema: RefParserSchema, options: ParserOptions): Promise<JSONSchema>;
|
|
166
134
|
static dereference(baseUrl: string, schema: RefParserSchema, options: ParserOptions, callback: SchemaCallback): Promise<void>;
|
|
167
|
-
/**
|
|
168
|
-
* Parses the given JSON schema, resolves any JSON references, and dereferences the JSON schema.
|
|
169
|
-
* That is, all JSON references are replaced with their resolved values.
|
|
170
|
-
*
|
|
171
|
-
* @param [path] - The file path or URL of the JSON schema
|
|
172
|
-
* @param [schema] - A JSON schema object. This object will be used instead of reading from `path`.
|
|
173
|
-
* @param [options] - Options that determine how the schema is parsed, resolved, and dereferenced
|
|
174
|
-
* @param [callback] - An error-first callback. The second parameter is the dereferenced JSON schema object
|
|
175
|
-
* @returns - The returned promise resolves with the dereferenced JSON schema object.
|
|
176
|
-
*/
|
|
177
135
|
/**
|
|
178
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.
|
|
179
137
|
*
|
package/dist/lib/index.js
CHANGED
|
@@ -139,19 +139,6 @@ class $RefParser {
|
|
|
139
139
|
const parser = new $RefParser();
|
|
140
140
|
return parser.parse.apply(parser, arguments);
|
|
141
141
|
}
|
|
142
|
-
/**
|
|
143
|
-
* Parses the given JSON schema and resolves any JSON references, including references in
|
|
144
|
-
* externally-referenced files.
|
|
145
|
-
*
|
|
146
|
-
* @param [path] - The file path or URL of the JSON schema
|
|
147
|
-
* @param [schema] - A JSON schema object. This object will be used instead of reading from `path`.
|
|
148
|
-
* @param [options] - Options that determine how the schema is parsed and resolved
|
|
149
|
-
* @param [callback]
|
|
150
|
-
* - An error-first callback. The second parameter is a {@link $Refs} object containing the resolved JSON references
|
|
151
|
-
*
|
|
152
|
-
* @returns
|
|
153
|
-
* The returned promise resolves with a {@link $Refs} object containing the resolved JSON references
|
|
154
|
-
*/
|
|
155
142
|
async resolve() {
|
|
156
143
|
const args = (0, normalize_args_js_1.default)(arguments);
|
|
157
144
|
try {
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import type { JSONSchema, SchemaCallback } from "./types";
|
|
2
2
|
import type $RefParserOptions from "./options";
|
|
3
|
-
export
|
|
4
|
-
export interface NormalizedArguments {
|
|
3
|
+
export interface NormalizedArguments<T = $RefParserOptions> {
|
|
5
4
|
path: string;
|
|
6
5
|
schema: JSONSchema;
|
|
7
|
-
options:
|
|
6
|
+
options: T;
|
|
8
7
|
callback: SchemaCallback;
|
|
9
8
|
}
|
|
10
9
|
/**
|
|
11
10
|
* Normalizes the given arguments, accounting for optional args.
|
|
12
11
|
*/
|
|
13
|
-
declare function normalizeArgs(_args: Partial<IArguments>): NormalizedArguments
|
|
12
|
+
export declare function normalizeArgs<T = $RefParserOptions>(_args: Partial<IArguments>): NormalizedArguments<T>;
|
|
13
|
+
export default normalizeArgs;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.normalizeArgs = void 0;
|
|
3
4
|
const options_js_1 = require("./options.js");
|
|
4
|
-
exports.default = normalizeArgs;
|
|
5
5
|
/**
|
|
6
6
|
* Normalizes the given arguments, accounting for optional args.
|
|
7
7
|
*/
|
|
@@ -49,3 +49,5 @@ function normalizeArgs(_args) {
|
|
|
49
49
|
callback,
|
|
50
50
|
};
|
|
51
51
|
}
|
|
52
|
+
exports.normalizeArgs = normalizeArgs;
|
|
53
|
+
exports.default = normalizeArgs;
|
package/lib/index.ts
CHANGED
|
@@ -178,19 +178,6 @@ export class $RefParser {
|
|
|
178
178
|
options: ParserOptions,
|
|
179
179
|
callback: $RefsCallback,
|
|
180
180
|
): Promise<void>;
|
|
181
|
-
/**
|
|
182
|
-
* Parses the given JSON schema and resolves any JSON references, including references in
|
|
183
|
-
* externally-referenced files.
|
|
184
|
-
*
|
|
185
|
-
* @param [path] - The file path or URL of the JSON schema
|
|
186
|
-
* @param [schema] - A JSON schema object. This object will be used instead of reading from `path`.
|
|
187
|
-
* @param [options] - Options that determine how the schema is parsed and resolved
|
|
188
|
-
* @param [callback]
|
|
189
|
-
* - An error-first callback. The second parameter is a {@link $Refs} object containing the resolved JSON references
|
|
190
|
-
*
|
|
191
|
-
* @returns
|
|
192
|
-
* The returned promise resolves with a {@link $Refs} object containing the resolved JSON references
|
|
193
|
-
*/
|
|
194
181
|
async resolve() {
|
|
195
182
|
const args = normalizeArgs(arguments);
|
|
196
183
|
|
|
@@ -231,17 +218,6 @@ export class $RefParser {
|
|
|
231
218
|
return instance.resolve.apply(instance, arguments as any);
|
|
232
219
|
}
|
|
233
220
|
|
|
234
|
-
/**
|
|
235
|
-
* Parses the given JSON schema, resolves any JSON references, and bundles all external references
|
|
236
|
-
* into the main JSON schema. This produces a JSON schema that only has *internal* references,
|
|
237
|
-
* not any *external* references.
|
|
238
|
-
*
|
|
239
|
-
* @param [path] - The file path or URL of the JSON schema
|
|
240
|
-
* @param [schema] - A JSON schema object. This object will be used instead of reading from `path`.
|
|
241
|
-
* @param [options] - Options that determine how the schema is parsed, resolved, and dereferenced
|
|
242
|
-
* @param [callback] - An error-first callback. The second parameter is the bundled JSON schema object
|
|
243
|
-
* @returns - The returned promise resolves with the bundled JSON schema object.
|
|
244
|
-
*/
|
|
245
221
|
/**
|
|
246
222
|
* 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.
|
|
247
223
|
*
|
|
@@ -269,17 +245,6 @@ export class $RefParser {
|
|
|
269
245
|
return instance.bundle.apply(instance, arguments as any);
|
|
270
246
|
}
|
|
271
247
|
|
|
272
|
-
/**
|
|
273
|
-
* Parses the given JSON schema, resolves any JSON references, and bundles all external references
|
|
274
|
-
* into the main JSON schema. This produces a JSON schema that only has *internal* references,
|
|
275
|
-
* not any *external* references.
|
|
276
|
-
*
|
|
277
|
-
* @param [path] - The file path or URL of the JSON schema
|
|
278
|
-
* @param [schema] - A JSON schema object. This object will be used instead of reading from `path`.
|
|
279
|
-
* @param [options] - Options that determine how the schema is parsed, resolved, and dereferenced
|
|
280
|
-
* @param [callback] - An error-first callback. The second parameter is the bundled JSON schema object
|
|
281
|
-
* @returns - The returned promise resolves with the bundled JSON schema object.
|
|
282
|
-
*/
|
|
283
248
|
/**
|
|
284
249
|
* 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.
|
|
285
250
|
*
|
|
@@ -314,16 +279,6 @@ export class $RefParser {
|
|
|
314
279
|
}
|
|
315
280
|
}
|
|
316
281
|
|
|
317
|
-
/**
|
|
318
|
-
* Parses the given JSON schema, resolves any JSON references, and dereferences the JSON schema.
|
|
319
|
-
* That is, all JSON references are replaced with their resolved values.
|
|
320
|
-
*
|
|
321
|
-
* @param [path] - The file path or URL of the JSON schema
|
|
322
|
-
* @param [schema] - A JSON schema object. This object will be used instead of reading from `path`.
|
|
323
|
-
* @param [options] - Options that determine how the schema is parsed, resolved, and dereferenced
|
|
324
|
-
* @param [callback] - An error-first callback. The second parameter is the dereferenced JSON schema object
|
|
325
|
-
* @returns - The returned promise resolves with the dereferenced JSON schema object.
|
|
326
|
-
*/
|
|
327
282
|
/**
|
|
328
283
|
* 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.
|
|
329
284
|
*
|
|
@@ -351,16 +306,6 @@ export class $RefParser {
|
|
|
351
306
|
return instance.dereference.apply(instance, arguments as any);
|
|
352
307
|
}
|
|
353
308
|
|
|
354
|
-
/**
|
|
355
|
-
* Parses the given JSON schema, resolves any JSON references, and dereferences the JSON schema.
|
|
356
|
-
* That is, all JSON references are replaced with their resolved values.
|
|
357
|
-
*
|
|
358
|
-
* @param [path] - The file path or URL of the JSON schema
|
|
359
|
-
* @param [schema] - A JSON schema object. This object will be used instead of reading from `path`.
|
|
360
|
-
* @param [options] - Options that determine how the schema is parsed, resolved, and dereferenced
|
|
361
|
-
* @param [callback] - An error-first callback. The second parameter is the dereferenced JSON schema object
|
|
362
|
-
* @returns - The returned promise resolves with the dereferenced JSON schema object.
|
|
363
|
-
*/
|
|
364
309
|
/**
|
|
365
310
|
* 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.
|
|
366
311
|
*
|
package/lib/normalize-args.ts
CHANGED
|
@@ -2,20 +2,18 @@ import { getNewOptions } from "./options.js";
|
|
|
2
2
|
import type { JSONSchema, SchemaCallback } from "./types";
|
|
3
3
|
import type $RefParserOptions from "./options";
|
|
4
4
|
|
|
5
|
-
export default normalizeArgs;
|
|
6
|
-
|
|
7
5
|
// I really dislike this function and the way it's written. It's not clear what it's doing, and it's way too flexible
|
|
8
6
|
// In the future, I'd like to deprecate the api and accept only named parameters in index.ts
|
|
9
|
-
export interface NormalizedArguments {
|
|
7
|
+
export interface NormalizedArguments<T = $RefParserOptions> {
|
|
10
8
|
path: string;
|
|
11
9
|
schema: JSONSchema;
|
|
12
|
-
options:
|
|
10
|
+
options: T;
|
|
13
11
|
callback: SchemaCallback;
|
|
14
12
|
}
|
|
15
13
|
/**
|
|
16
14
|
* Normalizes the given arguments, accounting for optional args.
|
|
17
15
|
*/
|
|
18
|
-
function normalizeArgs(_args: Partial<IArguments>): NormalizedArguments {
|
|
16
|
+
export function normalizeArgs<T = $RefParserOptions>(_args: Partial<IArguments>): NormalizedArguments<T> {
|
|
19
17
|
let path, schema, options, callback;
|
|
20
18
|
const args = Array.prototype.slice.call(_args) as any[];
|
|
21
19
|
|
|
@@ -61,3 +59,5 @@ function normalizeArgs(_args: Partial<IArguments>): NormalizedArguments {
|
|
|
61
59
|
callback,
|
|
62
60
|
};
|
|
63
61
|
}
|
|
62
|
+
|
|
63
|
+
export default normalizeArgs;
|