@@ -53,6 +53,28 @@ describe("Schema with circular (recursive) external $refs", () => {
5353 expect ( schema . definitions . child . properties . parents . items ) . to . equal ( schema . definitions . parent ) ;
5454 } ) ;
5555
56+ it ( 'should throw an error if "options.dereference.circular" is "ignore"' , async ( ) => {
57+ const parser = new $RefParser ( ) ;
58+
59+ const schema = await parser . dereference ( path . rel ( "test/specs/circular-external/circular-external.yaml" ) , {
60+ dereference : { circular : 'ignore' } ,
61+ } ) ;
62+
63+ expect ( schema ) . to . equal ( parser . schema ) ;
64+ expect ( schema ) . not . to . deep . equal ( dereferencedSchema ) ;
65+ expect ( parser . $refs . circular ) . to . equal ( true ) ;
66+ // @ts -expect-error TS(2532): Object is possibly 'undefined'.
67+ expect ( schema . definitions . pet . title ) . to . equal ( 'pet' ) ;
68+ // @ts -expect-error TS(2532): Object is possibly 'undefined'.
69+ expect ( schema . definitions . thing ) . to . deep . equal ( { $ref : 'circular-external.yaml#/definitions/thing' } ) ;
70+ // @ts -expect-error TS(2532): Object is possibly 'undefined'.
71+ expect ( schema . definitions . person ) . to . deep . equal ( { $ref : 'definitions/person.yaml' } ) ;
72+ // @ts -expect-error TS(2532): Object is possibly 'undefined'.
73+ expect ( schema . definitions . parent ) . to . deep . equal ( { $ref : 'definitions/parent.yaml' } ) ;
74+ // @ts -expect-error TS(2532): Object is possibly 'undefined'.
75+ expect ( schema . definitions . child ) . to . deep . equal ( { $ref : 'definitions/child.yaml' } ) ;
76+ } ) ;
77+
5678 it ( 'should throw an error if "options.dereference.circular" is false' , async ( ) => {
5779 const parser = new $RefParser ( ) ;
5880
0 commit comments