@@ -5,7 +5,7 @@ import * as url from "./util/url.js";
55import type $Refs from "./refs.js" ;
66import type { DereferenceOptions , ParserOptions } from "./options.js" ;
77import type { JSONSchema } from "./types" ;
8- import type $RefParser from "./index" ;
8+ import type { $RefParser } from "./index" ;
99import { TimeoutError } from "./util/errors" ;
1010
1111export default dereference ;
@@ -17,13 +17,13 @@ export default dereference;
1717 * @param parser
1818 * @param options
1919 */
20- function dereference < S extends object = JSONSchema , O extends ParserOptions < S > = ParserOptions < S > > (
21- parser : $RefParser < S , O > ,
22- options : O ,
20+ function dereference (
21+ parser : $RefParser ,
22+ options : ParserOptions ,
2323) {
2424 const start = Date . now ( ) ;
2525 // console.log('Dereferencing $ref pointers in %s', parser.$refs._root$Ref.path);
26- const dereferenced = crawl < S , O > (
26+ const dereferenced = crawl < JSONSchema > (
2727 parser . schema ,
2828 parser . $refs . _root$Ref . path ! ,
2929 "#" ,
@@ -52,15 +52,15 @@ function dereference<S extends object = JSONSchema, O extends ParserOptions<S> =
5252 * @param startTime - The time when the dereferencing started
5353 * @returns
5454 */
55- function crawl < S extends object = JSONSchema , O extends ParserOptions < S > = ParserOptions < S > > (
55+ function crawl < S extends object = JSONSchema > (
5656 obj : any ,
5757 path : string ,
5858 pathFromRoot : string ,
5959 parents : Set < any > ,
6060 processedObjects : Set < any > ,
6161 dereferencedCache : any ,
62- $refs : $Refs < S , O > ,
63- options : O ,
62+ $refs : $Refs < S > ,
63+ options : ParserOptions ,
6464 startTime : number ,
6565) {
6666 let dereferenced ;
@@ -82,7 +82,7 @@ function crawl<S extends object = JSONSchema, O extends ParserOptions<S> = Parse
8282 parents . add ( obj ) ;
8383 processedObjects . add ( obj ) ;
8484
85- if ( $Ref . isAllowed$Ref ( obj , options ) ) {
85+ if ( $Ref . isAllowed$Ref ( obj ) ) {
8686 dereferenced = dereference$Ref (
8787 obj ,
8888 path ,
@@ -108,7 +108,7 @@ function crawl<S extends object = JSONSchema, O extends ParserOptions<S> = Parse
108108 const value = obj [ key ] ;
109109 let circular = false ;
110110
111- if ( $Ref . isAllowed$Ref ( value , options ) ) {
111+ if ( $Ref . isAllowed$Ref ( value ) ) {
112112 dereferenced = dereference$Ref (
113113 value ,
114114 keyPath ,
@@ -174,20 +174,18 @@ function crawl<S extends object = JSONSchema, O extends ParserOptions<S> = Parse
174174 * @param options
175175 * @returns
176176 */
177- function dereference$Ref < S extends object = JSONSchema , O extends ParserOptions < S > = ParserOptions < S > > (
177+ function dereference$Ref < S extends object = JSONSchema > (
178178 $ref : any ,
179179 path : string ,
180180 pathFromRoot : string ,
181181 parents : Set < any > ,
182182 processedObjects : any ,
183183 dereferencedCache : any ,
184- $refs : $Refs < S , O > ,
185- options : O ,
184+ $refs : $Refs < S > ,
185+ options : ParserOptions ,
186186 startTime : number ,
187187) {
188- const isExternalRef = $Ref . isExternal$Ref ( $ref ) ;
189- const shouldResolveOnCwd = isExternalRef && options ?. dereference ?. externalReferenceResolution === "root" ;
190- const $refPath = url . resolve ( shouldResolveOnCwd ? url . cwd ( ) : path , $ref . $ref ) ;
188+ const $refPath = url . resolve ( path , $ref . $ref ) ;
191189
192190 const cache = dereferencedCache . get ( $refPath ) ;
193191 if ( cache && ! cache . circular ) {
0 commit comments