updated client per #669

This commit is contained in:
Tony Tam
2014-10-18 15:25:28 -07:00
parent dc84dfc8f8
commit 4d1e48df39
2 changed files with 26 additions and 14 deletions

View File

@@ -1002,7 +1002,7 @@ var Model = function(name, definition) {
this.name = name;
this.definition = definition || {};
this.properties = [];
var requiredFields = definition.enum || [];
var requiredFields = definition.required || [];
var key;
var props = definition.properties;
@@ -1063,7 +1063,7 @@ Model.prototype.getMockSignature = function(modelsToIgnore) {
var prop = this.properties[i];
var ref = prop['$ref'];
var model = models[ref];
if (model && typeof modelsToIgnore === 'undefined') {
if (model && typeof modelsToIgnore[model.name] === 'undefined') {
returnVal = returnVal + ('<br>' + model.getMockSignature(modelsToIgnore));
}
}
@@ -1085,6 +1085,7 @@ var Property = function(name, obj, required) {
obj = obj.items;
}
this.name = name;
this.description = obj.description;
this.obj = obj;
this.optional = true;
this.example = obj.example || null;
@@ -1182,12 +1183,17 @@ simpleRef = function(name) {
Property.prototype.toString = function() {
var str = getStringSignature(this.obj);
if(str !== '')
str = this.name + ' : ' + str;
if(str !== '') {
str = '<span class="propName ' + this.required + '">' + this.name + '</span> (<span class="propType">' + str + '</span>';
if(!this.required)
str += ', <span class="propOptKey">optional</span>';
str += ')';
}
else
str = this.name + ' : ' + JSON.stringify(this.obj);
if(!this.required)
str += ' (optional)';
str = this.name + ' (' + JSON.stringify(this.obj) + ')';
if(typeof this.description !== 'undefined')
str += ': ' + this.description;
return str;
}