Skip to content

Commit ecb3417

Browse files
authored
Merge pull request #1042 from shockey/bug/ui-3012-circular-refs
Add regression test to resolver
2 parents 9360891 + e638eaa commit ecb3417

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

test/resolver.js

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff 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'

0 commit comments

Comments
 (0)