#1892 infinite loop when rendering self-references

This commit is contained in:
Anna Bodnia
2016-01-21 18:36:00 +02:00
parent a9bbf31cc7
commit 9a5925f921
8 changed files with 144 additions and 36 deletions

View File

@@ -61,6 +61,44 @@ describe('SwaggerUi.partials.signature tests', function () {
'xml': { 'name': 'Tag' }
},
'name': 'Tag'
},
'Loop1': {
'definition': {
'type': 'object',
'properties': {
'id': { 'type': 'integer'},
'loop2': {
'$ref': '#/definitions/Loop2'
}
},
'xml': { 'name': 'Loop1' }
},
'name': 'Loop1'
},
'Loop2': {
'definition': {
'type': 'object',
'properties': {
'id': { 'type': 'integer'},
'loop1': {
'$ref': '#/definitions/Loop1'
}
},
'xml': { 'name': 'Loop2' }
},
'name': 'Loop2'
},
'Loop3': {
'definition': {
'type': 'object',
'properties' : {
'loop1': {
'$ref': '#/definitions/Loop1'
}
},
'xml': { 'name': 'Loop3' }
},
'name': 'Loop3'
}
};
@@ -438,7 +476,7 @@ describe('SwaggerUi.partials.signature tests', function () {
}
};
expect(sut.createSchemaXML(name, definition, models, true)).to.equal(expected);
expect(sut.createSchemaXML(name, definition, models, { isParam: true })).to.equal(expected);
});
it('returns object with passed parameter as attribute', function () {
@@ -510,6 +548,38 @@ describe('SwaggerUi.partials.signature tests', function () {
expect(sut.createSchemaXML('', schema, models)).to.equal(expected);
});
it('infinite loop Loop1 => Loop2, Loop2 => Loop1', function () {
var expected = '<Loop1>' +
'<id>1</id>' +
'<Loop2>' +
'<id>1</id>' +
'<!-- Infinite loop to model Loop1 -->' +
'</Loop2>' +
'</Loop1>';
var schema = {
$ref: '#/definitions/Loop1'
};
expect(sut.createSchemaXML('', schema, models)).to.equal(expected);
});
it('infinite loop Loop3 => Loop1, Loop1 => Loop2, Loop2 => Loop1', function () {
var expected = '<Loop3>' +
'<Loop1>' +
'<id>1</id>' +
'<Loop2>' +
'<id>1</id>' +
'<!-- Infinite loop to model Loop1 -->' +
'</Loop2>' +
'</Loop1>' +
'</Loop3>';
var schema = {
$ref: '#/definitions/Loop3'
};
expect(sut.createSchemaXML('', schema, models)).to.equal(expected);
});
});
});
});