@@ -411,6 +411,96 @@ suite('JSON Schema', () => {
411
411
412
412
} ) ;
413
413
414
+
415
+ test ( 'Resolving external $ref two levels' , async function ( ) {
416
+ const service = new SchemaService . JSONSchemaService ( newMockRequestService ( ) , workspaceContext ) ;
417
+ service . setSchemaContributions ( {
418
+ schemas : {
419
+ "https://myschemastore/main/schema1.json" : {
420
+ id : 'https://myschemastore/main/schema1.json' ,
421
+ definitions : {
422
+ "world" : {
423
+ $id : '#world' ,
424
+ type : 'string' ,
425
+ const : 'world'
426
+ }
427
+ } ,
428
+ type : 'object' ,
429
+ properties : {
430
+ p1 : {
431
+ $ref : 'schema2.json#blue'
432
+ }
433
+ }
434
+ } ,
435
+ "https://myschemastore/main/schema3.json" : {
436
+ id : 'https://myschemastore/main/schema3.json' ,
437
+ definitions : {
438
+ "world" : {
439
+ $id : '#world' ,
440
+ type : 'string' ,
441
+ const : 'world'
442
+ }
443
+ }
444
+ } ,
445
+ "https://myschemastore/main/schema2.json" : {
446
+ id : 'https://myschemastore/main/schema2.json' ,
447
+ definitions : {
448
+ "blue" : {
449
+ $id : '#blue' ,
450
+ $ref : 'schema3.json#world'
451
+ }
452
+ }
453
+ }
454
+ }
455
+ } ) ;
456
+
457
+ const resolvedSchema = await service . getResolvedSchema ( 'https://myschemastore/main/schema1.json' ) ;
458
+ assert . deepStrictEqual ( resolvedSchema ?. schema . properties ?. p1 , {
459
+ type : 'string' ,
460
+ const : 'world'
461
+ } ) ;
462
+ } ) ;
463
+
464
+
465
+ test ( 'Resolving external $ref recursive' , async function ( ) {
466
+ const service = new SchemaService . JSONSchemaService ( newMockRequestService ( ) , workspaceContext ) ;
467
+ service . setSchemaContributions ( {
468
+ schemas : {
469
+ "https://myschemastore/main/schema1.json" : {
470
+ id : 'https://myschemastore/main/schema1.json' ,
471
+ definitions : {
472
+ "world" : {
473
+ $id : '#world' ,
474
+ type : 'string' ,
475
+ const : 'world'
476
+ }
477
+ } ,
478
+ type : 'object' ,
479
+ properties : {
480
+ p1 : {
481
+ $ref : 'schema2.json#blue'
482
+ }
483
+ }
484
+ } ,
485
+ "https://myschemastore/main/schema2.json" : {
486
+ id : 'https://myschemastore/main/schema2.json' ,
487
+ definitions : {
488
+ "blue" : {
489
+ $id : '#blue' ,
490
+ $ref : 'schema1.json#world'
491
+ }
492
+ }
493
+ }
494
+ }
495
+ } ) ;
496
+
497
+ const resolvedSchema = await service . getResolvedSchema ( 'https://myschemastore/main/schema1.json' ) ;
498
+ assert . deepStrictEqual ( resolvedSchema ?. schema . properties ?. p1 , {
499
+ type : 'string' ,
500
+ const : 'world'
501
+ } ) ;
502
+ } ) ;
503
+
414
504
test ( 'Resolving $refs 5' , async function ( ) {
415
505
const service = new SchemaService . JSONSchemaService ( newMockRequestService ( ) , workspaceContext ) ;
416
506
service . setSchemaContributions ( {
0 commit comments