This commit is contained in:
Tony Tam
2014-09-23 00:54:14 -07:00
parent da661827bf
commit 922848b195
6 changed files with 1789 additions and 1799 deletions

View File

@@ -187,6 +187,7 @@ var SwaggerClient = function(url, options) {
this.isValid = false;
this.info = null;
this.useJQuery = false;
this.models = models;
options = (options||{});
if (url)
@@ -237,10 +238,12 @@ SwaggerClient.prototype.build = function() {
if(responseObj.swagger && responseObj.swagger === 2.0) {
self.swaggerVersion = responseObj.swagger;
self.buildFromSpec(responseObj);
this.isValid = true;
self.isValid = true;
}
else {
self.isValid = false;
self.failure();
}
else
this.isValid = false;
}
}
};
@@ -418,16 +421,22 @@ var Operation = function(parent, operationId, httpMethod, path, args, definition
var model;
var responses = this.responses;
if(responses['200'])
if(responses['200']) {
response = responses['200'];
else if(responses['default'])
defaultResponseCode = '200';
}
else if(responses['default']) {
response = responses['default'];
defaultResponseCode = 'default';
}
if(response && response.schema) {
var resolvedModel = this.resolveModel(response.schema, definitions);
if(resolvedModel) {
this.type = resolvedModel.name;
this.responseSampleJSON = JSON.stringify(resolvedModel.getSampleValue(), null, 2);
this.responseClassSignature = resolvedModel.getMockSignature();
delete responses[defaultResponseCode];
}
else {
this.type = response.schema.type;