Skip to content

Commit f3eeda5

Browse files
committed
fixed recursion loop for sample json
1 parent 0341416 commit f3eeda5

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

lib/swagger.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ SwaggerApi.prototype.build = function() {
6767
}
6868
},
6969
response: function(resp) {
70-
var responseObj = resp.obj;
70+
var responseObj = resp.obj || JSON.parse(resp.data);
7171
_this.swaggerVersion = responseObj.swaggerVersion;
7272
if (_this.swaggerVersion === "1.2") {
7373
return _this.buildFromSpec(responseObj);
@@ -284,8 +284,8 @@ var SwaggerResource = function(resourceObj, api) {
284284
accept: "application/json"
285285
},
286286
on: {
287-
response: function(response) {
288-
var responseObj = response.obj;
287+
response: function(resp) {
288+
var responseObj = resp.obj || JSON.parse(resp.data);
289289
return _this.addApiDeclaration(responseObj);
290290
},
291291
error: function(response) {
@@ -478,11 +478,11 @@ SwaggerModel.prototype.getMockSignature = function(modelsToIgnore) {
478478
var returnVal = classOpen + '<div>' + propertiesStr.join(',</div><div>') + '</div>' + classClose;
479479
if (!modelsToIgnore)
480480
modelsToIgnore = [];
481-
modelsToIgnore.push(this);
481+
modelsToIgnore.push(this.name);
482482

483483
for (var i = 0; i < this.properties.length; i++) {
484484
prop = this.properties[i];
485-
if ((prop.refModel != null) && modelsToIgnore.indexOf(prop.refModel) === -1) {
485+
if ((prop.refModel != null) && modelsToIgnore.indexOf(prop.refModel.name) === -1) {
486486
returnVal = returnVal + ('<br>' + prop.refModel.getMockSignature(modelsToIgnore));
487487
}
488488
}
@@ -534,7 +534,7 @@ var SwaggerModelProperty = function(name, obj) {
534534

535535
SwaggerModelProperty.prototype.getSampleValue = function(modelsToIgnore) {
536536
var result;
537-
if ((this.refModel != null) && (modelsToIgnore[this.refModel.name] === undefined)) {
537+
if ((this.refModel != null) && (modelsToIgnore.indexOf(prop.refModel.name) === -1)) {
538538
result = this.refModel.createJSONSample(modelsToIgnore);
539539
} else {
540540
if (this.isCollection) {

0 commit comments

Comments
 (0)