From 4d1e48df39b10f23c91a0fb872443a5a021e8ab3 Mon Sep 17 00:00:00 2001 From: Tony Tam Date: Sat, 18 Oct 2014 15:25:28 -0700 Subject: [PATCH] updated client per #669 --- dist/lib/swagger-client.js | 20 +++++++++++++------- lib/swagger-client.js | 20 +++++++++++++------- 2 files changed, 26 insertions(+), 14 deletions(-) diff --git a/dist/lib/swagger-client.js b/dist/lib/swagger-client.js index 735fc2a8..7e5bb9b6 100644 --- a/dist/lib/swagger-client.js +++ b/dist/lib/swagger-client.js @@ -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 + ('
' + 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 = '' + this.name + ' (' + str + ''; + if(!this.required) + str += ', optional'; + 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; } diff --git a/lib/swagger-client.js b/lib/swagger-client.js index 735fc2a8..7e5bb9b6 100644 --- a/lib/swagger-client.js +++ b/lib/swagger-client.js @@ -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 + ('
' + 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 = '' + this.name + ' (' + str + ''; + if(!this.required) + str += ', optional'; + 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; }