File tree Expand file tree Collapse file tree 3 files changed +67
-2
lines changed
Expand file tree Collapse file tree 3 files changed +67
-2
lines changed Original file line number Diff line number Diff line change 11{
22 "permissions" : {
3- "allow" : [" Bash(npx vitest:*)" , " Bash(bash:*)" , " Bash(node test-debug.js:*)" ]
3+ "allow" : [
4+ " Bash(npx vitest:*)" ,
5+ " Bash(bash:*)" ,
6+ " Bash(node test-debug.js:*)" ,
7+ " WebFetch(domain:github.com)"
8+ ]
49 },
510 "enableAllProjectMcpServers" : false
611}
Original file line number Diff line number Diff line change @@ -121,7 +121,7 @@ async function download<S extends object = JSONSchema>(
121121async function get < S extends object = JSONSchema > ( u : RequestInfo | URL , httpOptions : HTTPResolverOptions < S > ) {
122122 let controller : any ;
123123 let timeoutId : any ;
124- if ( httpOptions . timeout ) {
124+ if ( httpOptions . timeout && typeof AbortController !== "undefined" ) {
125125 controller = new AbortController ( ) ;
126126 timeoutId = setTimeout ( ( ) => controller . abort ( ) , httpOptions . timeout ) ;
127127 }
Original file line number Diff line number Diff line change @@ -298,4 +298,64 @@ describe("options.resolve", () => {
298298 properties : { test : { type : "string" } } ,
299299 } ) ;
300300 } ) ;
301+
302+ it ( "should properly resolve a remote schema" , async ( ) => {
303+ const mockHttpResolver = {
304+ order : 200 ,
305+ canRead : true ,
306+ safeUrlResolver : false ,
307+ read ( ) {
308+ return {
309+ type : "object" ,
310+ properties : {
311+ firstName : {
312+ type : "string" ,
313+ } ,
314+ } ,
315+ } ;
316+ } ,
317+ } ;
318+
319+ const schema = await $RefParser . dereference (
320+ {
321+ type : "object" ,
322+ required : [ "firstName" ] ,
323+ properties : {
324+ firstName : {
325+ $ref : "#/$defs/externalModel/properties/firstName" ,
326+ } ,
327+ } ,
328+ $defs : {
329+ externalModel : {
330+ $ref : "http://localhost:5000/myModel" ,
331+ } ,
332+ } ,
333+ } ,
334+ {
335+ resolve : {
336+ http : mockHttpResolver ,
337+ } ,
338+ } as ParserOptions ,
339+ ) ;
340+
341+ expect ( schema ) . to . deep . equal ( {
342+ type : "object" ,
343+ required : [ "firstName" ] ,
344+ properties : {
345+ firstName : {
346+ type : "string" ,
347+ } ,
348+ } ,
349+ $defs : {
350+ externalModel : {
351+ type : "object" ,
352+ properties : {
353+ firstName : {
354+ type : "string" ,
355+ } ,
356+ } ,
357+ } ,
358+ } ,
359+ } ) ;
360+ } ) ;
301361} ) ;
You can’t perform that action at this time.
0 commit comments