File tree Expand file tree Collapse file tree 1 file changed +45
-0
lines changed
packages/core/src/__tests__ Expand file tree Collapse file tree 1 file changed +45
-0
lines changed Original file line number Diff line number Diff line change @@ -1637,4 +1637,49 @@ responses:: !!foo
16371637 } ) ,
16381638 ] ) ;
16391639 } ) ;
1640+
1641+ test . concurrent ( 'should handle direct circular file $refs' , async ( ) => {
1642+ const spectral = new Spectral ( ) ;
1643+ spectral . setRuleset ( {
1644+ rules : {
1645+ 'valid-type' : {
1646+ given : '$..type' ,
1647+ then : {
1648+ function ( ) {
1649+ return [
1650+ {
1651+ message : 'Restricted type' ,
1652+ } ,
1653+ ] ;
1654+ } ,
1655+ } ,
1656+ } ,
1657+ } ,
1658+ } ) ;
1659+
1660+ const documentUri = path . join ( __dirname , './__fixtures__/test.json' ) ;
1661+ const document = new Document (
1662+ JSON . stringify ( {
1663+ oneOf : [
1664+ {
1665+ type : 'number' ,
1666+ } ,
1667+ {
1668+ $ref : './test.json' ,
1669+ } ,
1670+ ] ,
1671+ } ) ,
1672+ Parsers . Json ,
1673+ documentUri ,
1674+ ) ;
1675+ const results = spectral . run ( document ) ;
1676+
1677+ await expect ( results ) . resolves . toEqual ( [
1678+ expect . objectContaining ( {
1679+ code : 'valid-type' ,
1680+ path : [ 'oneOf' , '0' , 'type' ] ,
1681+ severity : DiagnosticSeverity . Warning ,
1682+ } ) ,
1683+ ] ) ;
1684+ } ) ;
16401685} ) ;
You can’t perform that action at this time.
0 commit comments