@apidevtools/json-schema-ref-parser 11.5.0 → 11.5.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/normalize-args.d.ts +1 -1
- package/dist/lib/options.d.ts +565 -2
- package/dist/lib/pointer.d.ts +1 -1
- package/dist/lib/ref.d.ts +2 -2
- package/dist/lib/refs.d.ts +5 -5
- package/dist/lib/refs.js +2 -2
- package/dist/lib/types/index.d.ts +4 -4
- package/dist/lib/util/plugins.d.ts +4 -4
- package/lib/bundle.ts +2 -2
- package/lib/normalize-args.ts +1 -1
- package/lib/options.ts +4 -2
- package/lib/pointer.ts +1 -1
- package/lib/ref.ts +2 -2
- package/lib/refs.ts +7 -7
- package/lib/resolvers/http.ts +2 -2
- package/lib/types/index.ts +4 -4
- package/lib/util/errors.ts +1 -1
- package/lib/util/plugins.ts +5 -5
- package/package.json +2 -2
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Options, ParserOptions } from "./options.js";
|
|
2
2
|
import type { JSONSchema, SchemaCallback } from "./types";
|
|
3
|
-
export interface NormalizedArguments<S, O> {
|
|
3
|
+
export interface NormalizedArguments<S extends JSONSchema = JSONSchema, O extends ParserOptions = ParserOptions> {
|
|
4
4
|
path: string;
|
|
5
5
|
schema: S;
|
|
6
6
|
options: O & Options;
|
package/dist/lib/options.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
1
2
|
import type { HTTPResolverOptions, JSONSchema, JSONSchemaObject, Plugin, ResolverOptions } from "./types/index.js";
|
|
2
3
|
export type DeepPartial<T> = T extends object ? {
|
|
3
4
|
[P in keyof T]?: DeepPartial<T[P]>;
|
|
@@ -39,7 +40,7 @@ export interface DereferenceOptions {
|
|
|
39
40
|
* @param [options] - Overridden options
|
|
40
41
|
* @class
|
|
41
42
|
*/
|
|
42
|
-
export interface $RefParserOptions<S> {
|
|
43
|
+
export interface $RefParserOptions<S extends JSONSchema = JSONSchema> {
|
|
43
44
|
/**
|
|
44
45
|
* The `parse` options determine how different types of files will be parsed.
|
|
45
46
|
*
|
|
@@ -87,7 +88,569 @@ export interface $RefParserOptions<S> {
|
|
|
87
88
|
mutateInputSchema?: boolean;
|
|
88
89
|
}
|
|
89
90
|
export declare const getJsonSchemaRefParserDefaultOptions: () => $RefParserOptions<JSONSchema>;
|
|
90
|
-
export declare const getNewOptions: <S
|
|
91
|
+
export declare const getNewOptions: <S extends JSONSchema = JSONSchema, O extends {
|
|
92
|
+
parse?: {
|
|
93
|
+
[x: string]: boolean | {
|
|
94
|
+
name?: string | undefined;
|
|
95
|
+
order?: number | undefined;
|
|
96
|
+
allowEmpty?: boolean | undefined;
|
|
97
|
+
allowBOM?: boolean | undefined;
|
|
98
|
+
encoding?: BufferEncoding | undefined;
|
|
99
|
+
canParse?: string | boolean | {
|
|
100
|
+
exec?: {} | undefined;
|
|
101
|
+
test?: {} | undefined;
|
|
102
|
+
readonly source?: string | undefined;
|
|
103
|
+
readonly global?: boolean | undefined;
|
|
104
|
+
readonly ignoreCase?: boolean | undefined;
|
|
105
|
+
readonly multiline?: boolean | undefined;
|
|
106
|
+
lastIndex?: number | undefined;
|
|
107
|
+
compile?: {} | undefined;
|
|
108
|
+
readonly flags?: string | undefined;
|
|
109
|
+
readonly sticky?: boolean | undefined;
|
|
110
|
+
readonly unicode?: boolean | undefined;
|
|
111
|
+
readonly dotAll?: boolean | undefined;
|
|
112
|
+
readonly hasIndices?: boolean | undefined;
|
|
113
|
+
[Symbol.match]?: {} | undefined;
|
|
114
|
+
[Symbol.replace]?: {} | undefined;
|
|
115
|
+
[Symbol.search]?: {} | undefined;
|
|
116
|
+
[Symbol.split]?: {} | undefined;
|
|
117
|
+
[Symbol.matchAll]?: {} | undefined;
|
|
118
|
+
} | (string | undefined)[] | {} | undefined;
|
|
119
|
+
parse?: string | number | {} | undefined;
|
|
120
|
+
} | undefined;
|
|
121
|
+
json?: boolean | {
|
|
122
|
+
name?: string | undefined;
|
|
123
|
+
order?: number | undefined;
|
|
124
|
+
allowEmpty?: boolean | undefined;
|
|
125
|
+
allowBOM?: boolean | undefined;
|
|
126
|
+
encoding?: BufferEncoding | undefined;
|
|
127
|
+
canParse?: string | boolean | {
|
|
128
|
+
exec?: {} | undefined;
|
|
129
|
+
test?: {} | undefined;
|
|
130
|
+
readonly source?: string | undefined;
|
|
131
|
+
readonly global?: boolean | undefined;
|
|
132
|
+
readonly ignoreCase?: boolean | undefined;
|
|
133
|
+
readonly multiline?: boolean | undefined;
|
|
134
|
+
lastIndex?: number | undefined;
|
|
135
|
+
compile?: {} | undefined;
|
|
136
|
+
readonly flags?: string | undefined;
|
|
137
|
+
readonly sticky?: boolean | undefined;
|
|
138
|
+
readonly unicode?: boolean | undefined;
|
|
139
|
+
readonly dotAll?: boolean | undefined;
|
|
140
|
+
readonly hasIndices?: boolean | undefined;
|
|
141
|
+
[Symbol.match]?: {} | undefined;
|
|
142
|
+
[Symbol.replace]?: {} | undefined;
|
|
143
|
+
[Symbol.search]?: {} | undefined;
|
|
144
|
+
[Symbol.split]?: {} | undefined;
|
|
145
|
+
[Symbol.matchAll]?: {} | undefined;
|
|
146
|
+
} | (string | undefined)[] | {} | undefined;
|
|
147
|
+
parse?: string | number | {} | undefined;
|
|
148
|
+
} | undefined;
|
|
149
|
+
yaml?: boolean | {
|
|
150
|
+
name?: string | undefined;
|
|
151
|
+
order?: number | undefined;
|
|
152
|
+
allowEmpty?: boolean | undefined;
|
|
153
|
+
allowBOM?: boolean | undefined;
|
|
154
|
+
encoding?: BufferEncoding | undefined;
|
|
155
|
+
canParse?: string | boolean | {
|
|
156
|
+
exec?: {} | undefined;
|
|
157
|
+
test?: {} | undefined;
|
|
158
|
+
readonly source?: string | undefined;
|
|
159
|
+
readonly global?: boolean | undefined;
|
|
160
|
+
readonly ignoreCase?: boolean | undefined;
|
|
161
|
+
readonly multiline?: boolean | undefined;
|
|
162
|
+
lastIndex?: number | undefined;
|
|
163
|
+
compile?: {} | undefined;
|
|
164
|
+
readonly flags?: string | undefined;
|
|
165
|
+
readonly sticky?: boolean | undefined;
|
|
166
|
+
readonly unicode?: boolean | undefined;
|
|
167
|
+
readonly dotAll?: boolean | undefined;
|
|
168
|
+
readonly hasIndices?: boolean | undefined;
|
|
169
|
+
[Symbol.match]?: {} | undefined;
|
|
170
|
+
[Symbol.replace]?: {} | undefined;
|
|
171
|
+
[Symbol.search]?: {} | undefined;
|
|
172
|
+
[Symbol.split]?: {} | undefined;
|
|
173
|
+
[Symbol.matchAll]?: {} | undefined;
|
|
174
|
+
} | (string | undefined)[] | {} | undefined;
|
|
175
|
+
parse?: string | number | {} | undefined;
|
|
176
|
+
} | undefined;
|
|
177
|
+
binary?: boolean | {
|
|
178
|
+
name?: string | undefined;
|
|
179
|
+
order?: number | undefined;
|
|
180
|
+
allowEmpty?: boolean | undefined;
|
|
181
|
+
allowBOM?: boolean | undefined;
|
|
182
|
+
encoding?: BufferEncoding | undefined;
|
|
183
|
+
canParse?: string | boolean | {
|
|
184
|
+
exec?: {} | undefined;
|
|
185
|
+
test?: {} | undefined;
|
|
186
|
+
readonly source?: string | undefined;
|
|
187
|
+
readonly global?: boolean | undefined;
|
|
188
|
+
readonly ignoreCase?: boolean | undefined;
|
|
189
|
+
readonly multiline?: boolean | undefined;
|
|
190
|
+
lastIndex?: number | undefined;
|
|
191
|
+
compile?: {} | undefined;
|
|
192
|
+
readonly flags?: string | undefined;
|
|
193
|
+
readonly sticky?: boolean | undefined;
|
|
194
|
+
readonly unicode?: boolean | undefined;
|
|
195
|
+
readonly dotAll?: boolean | undefined;
|
|
196
|
+
readonly hasIndices?: boolean | undefined;
|
|
197
|
+
[Symbol.match]?: {} | undefined;
|
|
198
|
+
[Symbol.replace]?: {} | undefined;
|
|
199
|
+
[Symbol.search]?: {} | undefined;
|
|
200
|
+
[Symbol.split]?: {} | undefined;
|
|
201
|
+
[Symbol.matchAll]?: {} | undefined;
|
|
202
|
+
} | (string | undefined)[] | {} | undefined;
|
|
203
|
+
parse?: string | number | {} | undefined;
|
|
204
|
+
} | undefined;
|
|
205
|
+
text?: boolean | {
|
|
206
|
+
name?: string | undefined;
|
|
207
|
+
order?: number | undefined;
|
|
208
|
+
allowEmpty?: boolean | undefined;
|
|
209
|
+
allowBOM?: boolean | undefined;
|
|
210
|
+
encoding?: "ascii" | "utf8" | "utf-8" | "utf16le" | "ucs2" | "ucs-2" | "base64" | "base64url" | "latin1" | "binary" | "hex" | undefined;
|
|
211
|
+
canParse?: string | boolean | {
|
|
212
|
+
exec?: {} | undefined;
|
|
213
|
+
test?: {} | undefined;
|
|
214
|
+
readonly source?: string | undefined;
|
|
215
|
+
readonly global?: boolean | undefined;
|
|
216
|
+
readonly ignoreCase?: boolean | undefined;
|
|
217
|
+
readonly multiline?: boolean | undefined;
|
|
218
|
+
lastIndex?: number | undefined;
|
|
219
|
+
compile?: {} | undefined;
|
|
220
|
+
readonly flags?: string | undefined;
|
|
221
|
+
readonly sticky?: boolean | undefined;
|
|
222
|
+
readonly unicode?: boolean | undefined;
|
|
223
|
+
readonly dotAll?: boolean | undefined;
|
|
224
|
+
readonly hasIndices?: boolean | undefined;
|
|
225
|
+
[Symbol.match]?: {} | undefined;
|
|
226
|
+
[Symbol.replace]?: {} | undefined;
|
|
227
|
+
[Symbol.search]?: {} | undefined;
|
|
228
|
+
[Symbol.split]?: {} | undefined;
|
|
229
|
+
[Symbol.matchAll]?: {} | undefined;
|
|
230
|
+
} | (string | undefined)[] | {} | undefined;
|
|
231
|
+
parse?: string | number | {} | undefined;
|
|
232
|
+
} | undefined;
|
|
233
|
+
} | undefined;
|
|
234
|
+
resolve?: {
|
|
235
|
+
[x: string]: boolean | {
|
|
236
|
+
name?: string | undefined;
|
|
237
|
+
order?: number | undefined;
|
|
238
|
+
canRead?: string | boolean | {
|
|
239
|
+
exec?: {} | undefined;
|
|
240
|
+
test?: {} | undefined;
|
|
241
|
+
readonly source?: string | undefined;
|
|
242
|
+
readonly global?: boolean | undefined;
|
|
243
|
+
readonly ignoreCase?: boolean | undefined;
|
|
244
|
+
readonly multiline?: boolean | undefined;
|
|
245
|
+
lastIndex?: number | undefined;
|
|
246
|
+
compile?: {} | undefined;
|
|
247
|
+
readonly flags?: string | undefined;
|
|
248
|
+
readonly sticky?: boolean | undefined;
|
|
249
|
+
readonly unicode?: boolean | undefined;
|
|
250
|
+
readonly dotAll?: boolean | undefined;
|
|
251
|
+
readonly hasIndices?: boolean | undefined;
|
|
252
|
+
[Symbol.match]?: {} | undefined;
|
|
253
|
+
[Symbol.replace]?: {} | undefined;
|
|
254
|
+
[Symbol.search]?: {} | undefined;
|
|
255
|
+
[Symbol.split]?: {} | undefined;
|
|
256
|
+
[Symbol.matchAll]?: {} | undefined;
|
|
257
|
+
} | (string | undefined)[] | {} | undefined;
|
|
258
|
+
read?: string | object | {} | undefined;
|
|
259
|
+
} | {
|
|
260
|
+
headers?: ([(string | undefined)?, (string | undefined)?] | undefined)[] | {
|
|
261
|
+
[x: string]: string | undefined;
|
|
262
|
+
} | {
|
|
263
|
+
append?: {} | undefined;
|
|
264
|
+
delete?: {} | undefined;
|
|
265
|
+
get?: {} | undefined;
|
|
266
|
+
getSetCookie?: {} | undefined;
|
|
267
|
+
has?: {} | undefined;
|
|
268
|
+
set?: {} | undefined;
|
|
269
|
+
forEach?: {} | undefined;
|
|
270
|
+
} | null | undefined;
|
|
271
|
+
timeout?: number | undefined;
|
|
272
|
+
redirects?: number | undefined;
|
|
273
|
+
withCredentials?: boolean | undefined;
|
|
274
|
+
name?: string | undefined;
|
|
275
|
+
order?: number | undefined;
|
|
276
|
+
canRead?: string | boolean | {
|
|
277
|
+
exec?: {} | undefined;
|
|
278
|
+
test?: {} | undefined;
|
|
279
|
+
readonly source?: string | undefined;
|
|
280
|
+
readonly global?: boolean | undefined;
|
|
281
|
+
readonly ignoreCase?: boolean | undefined;
|
|
282
|
+
readonly multiline?: boolean | undefined;
|
|
283
|
+
lastIndex?: number | undefined;
|
|
284
|
+
compile?: {} | undefined;
|
|
285
|
+
readonly flags?: string | undefined;
|
|
286
|
+
readonly sticky?: boolean | undefined;
|
|
287
|
+
readonly unicode?: boolean | undefined;
|
|
288
|
+
readonly dotAll?: boolean | undefined;
|
|
289
|
+
readonly hasIndices?: boolean | undefined;
|
|
290
|
+
[Symbol.match]?: {} | undefined;
|
|
291
|
+
[Symbol.replace]?: {} | undefined;
|
|
292
|
+
[Symbol.search]?: {} | undefined;
|
|
293
|
+
[Symbol.split]?: {} | undefined;
|
|
294
|
+
[Symbol.matchAll]?: {} | undefined;
|
|
295
|
+
} | (string | undefined)[] | {} | undefined;
|
|
296
|
+
read?: string | object | {} | undefined;
|
|
297
|
+
} | undefined;
|
|
298
|
+
external?: boolean | undefined;
|
|
299
|
+
file?: boolean | {
|
|
300
|
+
name?: string | undefined;
|
|
301
|
+
order?: number | undefined;
|
|
302
|
+
canRead?: string | boolean | {
|
|
303
|
+
exec?: {} | undefined;
|
|
304
|
+
test?: {} | undefined;
|
|
305
|
+
readonly source?: string | undefined;
|
|
306
|
+
readonly global?: boolean | undefined;
|
|
307
|
+
readonly ignoreCase?: boolean | undefined;
|
|
308
|
+
readonly multiline?: boolean | undefined;
|
|
309
|
+
lastIndex?: number | undefined;
|
|
310
|
+
compile?: {} | undefined;
|
|
311
|
+
readonly flags?: string | undefined;
|
|
312
|
+
readonly sticky?: boolean | undefined;
|
|
313
|
+
readonly unicode?: boolean | undefined;
|
|
314
|
+
readonly dotAll?: boolean | undefined;
|
|
315
|
+
readonly hasIndices?: boolean | undefined;
|
|
316
|
+
[Symbol.match]?: {} | undefined;
|
|
317
|
+
[Symbol.replace]?: {} | undefined;
|
|
318
|
+
[Symbol.search]?: {} | undefined;
|
|
319
|
+
[Symbol.split]?: {} | undefined;
|
|
320
|
+
[Symbol.matchAll]?: {} | undefined;
|
|
321
|
+
} | (string | undefined)[] | {} | undefined;
|
|
322
|
+
read?: string | object | {} | undefined;
|
|
323
|
+
} | undefined;
|
|
324
|
+
http?: boolean | {
|
|
325
|
+
headers?: ([(string | undefined)?, (string | undefined)?] | undefined)[] | {
|
|
326
|
+
[x: string]: string | undefined;
|
|
327
|
+
} | {
|
|
328
|
+
append?: {} | undefined;
|
|
329
|
+
delete?: {} | undefined;
|
|
330
|
+
get?: {} | undefined;
|
|
331
|
+
getSetCookie?: {} | undefined;
|
|
332
|
+
has?: {} | undefined;
|
|
333
|
+
set?: {} | undefined;
|
|
334
|
+
forEach?: {} | undefined;
|
|
335
|
+
} | null | undefined;
|
|
336
|
+
timeout?: number | undefined;
|
|
337
|
+
redirects?: number | undefined;
|
|
338
|
+
withCredentials?: boolean | undefined;
|
|
339
|
+
name?: string | undefined;
|
|
340
|
+
order?: number | undefined;
|
|
341
|
+
canRead?: string | boolean | {
|
|
342
|
+
exec?: {} | undefined;
|
|
343
|
+
test?: {} | undefined;
|
|
344
|
+
readonly source?: string | undefined;
|
|
345
|
+
readonly global?: boolean | undefined;
|
|
346
|
+
readonly ignoreCase?: boolean | undefined;
|
|
347
|
+
readonly multiline?: boolean | undefined;
|
|
348
|
+
lastIndex?: number | undefined;
|
|
349
|
+
compile?: {} | undefined;
|
|
350
|
+
readonly flags?: string | undefined;
|
|
351
|
+
readonly sticky?: boolean | undefined;
|
|
352
|
+
readonly unicode?: boolean | undefined;
|
|
353
|
+
readonly dotAll?: boolean | undefined;
|
|
354
|
+
readonly hasIndices?: boolean | undefined;
|
|
355
|
+
[Symbol.match]?: {} | undefined;
|
|
356
|
+
[Symbol.replace]?: {} | undefined;
|
|
357
|
+
[Symbol.search]?: {} | undefined;
|
|
358
|
+
[Symbol.split]?: {} | undefined;
|
|
359
|
+
[Symbol.matchAll]?: {} | undefined;
|
|
360
|
+
} | (string | undefined)[] | {} | undefined;
|
|
361
|
+
read?: string | object | {} | undefined;
|
|
362
|
+
} | undefined;
|
|
363
|
+
} | undefined;
|
|
364
|
+
continueOnError?: boolean | undefined;
|
|
365
|
+
dereference?: {
|
|
366
|
+
circular?: boolean | "ignore" | undefined;
|
|
367
|
+
excludedPathMatcher?: {} | undefined;
|
|
368
|
+
onDereference?: {} | undefined;
|
|
369
|
+
externalReferenceResolution?: "relative" | "root" | undefined;
|
|
370
|
+
} | undefined;
|
|
371
|
+
mutateInputSchema?: boolean | undefined;
|
|
372
|
+
} = {
|
|
373
|
+
parse?: {
|
|
374
|
+
[x: string]: boolean | {
|
|
375
|
+
name?: string | undefined;
|
|
376
|
+
order?: number | undefined;
|
|
377
|
+
allowEmpty?: boolean | undefined;
|
|
378
|
+
allowBOM?: boolean | undefined;
|
|
379
|
+
encoding?: BufferEncoding | undefined;
|
|
380
|
+
canParse?: string | boolean | {
|
|
381
|
+
exec?: {} | undefined;
|
|
382
|
+
test?: {} | undefined;
|
|
383
|
+
readonly source?: string | undefined;
|
|
384
|
+
readonly global?: boolean | undefined;
|
|
385
|
+
readonly ignoreCase?: boolean | undefined;
|
|
386
|
+
readonly multiline?: boolean | undefined;
|
|
387
|
+
lastIndex?: number | undefined;
|
|
388
|
+
compile?: {} | undefined;
|
|
389
|
+
readonly flags?: string | undefined;
|
|
390
|
+
readonly sticky?: boolean | undefined;
|
|
391
|
+
readonly unicode?: boolean | undefined;
|
|
392
|
+
readonly dotAll?: boolean | undefined;
|
|
393
|
+
readonly hasIndices?: boolean | undefined;
|
|
394
|
+
[Symbol.match]?: {} | undefined;
|
|
395
|
+
[Symbol.replace]?: {} | undefined;
|
|
396
|
+
[Symbol.search]?: {} | undefined;
|
|
397
|
+
[Symbol.split]?: {} | undefined;
|
|
398
|
+
[Symbol.matchAll]?: {} | undefined;
|
|
399
|
+
} | (string | undefined)[] | {} | undefined;
|
|
400
|
+
parse?: string | number | {} | undefined;
|
|
401
|
+
} | undefined;
|
|
402
|
+
json?: boolean | {
|
|
403
|
+
name?: string | undefined;
|
|
404
|
+
order?: number | undefined;
|
|
405
|
+
allowEmpty?: boolean | undefined;
|
|
406
|
+
allowBOM?: boolean | undefined;
|
|
407
|
+
encoding?: BufferEncoding | undefined;
|
|
408
|
+
canParse?: string | boolean | {
|
|
409
|
+
exec?: {} | undefined;
|
|
410
|
+
test?: {} | undefined;
|
|
411
|
+
readonly source?: string | undefined;
|
|
412
|
+
readonly global?: boolean | undefined;
|
|
413
|
+
readonly ignoreCase?: boolean | undefined;
|
|
414
|
+
readonly multiline?: boolean | undefined;
|
|
415
|
+
lastIndex?: number | undefined;
|
|
416
|
+
compile?: {} | undefined;
|
|
417
|
+
readonly flags?: string | undefined;
|
|
418
|
+
readonly sticky?: boolean | undefined;
|
|
419
|
+
readonly unicode?: boolean | undefined;
|
|
420
|
+
readonly dotAll?: boolean | undefined;
|
|
421
|
+
readonly hasIndices?: boolean | undefined;
|
|
422
|
+
[Symbol.match]?: {} | undefined;
|
|
423
|
+
[Symbol.replace]?: {} | undefined;
|
|
424
|
+
[Symbol.search]?: {} | undefined;
|
|
425
|
+
[Symbol.split]?: {} | undefined;
|
|
426
|
+
[Symbol.matchAll]?: {} | undefined;
|
|
427
|
+
} | (string | undefined)[] | {} | undefined;
|
|
428
|
+
parse?: string | number | {} | undefined;
|
|
429
|
+
} | undefined;
|
|
430
|
+
yaml?: boolean | {
|
|
431
|
+
name?: string | undefined;
|
|
432
|
+
order?: number | undefined;
|
|
433
|
+
allowEmpty?: boolean | undefined;
|
|
434
|
+
allowBOM?: boolean | undefined;
|
|
435
|
+
encoding?: BufferEncoding | undefined;
|
|
436
|
+
canParse?: string | boolean | {
|
|
437
|
+
exec?: {} | undefined;
|
|
438
|
+
test?: {} | undefined;
|
|
439
|
+
readonly source?: string | undefined;
|
|
440
|
+
readonly global?: boolean | undefined;
|
|
441
|
+
readonly ignoreCase?: boolean | undefined;
|
|
442
|
+
readonly multiline?: boolean | undefined;
|
|
443
|
+
lastIndex?: number | undefined;
|
|
444
|
+
compile?: {} | undefined;
|
|
445
|
+
readonly flags?: string | undefined;
|
|
446
|
+
readonly sticky?: boolean | undefined;
|
|
447
|
+
readonly unicode?: boolean | undefined;
|
|
448
|
+
readonly dotAll?: boolean | undefined;
|
|
449
|
+
readonly hasIndices?: boolean | undefined;
|
|
450
|
+
[Symbol.match]?: {} | undefined;
|
|
451
|
+
[Symbol.replace]?: {} | undefined;
|
|
452
|
+
[Symbol.search]?: {} | undefined;
|
|
453
|
+
[Symbol.split]?: {} | undefined;
|
|
454
|
+
[Symbol.matchAll]?: {} | undefined;
|
|
455
|
+
} | (string | undefined)[] | {} | undefined;
|
|
456
|
+
parse?: string | number | {} | undefined;
|
|
457
|
+
} | undefined;
|
|
458
|
+
binary?: boolean | {
|
|
459
|
+
name?: string | undefined;
|
|
460
|
+
order?: number | undefined;
|
|
461
|
+
allowEmpty?: boolean | undefined;
|
|
462
|
+
allowBOM?: boolean | undefined;
|
|
463
|
+
encoding?: BufferEncoding | undefined;
|
|
464
|
+
canParse?: string | boolean | {
|
|
465
|
+
exec?: {} | undefined;
|
|
466
|
+
test?: {} | undefined;
|
|
467
|
+
readonly source?: string | undefined;
|
|
468
|
+
readonly global?: boolean | undefined;
|
|
469
|
+
readonly ignoreCase?: boolean | undefined;
|
|
470
|
+
readonly multiline?: boolean | undefined;
|
|
471
|
+
lastIndex?: number | undefined;
|
|
472
|
+
compile?: {} | undefined;
|
|
473
|
+
readonly flags?: string | undefined;
|
|
474
|
+
readonly sticky?: boolean | undefined;
|
|
475
|
+
readonly unicode?: boolean | undefined;
|
|
476
|
+
readonly dotAll?: boolean | undefined;
|
|
477
|
+
readonly hasIndices?: boolean | undefined;
|
|
478
|
+
[Symbol.match]?: {} | undefined;
|
|
479
|
+
[Symbol.replace]?: {} | undefined;
|
|
480
|
+
[Symbol.search]?: {} | undefined;
|
|
481
|
+
[Symbol.split]?: {} | undefined;
|
|
482
|
+
[Symbol.matchAll]?: {} | undefined;
|
|
483
|
+
} | (string | undefined)[] | {} | undefined;
|
|
484
|
+
parse?: string | number | {} | undefined;
|
|
485
|
+
} | undefined;
|
|
486
|
+
text?: boolean | {
|
|
487
|
+
name?: string | undefined;
|
|
488
|
+
order?: number | undefined;
|
|
489
|
+
allowEmpty?: boolean | undefined;
|
|
490
|
+
allowBOM?: boolean | undefined;
|
|
491
|
+
encoding?: "ascii" | "utf8" | "utf-8" | "utf16le" | "ucs2" | "ucs-2" | "base64" | "base64url" | "latin1" | "binary" | "hex" | undefined;
|
|
492
|
+
canParse?: string | boolean | {
|
|
493
|
+
exec?: {} | undefined;
|
|
494
|
+
test?: {} | undefined;
|
|
495
|
+
readonly source?: string | undefined;
|
|
496
|
+
readonly global?: boolean | undefined;
|
|
497
|
+
readonly ignoreCase?: boolean | undefined;
|
|
498
|
+
readonly multiline?: boolean | undefined;
|
|
499
|
+
lastIndex?: number | undefined;
|
|
500
|
+
compile?: {} | undefined;
|
|
501
|
+
readonly flags?: string | undefined;
|
|
502
|
+
readonly sticky?: boolean | undefined;
|
|
503
|
+
readonly unicode?: boolean | undefined;
|
|
504
|
+
readonly dotAll?: boolean | undefined;
|
|
505
|
+
readonly hasIndices?: boolean | undefined;
|
|
506
|
+
[Symbol.match]?: {} | undefined;
|
|
507
|
+
[Symbol.replace]?: {} | undefined;
|
|
508
|
+
[Symbol.search]?: {} | undefined;
|
|
509
|
+
[Symbol.split]?: {} | undefined;
|
|
510
|
+
[Symbol.matchAll]?: {} | undefined;
|
|
511
|
+
} | (string | undefined)[] | {} | undefined;
|
|
512
|
+
parse?: string | number | {} | undefined;
|
|
513
|
+
} | undefined;
|
|
514
|
+
} | undefined;
|
|
515
|
+
resolve?: {
|
|
516
|
+
[x: string]: boolean | {
|
|
517
|
+
name?: string | undefined;
|
|
518
|
+
order?: number | undefined;
|
|
519
|
+
canRead?: string | boolean | {
|
|
520
|
+
exec?: {} | undefined;
|
|
521
|
+
test?: {} | undefined;
|
|
522
|
+
readonly source?: string | undefined;
|
|
523
|
+
readonly global?: boolean | undefined;
|
|
524
|
+
readonly ignoreCase?: boolean | undefined;
|
|
525
|
+
readonly multiline?: boolean | undefined;
|
|
526
|
+
lastIndex?: number | undefined;
|
|
527
|
+
compile?: {} | undefined;
|
|
528
|
+
readonly flags?: string | undefined;
|
|
529
|
+
readonly sticky?: boolean | undefined;
|
|
530
|
+
readonly unicode?: boolean | undefined;
|
|
531
|
+
readonly dotAll?: boolean | undefined;
|
|
532
|
+
readonly hasIndices?: boolean | undefined;
|
|
533
|
+
[Symbol.match]?: {} | undefined;
|
|
534
|
+
[Symbol.replace]?: {} | undefined;
|
|
535
|
+
[Symbol.search]?: {} | undefined;
|
|
536
|
+
[Symbol.split]?: {} | undefined;
|
|
537
|
+
[Symbol.matchAll]?: {} | undefined;
|
|
538
|
+
} | (string | undefined)[] | {} | undefined;
|
|
539
|
+
read?: string | object | {} | undefined;
|
|
540
|
+
} | {
|
|
541
|
+
headers?: ([(string | undefined)?, (string | undefined)?] | undefined)[] | {
|
|
542
|
+
[x: string]: string | undefined;
|
|
543
|
+
} | {
|
|
544
|
+
append?: {} | undefined;
|
|
545
|
+
delete?: {} | undefined;
|
|
546
|
+
get?: {} | undefined;
|
|
547
|
+
getSetCookie?: {} | undefined;
|
|
548
|
+
has?: {} | undefined;
|
|
549
|
+
set?: {} | undefined;
|
|
550
|
+
forEach?: {} | undefined;
|
|
551
|
+
} | null | undefined;
|
|
552
|
+
timeout?: number | undefined;
|
|
553
|
+
redirects?: number | undefined;
|
|
554
|
+
withCredentials?: boolean | undefined;
|
|
555
|
+
name?: string | undefined;
|
|
556
|
+
order?: number | undefined;
|
|
557
|
+
canRead?: string | boolean | {
|
|
558
|
+
exec?: {} | undefined;
|
|
559
|
+
test?: {} | undefined;
|
|
560
|
+
readonly source?: string | undefined;
|
|
561
|
+
readonly global?: boolean | undefined;
|
|
562
|
+
readonly ignoreCase?: boolean | undefined;
|
|
563
|
+
readonly multiline?: boolean | undefined;
|
|
564
|
+
lastIndex?: number | undefined;
|
|
565
|
+
compile?: {} | undefined;
|
|
566
|
+
readonly flags?: string | undefined;
|
|
567
|
+
readonly sticky?: boolean | undefined;
|
|
568
|
+
readonly unicode?: boolean | undefined;
|
|
569
|
+
readonly dotAll?: boolean | undefined;
|
|
570
|
+
readonly hasIndices?: boolean | undefined;
|
|
571
|
+
[Symbol.match]?: {} | undefined;
|
|
572
|
+
[Symbol.replace]?: {} | undefined;
|
|
573
|
+
[Symbol.search]?: {} | undefined;
|
|
574
|
+
[Symbol.split]?: {} | undefined;
|
|
575
|
+
[Symbol.matchAll]?: {} | undefined;
|
|
576
|
+
} | (string | undefined)[] | {} | undefined;
|
|
577
|
+
read?: string | object | {} | undefined;
|
|
578
|
+
} | undefined;
|
|
579
|
+
external?: boolean | undefined;
|
|
580
|
+
file?: boolean | {
|
|
581
|
+
name?: string | undefined;
|
|
582
|
+
order?: number | undefined;
|
|
583
|
+
canRead?: string | boolean | {
|
|
584
|
+
exec?: {} | undefined;
|
|
585
|
+
test?: {} | undefined;
|
|
586
|
+
readonly source?: string | undefined;
|
|
587
|
+
readonly global?: boolean | undefined;
|
|
588
|
+
readonly ignoreCase?: boolean | undefined;
|
|
589
|
+
readonly multiline?: boolean | undefined;
|
|
590
|
+
lastIndex?: number | undefined;
|
|
591
|
+
compile?: {} | undefined;
|
|
592
|
+
readonly flags?: string | undefined;
|
|
593
|
+
readonly sticky?: boolean | undefined;
|
|
594
|
+
readonly unicode?: boolean | undefined;
|
|
595
|
+
readonly dotAll?: boolean | undefined;
|
|
596
|
+
readonly hasIndices?: boolean | undefined;
|
|
597
|
+
[Symbol.match]?: {} | undefined;
|
|
598
|
+
[Symbol.replace]?: {} | undefined;
|
|
599
|
+
[Symbol.search]?: {} | undefined;
|
|
600
|
+
[Symbol.split]?: {} | undefined;
|
|
601
|
+
[Symbol.matchAll]?: {} | undefined;
|
|
602
|
+
} | (string | undefined)[] | {} | undefined;
|
|
603
|
+
read?: string | object | {} | undefined;
|
|
604
|
+
} | undefined;
|
|
605
|
+
http?: boolean | {
|
|
606
|
+
headers?: ([(string | undefined)?, (string | undefined)?] | undefined)[] | {
|
|
607
|
+
[x: string]: string | undefined;
|
|
608
|
+
} | {
|
|
609
|
+
append?: {} | undefined;
|
|
610
|
+
delete?: {} | undefined;
|
|
611
|
+
get?: {} | undefined;
|
|
612
|
+
getSetCookie?: {} | undefined;
|
|
613
|
+
has?: {} | undefined;
|
|
614
|
+
set?: {} | undefined;
|
|
615
|
+
forEach?: {} | undefined;
|
|
616
|
+
} | null | undefined;
|
|
617
|
+
timeout?: number | undefined;
|
|
618
|
+
redirects?: number | undefined;
|
|
619
|
+
withCredentials?: boolean | undefined;
|
|
620
|
+
name?: string | undefined;
|
|
621
|
+
order?: number | undefined;
|
|
622
|
+
canRead?: string | boolean | {
|
|
623
|
+
exec?: {} | undefined;
|
|
624
|
+
test?: {} | undefined;
|
|
625
|
+
readonly source?: string | undefined;
|
|
626
|
+
readonly global?: boolean | undefined;
|
|
627
|
+
readonly ignoreCase?: boolean | undefined;
|
|
628
|
+
readonly multiline?: boolean | undefined;
|
|
629
|
+
lastIndex?: number | undefined;
|
|
630
|
+
compile?: {} | undefined;
|
|
631
|
+
readonly flags?: string | undefined;
|
|
632
|
+
readonly sticky?: boolean | undefined;
|
|
633
|
+
readonly unicode?: boolean | undefined;
|
|
634
|
+
readonly dotAll?: boolean | undefined;
|
|
635
|
+
readonly hasIndices?: boolean | undefined;
|
|
636
|
+
[Symbol.match]?: {} | undefined;
|
|
637
|
+
[Symbol.replace]?: {} | undefined;
|
|
638
|
+
[Symbol.search]?: {} | undefined;
|
|
639
|
+
[Symbol.split]?: {} | undefined;
|
|
640
|
+
[Symbol.matchAll]?: {} | undefined;
|
|
641
|
+
} | (string | undefined)[] | {} | undefined;
|
|
642
|
+
read?: string | object | {} | undefined;
|
|
643
|
+
} | undefined;
|
|
644
|
+
} | undefined;
|
|
645
|
+
continueOnError?: boolean | undefined;
|
|
646
|
+
dereference?: {
|
|
647
|
+
circular?: boolean | "ignore" | undefined;
|
|
648
|
+
excludedPathMatcher?: {} | undefined;
|
|
649
|
+
onDereference?: {} | undefined;
|
|
650
|
+
externalReferenceResolution?: "relative" | "root" | undefined;
|
|
651
|
+
} | undefined;
|
|
652
|
+
mutateInputSchema?: boolean | undefined;
|
|
653
|
+
}>(options: O | undefined) => O & $RefParserOptions<S>;
|
|
91
654
|
export type Options = $RefParserOptions<JSONSchema>;
|
|
92
655
|
export type ParserOptions = DeepPartial<$RefParserOptions<JSONSchema>>;
|
|
93
656
|
export default $RefParserOptions;
|
package/dist/lib/pointer.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ import type { JSONSchema } from "./types";
|
|
|
9
9
|
* @param [friendlyPath] - The original user-specified path (used for error messages)
|
|
10
10
|
* @class
|
|
11
11
|
*/
|
|
12
|
-
declare class Pointer<S = JSONSchema> {
|
|
12
|
+
declare class Pointer<S extends JSONSchema = JSONSchema> {
|
|
13
13
|
/**
|
|
14
14
|
* The {@link $Ref} object that contains this {@link Pointer} object.
|
|
15
15
|
*/
|
package/dist/lib/ref.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ export type $RefError = JSONParserError | ResolverError | ParserError | MissingP
|
|
|
10
10
|
*
|
|
11
11
|
* @class
|
|
12
12
|
*/
|
|
13
|
-
declare class $Ref<S = JSONSchema> {
|
|
13
|
+
declare class $Ref<S extends JSONSchema = JSONSchema> {
|
|
14
14
|
/**
|
|
15
15
|
* The file path or URL of the referenced file.
|
|
16
16
|
* This path is relative to the path of the main JSON schema file.
|
|
@@ -177,6 +177,6 @@ declare class $Ref<S = JSONSchema> {
|
|
|
177
177
|
* @param resolvedValue - The resolved value, which can be any type
|
|
178
178
|
* @returns - Returns the dereferenced value
|
|
179
179
|
*/
|
|
180
|
-
static dereference<S>($ref: $Ref<S>, resolvedValue: S): S;
|
|
180
|
+
static dereference<S extends JSONSchema = JSONSchema>($ref: $Ref<S>, resolvedValue: S): S;
|
|
181
181
|
}
|
|
182
182
|
export default $Ref;
|
package/dist/lib/refs.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import $Ref from "./ref.js";
|
|
|
2
2
|
import type { JSONSchema4Type, JSONSchema6Type, JSONSchema7Type } from "json-schema";
|
|
3
3
|
import type $RefParserOptions from "./options.js";
|
|
4
4
|
import type { JSONSchema } from "./types";
|
|
5
|
-
interface $RefsMap<S> {
|
|
5
|
+
interface $RefsMap<S extends JSONSchema = JSONSchema> {
|
|
6
6
|
[url: string]: $Ref<S>;
|
|
7
7
|
}
|
|
8
8
|
/**
|
|
@@ -12,7 +12,7 @@ interface $RefsMap<S> {
|
|
|
12
12
|
*
|
|
13
13
|
* See https://apitools.dev/json-schema-ref-parser/docs/refs.html
|
|
14
14
|
*/
|
|
15
|
-
export default class $Refs<S = JSONSchema> {
|
|
15
|
+
export default class $Refs<S extends JSONSchema = JSONSchema> {
|
|
16
16
|
/**
|
|
17
17
|
* This property is true if the schema contains any circular references. You may want to check this property before serializing the dereferenced schema as JSON, since JSON.stringify() does not support circular references by default.
|
|
18
18
|
*
|
|
@@ -26,7 +26,7 @@ export default class $Refs<S = JSONSchema> {
|
|
|
26
26
|
*
|
|
27
27
|
* @param types (optional) Optionally only return certain types of paths ("file", "http", etc.)
|
|
28
28
|
*/
|
|
29
|
-
paths(...types: string[]): string[];
|
|
29
|
+
paths(...types: (string | string[])[]): string[];
|
|
30
30
|
/**
|
|
31
31
|
* Returns a map of paths/URLs and their correspond values.
|
|
32
32
|
*
|
|
@@ -34,7 +34,7 @@ export default class $Refs<S = JSONSchema> {
|
|
|
34
34
|
*
|
|
35
35
|
* @param types (optional) Optionally only return values from certain locations ("file", "http", etc.)
|
|
36
36
|
*/
|
|
37
|
-
values(...types: string[]): S;
|
|
37
|
+
values(...types: (string | string[])[]): S;
|
|
38
38
|
/**
|
|
39
39
|
* Returns `true` if the given path exists in the schema; otherwise, returns `false`
|
|
40
40
|
*
|
|
@@ -122,6 +122,6 @@ export default class $Refs<S = JSONSchema> {
|
|
|
122
122
|
*
|
|
123
123
|
* @returns {object}
|
|
124
124
|
*/
|
|
125
|
-
toJSON: (...types: string[]) => S;
|
|
125
|
+
toJSON: (...types: (string | string[])[]) => S;
|
|
126
126
|
}
|
|
127
127
|
export {};
|
package/dist/lib/refs.js
CHANGED
|
@@ -46,7 +46,7 @@ class $Refs {
|
|
|
46
46
|
* @param types (optional) Optionally only return certain types of paths ("file", "http", etc.)
|
|
47
47
|
*/
|
|
48
48
|
paths(...types) {
|
|
49
|
-
const paths = getPaths(this._$refs, types);
|
|
49
|
+
const paths = getPaths(this._$refs, types.flat());
|
|
50
50
|
return paths.map((path) => {
|
|
51
51
|
return (0, convert_path_to_posix_1.default)(path.decoded);
|
|
52
52
|
});
|
|
@@ -60,7 +60,7 @@ class $Refs {
|
|
|
60
60
|
*/
|
|
61
61
|
values(...types) {
|
|
62
62
|
const $refs = this._$refs;
|
|
63
|
-
const paths = getPaths($refs, types);
|
|
63
|
+
const paths = getPaths($refs, types.flat());
|
|
64
64
|
return paths.reduce((obj, path) => {
|
|
65
65
|
obj[(0, convert_path_to_posix_1.default)(path.decoded)] = $refs[path.encoded].value;
|
|
66
66
|
return obj;
|
|
@@ -3,12 +3,12 @@ import type { JSONSchema4, JSONSchema4Object, JSONSchema6, JSONSchema6Object, JS
|
|
|
3
3
|
import type $Refs from "../refs.js";
|
|
4
4
|
export type JSONSchema = JSONSchema4 | JSONSchema6 | JSONSchema7;
|
|
5
5
|
export type JSONSchemaObject = JSONSchema4Object | JSONSchema6Object | JSONSchema7Object;
|
|
6
|
-
export type SchemaCallback<S = JSONSchema> = (err: Error | null, schema?: S | object | null) => any;
|
|
7
|
-
export type $RefsCallback<S = JSONSchema> = (err: Error | null, $refs?: $Refs<S>) => any;
|
|
6
|
+
export type SchemaCallback<S extends JSONSchema = JSONSchema> = (err: Error | null, schema?: S | object | null) => any;
|
|
7
|
+
export type $RefsCallback<S extends JSONSchema = JSONSchema> = (err: Error | null, $refs?: $Refs<S>) => any;
|
|
8
8
|
/**
|
|
9
9
|
* See https://apitools.dev/json-schema-ref-parser/docs/options.html
|
|
10
10
|
*/
|
|
11
|
-
export interface HTTPResolverOptions<S = JSONSchema> extends Partial<ResolverOptions<S>> {
|
|
11
|
+
export interface HTTPResolverOptions<S extends JSONSchema = JSONSchema> extends Partial<ResolverOptions<S>> {
|
|
12
12
|
/**
|
|
13
13
|
* You can specify any HTTP headers that should be sent when downloading files. For example, some servers may require you to set the `Accept` or `Referrer` header.
|
|
14
14
|
*/
|
|
@@ -31,7 +31,7 @@ export interface HTTPResolverOptions<S = JSONSchema> extends Partial<ResolverOpt
|
|
|
31
31
|
*
|
|
32
32
|
* See https://apitools.dev/json-schema-ref-parser/docs/plugins/resolvers.html
|
|
33
33
|
*/
|
|
34
|
-
export interface ResolverOptions<S = JSONSchema> {
|
|
34
|
+
export interface ResolverOptions<S extends JSONSchema = JSONSchema> {
|
|
35
35
|
name?: string;
|
|
36
36
|
/**
|
|
37
37
|
* All resolvers have an order property, even the built-in resolvers. If you don't specify an order property, then your resolver will run last. Specifying `order: 1`, like we did in this example, will make your resolver run first. Or you can squeeze your resolver in-between some of the built-in resolvers. For example, `order: 101` would make it run after the file resolver, but before the HTTP resolver. You can see the order of all the built-in resolvers by looking at their source code.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import type { FileInfo } from "../types/index.js";
|
|
2
|
+
import type { FileInfo, JSONSchema } from "../types/index.js";
|
|
3
3
|
import type $RefParserOptions from "../options.js";
|
|
4
4
|
import type { ResolverOptions } from "../types/index.js";
|
|
5
5
|
import type $Refs from "../refs.js";
|
|
@@ -10,7 +10,7 @@ import type { Plugin } from "../types/index.js";
|
|
|
10
10
|
*
|
|
11
11
|
* @returns
|
|
12
12
|
*/
|
|
13
|
-
export declare function all<S>(plugins: $RefParserOptions<S>["resolve"]): Plugin[];
|
|
13
|
+
export declare function all<S extends JSONSchema = JSONSchema>(plugins: $RefParserOptions<S>["resolve"]): Plugin[];
|
|
14
14
|
/**
|
|
15
15
|
* Filters the given plugins, returning only the ones return `true` for the given method.
|
|
16
16
|
*/
|
|
@@ -19,7 +19,7 @@ export declare function filter(plugins: Plugin[], method: any, file: any): Plugi
|
|
|
19
19
|
* Sorts the given plugins, in place, by their `order` property.
|
|
20
20
|
*/
|
|
21
21
|
export declare function sort(plugins: Plugin[]): Plugin[];
|
|
22
|
-
export interface PluginResult<S> {
|
|
22
|
+
export interface PluginResult<S extends JSONSchema = JSONSchema> {
|
|
23
23
|
plugin: Plugin;
|
|
24
24
|
result?: string | Buffer | S;
|
|
25
25
|
error?: any;
|
|
@@ -32,4 +32,4 @@ export interface PluginResult<S> {
|
|
|
32
32
|
* If the promise rejects, or the callback is called with an error, then the next plugin is called.
|
|
33
33
|
* If ALL plugins fail, then the last error is thrown.
|
|
34
34
|
*/
|
|
35
|
-
export declare function run<S>(plugins: Plugin[], method: keyof Plugin | keyof ResolverOptions<S>, file: FileInfo, $refs: $Refs<S>): Promise<PluginResult<S>>;
|
|
35
|
+
export declare function run<S extends JSONSchema = JSONSchema>(plugins: Plugin[], method: keyof Plugin | keyof ResolverOptions<S>, file: FileInfo, $refs: $Refs<S>): Promise<PluginResult<S>>;
|
package/lib/bundle.ts
CHANGED
|
@@ -40,7 +40,7 @@ function bundle<S extends JSONSchema = JSONSchema, O extends ParserOptions = Par
|
|
|
40
40
|
* @param $refs
|
|
41
41
|
* @param options
|
|
42
42
|
*/
|
|
43
|
-
function crawl<S, O>(
|
|
43
|
+
function crawl<S extends JSONSchema = JSONSchema, O extends ParserOptions = ParserOptions>(
|
|
44
44
|
parent: any,
|
|
45
45
|
key: string | null,
|
|
46
46
|
path: string,
|
|
@@ -102,7 +102,7 @@ function crawl<S, O>(
|
|
|
102
102
|
* @param $refs
|
|
103
103
|
* @param options
|
|
104
104
|
*/
|
|
105
|
-
function inventory$Ref<S, O>(
|
|
105
|
+
function inventory$Ref<S extends JSONSchema = JSONSchema, O extends ParserOptions = ParserOptions>(
|
|
106
106
|
$refParent: any,
|
|
107
107
|
$refKey: any,
|
|
108
108
|
path: string,
|
package/lib/normalize-args.ts
CHANGED
|
@@ -4,7 +4,7 @@ import type { JSONSchema, SchemaCallback } from "./types";
|
|
|
4
4
|
|
|
5
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
|
|
6
6
|
// In the future, I'd like to deprecate the api and accept only named parameters in index.ts
|
|
7
|
-
export interface NormalizedArguments<S, O> {
|
|
7
|
+
export interface NormalizedArguments<S extends JSONSchema = JSONSchema, O extends ParserOptions = ParserOptions> {
|
|
8
8
|
path: string;
|
|
9
9
|
schema: S;
|
|
10
10
|
options: O & Options;
|
package/lib/options.ts
CHANGED
|
@@ -53,7 +53,7 @@ export interface DereferenceOptions {
|
|
|
53
53
|
* @param [options] - Overridden options
|
|
54
54
|
* @class
|
|
55
55
|
*/
|
|
56
|
-
export interface $RefParserOptions<S> {
|
|
56
|
+
export interface $RefParserOptions<S extends JSONSchema = JSONSchema> {
|
|
57
57
|
/**
|
|
58
58
|
* The `parse` options determine how different types of files will be parsed.
|
|
59
59
|
*
|
|
@@ -174,7 +174,9 @@ export const getJsonSchemaRefParserDefaultOptions = () => {
|
|
|
174
174
|
return defaults;
|
|
175
175
|
};
|
|
176
176
|
|
|
177
|
-
export const getNewOptions = <S
|
|
177
|
+
export const getNewOptions = <S extends JSONSchema = JSONSchema, O extends ParserOptions = ParserOptions>(
|
|
178
|
+
options: O | undefined,
|
|
179
|
+
): O & $RefParserOptions<S> => {
|
|
178
180
|
const newOptions = getJsonSchemaRefParserDefaultOptions();
|
|
179
181
|
if (options) {
|
|
180
182
|
merge(newOptions, options);
|
package/lib/pointer.ts
CHANGED
|
@@ -26,7 +26,7 @@ const safeDecodeURIComponent = (encodedURIComponent: string): string => {
|
|
|
26
26
|
* @param [friendlyPath] - The original user-specified path (used for error messages)
|
|
27
27
|
* @class
|
|
28
28
|
*/
|
|
29
|
-
class Pointer<S = JSONSchema> {
|
|
29
|
+
class Pointer<S extends JSONSchema = JSONSchema> {
|
|
30
30
|
/**
|
|
31
31
|
* The {@link $Ref} object that contains this {@link Pointer} object.
|
|
32
32
|
*/
|
package/lib/ref.ts
CHANGED
|
@@ -14,7 +14,7 @@ export type $RefError = JSONParserError | ResolverError | ParserError | MissingP
|
|
|
14
14
|
*
|
|
15
15
|
* @class
|
|
16
16
|
*/
|
|
17
|
-
class $Ref<S = JSONSchema> {
|
|
17
|
+
class $Ref<S extends JSONSchema = JSONSchema> {
|
|
18
18
|
/**
|
|
19
19
|
* The file path or URL of the referenced file.
|
|
20
20
|
* This path is relative to the path of the main JSON schema file.
|
|
@@ -267,7 +267,7 @@ class $Ref<S = JSONSchema> {
|
|
|
267
267
|
* @param resolvedValue - The resolved value, which can be any type
|
|
268
268
|
* @returns - Returns the dereferenced value
|
|
269
269
|
*/
|
|
270
|
-
static dereference<S>($ref: $Ref<S>, resolvedValue: S): S {
|
|
270
|
+
static dereference<S extends JSONSchema = JSONSchema>($ref: $Ref<S>, resolvedValue: S): S {
|
|
271
271
|
if (resolvedValue && typeof resolvedValue === "object" && $Ref.isExtended$Ref($ref)) {
|
|
272
272
|
const merged = {};
|
|
273
273
|
for (const key of Object.keys($ref)) {
|
package/lib/refs.ts
CHANGED
|
@@ -6,7 +6,7 @@ import type $RefParserOptions from "./options.js";
|
|
|
6
6
|
import convertPathToPosix from "./util/convert-path-to-posix";
|
|
7
7
|
import type { JSONSchema } from "./types";
|
|
8
8
|
|
|
9
|
-
interface $RefsMap<S> {
|
|
9
|
+
interface $RefsMap<S extends JSONSchema = JSONSchema> {
|
|
10
10
|
[url: string]: $Ref<S>;
|
|
11
11
|
}
|
|
12
12
|
/**
|
|
@@ -16,7 +16,7 @@ interface $RefsMap<S> {
|
|
|
16
16
|
*
|
|
17
17
|
* See https://apitools.dev/json-schema-ref-parser/docs/refs.html
|
|
18
18
|
*/
|
|
19
|
-
export default class $Refs<S = JSONSchema> {
|
|
19
|
+
export default class $Refs<S extends JSONSchema = JSONSchema> {
|
|
20
20
|
/**
|
|
21
21
|
* This property is true if the schema contains any circular references. You may want to check this property before serializing the dereferenced schema as JSON, since JSON.stringify() does not support circular references by default.
|
|
22
22
|
*
|
|
@@ -31,8 +31,8 @@ export default class $Refs<S = JSONSchema> {
|
|
|
31
31
|
*
|
|
32
32
|
* @param types (optional) Optionally only return certain types of paths ("file", "http", etc.)
|
|
33
33
|
*/
|
|
34
|
-
paths(...types: string[]): string[] {
|
|
35
|
-
const paths = getPaths(this._$refs, types);
|
|
34
|
+
paths(...types: (string | string[])[]): string[] {
|
|
35
|
+
const paths = getPaths(this._$refs, types.flat());
|
|
36
36
|
return paths.map((path) => {
|
|
37
37
|
return convertPathToPosix(path.decoded);
|
|
38
38
|
});
|
|
@@ -45,9 +45,9 @@ export default class $Refs<S = JSONSchema> {
|
|
|
45
45
|
*
|
|
46
46
|
* @param types (optional) Optionally only return values from certain locations ("file", "http", etc.)
|
|
47
47
|
*/
|
|
48
|
-
values(...types: string[]): S {
|
|
48
|
+
values(...types: (string | string[])[]): S {
|
|
49
49
|
const $refs = this._$refs;
|
|
50
|
-
const paths = getPaths($refs, types);
|
|
50
|
+
const paths = getPaths($refs, types.flat());
|
|
51
51
|
return paths.reduce<Record<string, any>>((obj, path) => {
|
|
52
52
|
obj[convertPathToPosix(path.decoded)] = $refs[path.encoded].value;
|
|
53
53
|
return obj;
|
|
@@ -215,7 +215,7 @@ export default class $Refs<S = JSONSchema> {
|
|
|
215
215
|
* @param [types] - Only return paths of the given types ("file", "http", etc.)
|
|
216
216
|
* @returns
|
|
217
217
|
*/
|
|
218
|
-
function getPaths<S>($refs: $RefsMap<S>, types: string[]) {
|
|
218
|
+
function getPaths<S extends JSONSchema = JSONSchema>($refs: $RefsMap<S>, types: string[]) {
|
|
219
219
|
let paths = Object.keys($refs);
|
|
220
220
|
|
|
221
221
|
// Filter the paths by type
|
package/lib/resolvers/http.ts
CHANGED
|
@@ -66,7 +66,7 @@ export default {
|
|
|
66
66
|
* @returns
|
|
67
67
|
* The promise resolves with the raw downloaded data, or rejects if there is an HTTP error.
|
|
68
68
|
*/
|
|
69
|
-
async function download<S>(
|
|
69
|
+
async function download<S extends JSONSchema = JSONSchema>(
|
|
70
70
|
u: URL | string,
|
|
71
71
|
httpOptions: HTTPResolverOptions<S>,
|
|
72
72
|
_redirects?: string[],
|
|
@@ -109,7 +109,7 @@ async function download<S>(
|
|
|
109
109
|
* Sends an HTTP GET request.
|
|
110
110
|
* The promise resolves with the HTTP Response object.
|
|
111
111
|
*/
|
|
112
|
-
async function get<S>(u: RequestInfo | URL, httpOptions: HTTPResolverOptions<S>) {
|
|
112
|
+
async function get<S extends JSONSchema = JSONSchema>(u: RequestInfo | URL, httpOptions: HTTPResolverOptions<S>) {
|
|
113
113
|
let controller: any;
|
|
114
114
|
let timeoutId: any;
|
|
115
115
|
if (httpOptions.timeout) {
|
package/lib/types/index.ts
CHANGED
|
@@ -10,14 +10,14 @@ import type $Refs from "../refs.js";
|
|
|
10
10
|
|
|
11
11
|
export type JSONSchema = JSONSchema4 | JSONSchema6 | JSONSchema7;
|
|
12
12
|
export type JSONSchemaObject = JSONSchema4Object | JSONSchema6Object | JSONSchema7Object;
|
|
13
|
-
export type SchemaCallback<S = JSONSchema> = (err: Error | null, schema?: S | object | null) => any;
|
|
14
|
-
export type $RefsCallback<S = JSONSchema> = (err: Error | null, $refs?: $Refs<S>) => any;
|
|
13
|
+
export type SchemaCallback<S extends JSONSchema = JSONSchema> = (err: Error | null, schema?: S | object | null) => any;
|
|
14
|
+
export type $RefsCallback<S extends JSONSchema = JSONSchema> = (err: Error | null, $refs?: $Refs<S>) => any;
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
17
|
* See https://apitools.dev/json-schema-ref-parser/docs/options.html
|
|
18
18
|
*/
|
|
19
19
|
|
|
20
|
-
export interface HTTPResolverOptions<S = JSONSchema> extends Partial<ResolverOptions<S>> {
|
|
20
|
+
export interface HTTPResolverOptions<S extends JSONSchema = JSONSchema> extends Partial<ResolverOptions<S>> {
|
|
21
21
|
/**
|
|
22
22
|
* You can specify any HTTP headers that should be sent when downloading files. For example, some servers may require you to set the `Accept` or `Referrer` header.
|
|
23
23
|
*/
|
|
@@ -44,7 +44,7 @@ export interface HTTPResolverOptions<S = JSONSchema> extends Partial<ResolverOpt
|
|
|
44
44
|
*
|
|
45
45
|
* See https://apitools.dev/json-schema-ref-parser/docs/plugins/resolvers.html
|
|
46
46
|
*/
|
|
47
|
-
export interface ResolverOptions<S = JSONSchema> {
|
|
47
|
+
export interface ResolverOptions<S extends JSONSchema = JSONSchema> {
|
|
48
48
|
name?: string;
|
|
49
49
|
/**
|
|
50
50
|
* All resolvers have an order property, even the built-in resolvers. If you don't specify an order property, then your resolver will run last. Specifying `order: 1`, like we did in this example, will make your resolver run first. Or you can squeeze your resolver in-between some of the built-in resolvers. For example, `order: 101` would make it run after the file resolver, but before the HTTP resolver. You can see the order of all the built-in resolvers by looking at their source code.
|
package/lib/util/errors.ts
CHANGED
|
@@ -60,7 +60,7 @@ export class JSONParserErrorGroup<
|
|
|
60
60
|
) {
|
|
61
61
|
const errors = [];
|
|
62
62
|
|
|
63
|
-
for (const $ref of Object.values(parser.$refs._$refs) as $Ref<
|
|
63
|
+
for (const $ref of Object.values(parser.$refs._$refs) as $Ref<S>[]) {
|
|
64
64
|
if ($ref.errors) {
|
|
65
65
|
errors.push(...$ref.errors);
|
|
66
66
|
}
|
package/lib/util/plugins.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { FileInfo } from "../types/index.js";
|
|
1
|
+
import type { FileInfo, JSONSchema } from "../types/index.js";
|
|
2
2
|
import type $RefParserOptions from "../options.js";
|
|
3
3
|
import type { ResolverOptions } from "../types/index.js";
|
|
4
4
|
import type $Refs from "../refs.js";
|
|
@@ -10,7 +10,7 @@ import type { Plugin } from "../types/index.js";
|
|
|
10
10
|
*
|
|
11
11
|
* @returns
|
|
12
12
|
*/
|
|
13
|
-
export function all<S>(plugins: $RefParserOptions<S>["resolve"]): Plugin[] {
|
|
13
|
+
export function all<S extends JSONSchema = JSONSchema>(plugins: $RefParserOptions<S>["resolve"]): Plugin[] {
|
|
14
14
|
return Object.keys(plugins)
|
|
15
15
|
.filter((key) => {
|
|
16
16
|
return typeof plugins[key] === "object";
|
|
@@ -43,7 +43,7 @@ export function sort(plugins: Plugin[]) {
|
|
|
43
43
|
});
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
export interface PluginResult<S> {
|
|
46
|
+
export interface PluginResult<S extends JSONSchema = JSONSchema> {
|
|
47
47
|
plugin: Plugin;
|
|
48
48
|
result?: string | Buffer | S;
|
|
49
49
|
error?: any;
|
|
@@ -57,7 +57,7 @@ export interface PluginResult<S> {
|
|
|
57
57
|
* If the promise rejects, or the callback is called with an error, then the next plugin is called.
|
|
58
58
|
* If ALL plugins fail, then the last error is thrown.
|
|
59
59
|
*/
|
|
60
|
-
export async function run<S>(
|
|
60
|
+
export async function run<S extends JSONSchema = JSONSchema>(
|
|
61
61
|
plugins: Plugin[],
|
|
62
62
|
method: keyof Plugin | keyof ResolverOptions<S>,
|
|
63
63
|
file: FileInfo,
|
|
@@ -127,7 +127,7 @@ export async function run<S>(
|
|
|
127
127
|
* If the value is a RegExp, then it will be tested against the file URL.
|
|
128
128
|
* If the value is an array, then it will be compared against the file extension.
|
|
129
129
|
*/
|
|
130
|
-
function getResult<S>(
|
|
130
|
+
function getResult<S extends JSONSchema = JSONSchema>(
|
|
131
131
|
obj: Plugin,
|
|
132
132
|
prop: keyof Plugin | keyof ResolverOptions<S>,
|
|
133
133
|
file: FileInfo,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@apidevtools/json-schema-ref-parser",
|
|
3
|
-
"version": "11.5.
|
|
3
|
+
"version": "11.5.2",
|
|
4
4
|
"description": "Parse, Resolve, and Dereference JSON Schema $ref pointers",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"json",
|
|
@@ -84,7 +84,7 @@
|
|
|
84
84
|
"jsdom": "^24.0.0",
|
|
85
85
|
"prettier": "^3.2.5",
|
|
86
86
|
"rimraf": "^5.0.5",
|
|
87
|
-
"typescript": "^5.
|
|
87
|
+
"typescript": "^5.4.2",
|
|
88
88
|
"vitest": "^1.3.1"
|
|
89
89
|
},
|
|
90
90
|
"dependencies": {
|