@@ -37,7 +37,7 @@ export type RefParserSchema = string | JSONSchema;
37
37
*
38
38
* @class
39
39
*/
40
- export class $RefParser < S extends JSONSchema = JSONSchema , O extends ParserOptions < S > = ParserOptions < S > > {
40
+ export class $RefParser < S extends object = JSONSchema , O extends ParserOptions < S > = ParserOptions < S > > {
41
41
/**
42
42
* The parsed (and possibly dereferenced) JSON schema object
43
43
*
@@ -94,10 +94,10 @@ export class $RefParser<S extends JSONSchema = JSONSchema, O extends ParserOptio
94
94
if ( url . isFileSystemPath ( args . path ) ) {
95
95
args . path = url . fromFileSystemPath ( args . path ) ;
96
96
pathType = "file" ;
97
- } else if ( ! args . path && args . schema && args . schema . $id ) {
97
+ } else if ( ! args . path && args . schema && "$id" in args . schema && args . schema . $id ) {
98
98
// when schema id has defined an URL should use that hostname to request the references,
99
99
// instead of using the current page URL
100
- const params = url . parse ( args . schema . $id ) ;
100
+ const params = url . parse ( args . schema . $id as string ) ;
101
101
const port = params . protocol === "https:" ? 443 : 80 ;
102
102
103
103
args . path = `${ params . protocol } //${ params . hostname } :${ port } ` ;
@@ -143,34 +143,34 @@ export class $RefParser<S extends JSONSchema = JSONSchema, O extends ParserOptio
143
143
}
144
144
}
145
145
146
- public static parse < S extends JSONSchema = JSONSchema , O extends ParserOptions < S > = ParserOptions < S > > (
146
+ public static parse < S extends object = JSONSchema , O extends ParserOptions < S > = ParserOptions < S > > (
147
147
schema : S | string ,
148
148
) : Promise < S > ;
149
- public static parse < S extends JSONSchema = JSONSchema , O extends ParserOptions < S > = ParserOptions < S > > (
149
+ public static parse < S extends object = JSONSchema , O extends ParserOptions < S > = ParserOptions < S > > (
150
150
schema : S | string ,
151
151
callback : SchemaCallback < S > ,
152
152
) : Promise < void > ;
153
- public static parse < S extends JSONSchema = JSONSchema , O extends ParserOptions < S > = ParserOptions < S > > (
153
+ public static parse < S extends object = JSONSchema , O extends ParserOptions < S > = ParserOptions < S > > (
154
154
schema : S | string ,
155
155
options : O ,
156
156
) : Promise < S > ;
157
- public static parse < S extends JSONSchema = JSONSchema , O extends ParserOptions < S > = ParserOptions < S > > (
157
+ public static parse < S extends object = JSONSchema , O extends ParserOptions < S > = ParserOptions < S > > (
158
158
schema : S | string ,
159
159
options : O ,
160
160
callback : SchemaCallback < S > ,
161
161
) : Promise < void > ;
162
- public static parse < S extends JSONSchema = JSONSchema , O extends ParserOptions < S > = ParserOptions < S > > (
162
+ public static parse < S extends object = JSONSchema , O extends ParserOptions < S > = ParserOptions < S > > (
163
163
baseUrl : string ,
164
164
schema : S | string ,
165
165
options : O ,
166
166
) : Promise < S > ;
167
- public static parse < S extends JSONSchema = JSONSchema , O extends ParserOptions < S > = ParserOptions < S > > (
167
+ public static parse < S extends object = JSONSchema , O extends ParserOptions < S > = ParserOptions < S > > (
168
168
baseUrl : string ,
169
169
schema : S | string ,
170
170
options : O ,
171
171
callback : SchemaCallback < S > ,
172
172
) : Promise < void > ;
173
- public static parse < S extends JSONSchema = JSONSchema , O extends ParserOptions < S > = ParserOptions < S > > ( ) :
173
+ public static parse < S extends object = JSONSchema , O extends ParserOptions < S > = ParserOptions < S > > ( ) :
174
174
| Promise < S >
175
175
| Promise < void > {
176
176
const parser = new $RefParser < S , O > ( ) ;
@@ -218,34 +218,34 @@ export class $RefParser<S extends JSONSchema = JSONSchema, O extends ParserOptio
218
218
* @param options (optional)
219
219
* @param callback (optional) A callback that will receive a `$Refs` object
220
220
*/
221
- public static resolve < S extends JSONSchema = JSONSchema , O extends ParserOptions < S > = ParserOptions < S > > (
221
+ public static resolve < S extends object = JSONSchema , O extends ParserOptions < S > = ParserOptions < S > > (
222
222
schema : S | string ,
223
223
) : Promise < $Refs < S , O > > ;
224
- public static resolve < S extends JSONSchema = JSONSchema , O extends ParserOptions < S > = ParserOptions < S > > (
224
+ public static resolve < S extends object = JSONSchema , O extends ParserOptions < S > = ParserOptions < S > > (
225
225
schema : S | string ,
226
226
callback : $RefsCallback < S , O > ,
227
227
) : Promise < void > ;
228
- public static resolve < S extends JSONSchema = JSONSchema , O extends ParserOptions < S > = ParserOptions < S > > (
228
+ public static resolve < S extends object = JSONSchema , O extends ParserOptions < S > = ParserOptions < S > > (
229
229
schema : S | string ,
230
230
options : O ,
231
231
) : Promise < $Refs < S , O > > ;
232
- public static resolve < S extends JSONSchema = JSONSchema , O extends ParserOptions < S > = ParserOptions < S > > (
232
+ public static resolve < S extends object = JSONSchema , O extends ParserOptions < S > = ParserOptions < S > > (
233
233
schema : S | string ,
234
234
options : O ,
235
235
callback : $RefsCallback < S , O > ,
236
236
) : Promise < void > ;
237
- public static resolve < S extends JSONSchema = JSONSchema , O extends ParserOptions < S > = ParserOptions < S > > (
237
+ public static resolve < S extends object = JSONSchema , O extends ParserOptions < S > = ParserOptions < S > > (
238
238
baseUrl : string ,
239
239
schema : S | string ,
240
240
options : O ,
241
241
) : Promise < $Refs < S , O > > ;
242
- public static resolve < S extends JSONSchema = JSONSchema , O extends ParserOptions < S > = ParserOptions < S > > (
242
+ public static resolve < S extends object = JSONSchema , O extends ParserOptions < S > = ParserOptions < S > > (
243
243
baseUrl : string ,
244
244
schema : S | string ,
245
245
options : O ,
246
246
callback : $RefsCallback < S , O > ,
247
247
) : Promise < void > ;
248
- static resolve < S extends JSONSchema = JSONSchema , O extends ParserOptions < S > = ParserOptions < S > > ( ) :
248
+ static resolve < S extends object = JSONSchema , O extends ParserOptions < S > = ParserOptions < S > > ( ) :
249
249
| Promise < S >
250
250
| Promise < void > {
251
251
const instance = new $RefParser < S , O > ( ) ;
@@ -263,34 +263,34 @@ export class $RefParser<S extends JSONSchema = JSONSchema, O extends ParserOptio
263
263
* @param options (optional)
264
264
* @param callback (optional) A callback that will receive the bundled schema object
265
265
*/
266
- public static bundle < S extends JSONSchema = JSONSchema , O extends ParserOptions < S > = ParserOptions < S > > (
266
+ public static bundle < S extends object = JSONSchema , O extends ParserOptions < S > = ParserOptions < S > > (
267
267
schema : S | string ,
268
268
) : Promise < S > ;
269
- public static bundle < S extends JSONSchema = JSONSchema , O extends ParserOptions < S > = ParserOptions < S > > (
269
+ public static bundle < S extends object = JSONSchema , O extends ParserOptions < S > = ParserOptions < S > > (
270
270
schema : S | string ,
271
271
callback : SchemaCallback < S > ,
272
272
) : Promise < void > ;
273
- public static bundle < S extends JSONSchema = JSONSchema , O extends ParserOptions < S > = ParserOptions < S > > (
273
+ public static bundle < S extends object = JSONSchema , O extends ParserOptions < S > = ParserOptions < S > > (
274
274
schema : S | string ,
275
275
options : O ,
276
276
) : Promise < S > ;
277
- public static bundle < S extends JSONSchema = JSONSchema , O extends ParserOptions < S > = ParserOptions < S > > (
277
+ public static bundle < S extends object = JSONSchema , O extends ParserOptions < S > = ParserOptions < S > > (
278
278
schema : S | string ,
279
279
options : O ,
280
280
callback : SchemaCallback < S > ,
281
281
) : Promise < void > ;
282
- public static bundle < S extends JSONSchema = JSONSchema , O extends ParserOptions < S > = ParserOptions < S > > (
282
+ public static bundle < S extends object = JSONSchema , O extends ParserOptions < S > = ParserOptions < S > > (
283
283
baseUrl : string ,
284
284
schema : S | string ,
285
285
options : O ,
286
286
) : Promise < S > ;
287
- public static bundle < S extends JSONSchema = JSONSchema , O extends ParserOptions < S > = ParserOptions < S > > (
287
+ public static bundle < S extends object = JSONSchema , O extends ParserOptions < S > = ParserOptions < S > > (
288
288
baseUrl : string ,
289
289
schema : S | string ,
290
290
options : O ,
291
291
callback : SchemaCallback < S > ,
292
292
) : Promise < S > ;
293
- static bundle < S extends JSONSchema = JSONSchema , O extends ParserOptions < S > = ParserOptions < S > > ( ) :
293
+ static bundle < S extends object = JSONSchema , O extends ParserOptions < S > = ParserOptions < S > > ( ) :
294
294
| Promise < S >
295
295
| Promise < void > {
296
296
const instance = new $RefParser < S , O > ( ) ;
@@ -337,34 +337,34 @@ export class $RefParser<S extends JSONSchema = JSONSchema, O extends ParserOptio
337
337
* @param options (optional)
338
338
* @param callback (optional) A callback that will receive the dereferenced schema object
339
339
*/
340
- public static dereference < S extends JSONSchema = JSONSchema , O extends ParserOptions < S > = ParserOptions < S > > (
340
+ public static dereference < S extends object = JSONSchema , O extends ParserOptions < S > = ParserOptions < S > > (
341
341
schema : S | string ,
342
342
) : Promise < S > ;
343
- public static dereference < S extends JSONSchema = JSONSchema , O extends ParserOptions < S > = ParserOptions < S > > (
343
+ public static dereference < S extends object = JSONSchema , O extends ParserOptions < S > = ParserOptions < S > > (
344
344
schema : S | string ,
345
345
callback : SchemaCallback < S > ,
346
346
) : Promise < void > ;
347
- public static dereference < S extends JSONSchema = JSONSchema , O extends ParserOptions < S > = ParserOptions < S > > (
347
+ public static dereference < S extends object = JSONSchema , O extends ParserOptions < S > = ParserOptions < S > > (
348
348
schema : S | string ,
349
349
options : O ,
350
350
) : Promise < S > ;
351
- public static dereference < S extends JSONSchema = JSONSchema , O extends ParserOptions < S > = ParserOptions < S > > (
351
+ public static dereference < S extends object = JSONSchema , O extends ParserOptions < S > = ParserOptions < S > > (
352
352
schema : S | string ,
353
353
options : O ,
354
354
callback : SchemaCallback < S > ,
355
355
) : Promise < void > ;
356
- public static dereference < S extends JSONSchema = JSONSchema , O extends ParserOptions < S > = ParserOptions < S > > (
356
+ public static dereference < S extends object = JSONSchema , O extends ParserOptions < S > = ParserOptions < S > > (
357
357
baseUrl : string ,
358
358
schema : S | string ,
359
359
options : O ,
360
360
) : Promise < S > ;
361
- public static dereference < S extends JSONSchema = JSONSchema , O extends ParserOptions < S > = ParserOptions < S > > (
361
+ public static dereference < S extends object = JSONSchema , O extends ParserOptions < S > = ParserOptions < S > > (
362
362
baseUrl : string ,
363
363
schema : S | string ,
364
364
options : O ,
365
365
callback : SchemaCallback < S > ,
366
366
) : Promise < void > ;
367
- static dereference < S extends JSONSchema = JSONSchema , O extends ParserOptions < S > = ParserOptions < S > > ( ) :
367
+ static dereference < S extends object = JSONSchema , O extends ParserOptions < S > = ParserOptions < S > > ( ) :
368
368
| Promise < S >
369
369
| Promise < void > {
370
370
const instance = new $RefParser < S , O > ( ) ;
@@ -404,7 +404,7 @@ export class $RefParser<S extends JSONSchema = JSONSchema, O extends ParserOptio
404
404
}
405
405
export default $RefParser ;
406
406
407
- function finalize < S extends JSONSchema = JSONSchema , O extends ParserOptions < S > = ParserOptions < S > > (
407
+ function finalize < S extends object = JSONSchema , O extends ParserOptions < S > = ParserOptions < S > > (
408
408
parser : $RefParser < S , O > ,
409
409
) {
410
410
const errors = JSONParserErrorGroup . getParserErrors ( parser ) ;
0 commit comments