File tree Expand file tree Collapse file tree 1 file changed +49
-0
lines changed Expand file tree Collapse file tree 1 file changed +49
-0
lines changed Original file line number Diff line number Diff line change @@ -45,6 +45,55 @@ describe('resolver', () => {
4545 }
4646 } )
4747
48+ it ( 'should be able to resolve circular $refs when a baseDoc is provided' , ( ) => {
49+ // Given
50+ const spec = {
51+ "one" : {
52+ "$ref" : "#/two"
53+ } ,
54+ "two" : {
55+ "a" : {
56+ "$ref" : "#/three"
57+ }
58+ } ,
59+ "three" : {
60+ "b" : {
61+ "$ref" : "#/two"
62+ }
63+ }
64+ }
65+
66+ // When
67+ return Swagger . resolve ( { spec, baseDoc : 'http://example.com/swagger.json' , allowMetaPatches : false } )
68+ . then ( handleResponse )
69+
70+ // Then
71+ function handleResponse ( obj ) {
72+ expect ( obj . errors ) . toEqual ( [ ] )
73+ expect ( obj . spec ) . toEqual ( {
74+ "one" : {
75+ "a" : {
76+ "b" : {
77+ "$ref" : "#/two"
78+ }
79+ }
80+ } ,
81+ "three" : {
82+ "b" : {
83+ "$ref" : "#/two"
84+ }
85+ } ,
86+ "two" : {
87+ "a" : {
88+ "b" : {
89+ "$ref" : "#/two"
90+ }
91+ }
92+ }
93+ } )
94+ }
95+ } )
96+
4897 it ( 'should resolve the url, if no spec provided' , function ( ) {
4998 // Given
5099 const url = 'http://example.com/swagger.json'
You can’t perform that action at this time.
0 commit comments