@@ -37,7 +37,7 @@ export type RefParserSchema = string | JSONSchema;
3737 *
3838 * @class
3939 */
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 > > {
4141 /**
4242 * The parsed (and possibly dereferenced) JSON schema object
4343 *
@@ -94,10 +94,10 @@ export class $RefParser<S extends JSONSchema = JSONSchema, O extends ParserOptio
9494 if ( url . isFileSystemPath ( args . path ) ) {
9595 args . path = url . fromFileSystemPath ( args . path ) ;
9696 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 ) {
9898 // when schema id has defined an URL should use that hostname to request the references,
9999 // 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 ) ;
101101 const port = params . protocol === "https:" ? 443 : 80 ;
102102
103103 args . path = `${ params . protocol } //${ params . hostname } :${ port } ` ;
@@ -143,34 +143,34 @@ export class $RefParser<S extends JSONSchema = JSONSchema, O extends ParserOptio
143143 }
144144 }
145145
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 > > (
147147 schema : S | string ,
148148 ) : 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 > > (
150150 schema : S | string ,
151151 callback : SchemaCallback < S > ,
152152 ) : 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 > > (
154154 schema : S | string ,
155155 options : O ,
156156 ) : 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 > > (
158158 schema : S | string ,
159159 options : O ,
160160 callback : SchemaCallback < S > ,
161161 ) : 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 > > (
163163 baseUrl : string ,
164164 schema : S | string ,
165165 options : O ,
166166 ) : 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 > > (
168168 baseUrl : string ,
169169 schema : S | string ,
170170 options : O ,
171171 callback : SchemaCallback < S > ,
172172 ) : 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 > > ( ) :
174174 | Promise < S >
175175 | Promise < void > {
176176 const parser = new $RefParser < S , O > ( ) ;
@@ -218,34 +218,34 @@ export class $RefParser<S extends JSONSchema = JSONSchema, O extends ParserOptio
218218 * @param options (optional)
219219 * @param callback (optional) A callback that will receive a `$Refs` object
220220 */
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 > > (
222222 schema : S | string ,
223223 ) : 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 > > (
225225 schema : S | string ,
226226 callback : $RefsCallback < S , O > ,
227227 ) : 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 > > (
229229 schema : S | string ,
230230 options : O ,
231231 ) : 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 > > (
233233 schema : S | string ,
234234 options : O ,
235235 callback : $RefsCallback < S , O > ,
236236 ) : 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 > > (
238238 baseUrl : string ,
239239 schema : S | string ,
240240 options : O ,
241241 ) : 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 > > (
243243 baseUrl : string ,
244244 schema : S | string ,
245245 options : O ,
246246 callback : $RefsCallback < S , O > ,
247247 ) : 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 > > ( ) :
249249 | Promise < S >
250250 | Promise < void > {
251251 const instance = new $RefParser < S , O > ( ) ;
@@ -263,34 +263,34 @@ export class $RefParser<S extends JSONSchema = JSONSchema, O extends ParserOptio
263263 * @param options (optional)
264264 * @param callback (optional) A callback that will receive the bundled schema object
265265 */
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 > > (
267267 schema : S | string ,
268268 ) : 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 > > (
270270 schema : S | string ,
271271 callback : SchemaCallback < S > ,
272272 ) : 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 > > (
274274 schema : S | string ,
275275 options : O ,
276276 ) : 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 > > (
278278 schema : S | string ,
279279 options : O ,
280280 callback : SchemaCallback < S > ,
281281 ) : 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 > > (
283283 baseUrl : string ,
284284 schema : S | string ,
285285 options : O ,
286286 ) : 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 > > (
288288 baseUrl : string ,
289289 schema : S | string ,
290290 options : O ,
291291 callback : SchemaCallback < S > ,
292292 ) : 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 > > ( ) :
294294 | Promise < S >
295295 | Promise < void > {
296296 const instance = new $RefParser < S , O > ( ) ;
@@ -337,34 +337,34 @@ export class $RefParser<S extends JSONSchema = JSONSchema, O extends ParserOptio
337337 * @param options (optional)
338338 * @param callback (optional) A callback that will receive the dereferenced schema object
339339 */
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 > > (
341341 schema : S | string ,
342342 ) : 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 > > (
344344 schema : S | string ,
345345 callback : SchemaCallback < S > ,
346346 ) : 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 > > (
348348 schema : S | string ,
349349 options : O ,
350350 ) : 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 > > (
352352 schema : S | string ,
353353 options : O ,
354354 callback : SchemaCallback < S > ,
355355 ) : 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 > > (
357357 baseUrl : string ,
358358 schema : S | string ,
359359 options : O ,
360360 ) : 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 > > (
362362 baseUrl : string ,
363363 schema : S | string ,
364364 options : O ,
365365 callback : SchemaCallback < S > ,
366366 ) : 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 > > ( ) :
368368 | Promise < S >
369369 | Promise < void > {
370370 const instance = new $RefParser < S , O > ( ) ;
@@ -404,7 +404,7 @@ export class $RefParser<S extends JSONSchema = JSONSchema, O extends ParserOptio
404404}
405405export default $RefParser ;
406406
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 > > (
408408 parser : $RefParser < S , O > ,
409409) {
410410 const errors = JSONParserErrorGroup . getParserErrors ( parser ) ;
0 commit comments