diff --git a/dist/lib/swagger-client.js b/dist/lib/swagger-client.js index 5173335d..99484597 100644 --- a/dist/lib/swagger-client.js +++ b/dist/lib/swagger-client.js @@ -1,6 +1,6 @@ /** * swagger-client - swagger.js is a javascript client for use with swaggering APIs. - * @version v2.1.5-M1 + * @version v2.1.6-M1 * @link http://swagger.io * @license apache 2.0 */ @@ -502,6 +502,8 @@ SwaggerClient.prototype.buildFromSpec = function(response) { for(i = 0; i < tags.length; i++) { var tag = this.tagFromLabel(tags[i]); var operationGroup = this[tag]; + if(typeof this.apis[tag] === 'undefined') + this.apis[tag] = {}; if(typeof operationGroup === 'undefined') { this[tag] = []; operationGroup = this[tag]; @@ -516,8 +518,16 @@ SwaggerClient.prototype.buildFromSpec = function(response) { this[tag].help = this.help.bind(operationGroup); this.apisArray.push(new OperationGroup(tag, operationGroup.description, operationGroup.externalDocs, operationObject)); } + if(typeof this.apis[tag].help !== 'function') + this.apis[tag].help = this.help.bind(operationGroup); + // bind to the apis object + this.apis[tag][operationId] = operationObject.execute.bind(operationObject); + this.apis[tag][operationId].help = operationObject.help.bind(operationObject); + this.apis[tag][operationId].asCurl = operationObject.asCurl.bind(operationObject); operationGroup[operationId] = operationObject.execute.bind(operationObject); operationGroup[operationId].help = operationObject.help.bind(operationObject); + operationGroup[operationId].asCurl = operationObject.asCurl.bind(operationObject); + operationGroup.apis.push(operationObject); operationGroup.operations[operationId] = operationObject; @@ -560,12 +570,18 @@ SwaggerClient.prototype.parseUri = function(uri) { }; }; -SwaggerClient.prototype.help = function() { +SwaggerClient.prototype.help = function(dontPrint) { var i; - log('operations for the "' + this.label + '" tag'); + var output = 'operations for the "' + this.label + '" tag'; for(i = 0; i < this.apis.length; i++) { var api = this.apis[i]; - log(' * ' + api.nickname + ': ' + api.operation.summary); + output += '\n * ' + api.nickname + ': ' + api.operation.summary; + } + if(dontPrint) + return output; + else { + log(output); + return output; } }; @@ -1610,6 +1626,7 @@ SwaggerClient.prototype.buildFrom1_2Spec = function (response) { res = new SwaggerResource(response, this); this.apis[newName] = res; this.apisArray.push(res); + this.finish(); } else { var k; this.expectedResourceCount = response.apis.length; @@ -1665,7 +1682,9 @@ SwaggerClient.prototype.buildFrom1_1Spec = function (response) { res = new SwaggerResource(response, this); this.apis[newName] = res; this.apisArray.push(res); + this.finish(); } else { + this.expectedResourceCount = response.apis.length; for (k = 0; k < response.apis.length; k++) { resource = response.apis[k]; res = new SwaggerResource(resource, this); @@ -1674,9 +1693,6 @@ SwaggerClient.prototype.buildFrom1_1Spec = function (response) { } } this.isValid = true; - if (this.success) { - this.success(); - } return this; }; @@ -1698,16 +1714,18 @@ SwaggerClient.prototype.convertInfo = function (resp) { }; SwaggerClient.prototype.selfReflect = function () { - var resource, resource_name, ref; + var resource, tag, ref; if (this.apis === null) { return false; } ref = this.apis; - for (resource_name in ref) { - resource = ref[resource_name]; - if (resource.ready === null) { + for (tag in ref) { + api = ref[tag]; + if (api.ready === null) { return false; } + this[tag] = api; + this[tag].help = __bind(api.help, api); } this.setConsolidatedModels(); this.ready = true; @@ -1743,7 +1761,6 @@ var SwaggerResource = function (resourceObj, api) { this.description = resourceObj.description; this.authorizations = (resourceObj.authorizations || {}); - var parts = this.path.split('/'); this.name = parts[parts.length - 1].replace('.{format}', ''); this.basePath = this.api.basePath; @@ -1792,6 +1809,21 @@ var SwaggerResource = function (resourceObj, api) { } }; +SwaggerResource.prototype.help = function (dontPrint) { + var i; + var output = 'operations for the "' + this.name + '" tag'; + for(i = 0; i < this.operationsArray.length; i++) { + var api = this.operationsArray[i]; + output += '\n * ' + api.nickname + ': ' + api.description; + } + if(dontPrint) + return output; + else { + log(output); + return output; + } +}; + SwaggerResource.prototype.getAbsoluteBasePath = function (relativeBasePath) { var pos, url; url = this.api.basePath; @@ -2108,6 +2140,7 @@ var SwaggerOperation = function (nickname, path, method, parameters, summary, no this.deprecated = deprecated; this['do'] = __bind(this['do'], this); + if(typeof this.deprecated === 'string') { switch(this.deprecated.toLowerCase()) { case 'true': case 'yes': case '1': { @@ -2225,8 +2258,8 @@ var SwaggerOperation = function (nickname, path, method, parameters, summary, no return _this['do'](arg1 || {}, arg2 || {}, arg3 || defaultSuccessCallback, arg4 || defaultErrorCallback); }; - this.resource[this.nickname].help = function () { - return _this.help(); + this.resource[this.nickname].help = function (dontPrint) { + return _this.help(dontPrint); }; this.resource[this.nickname].asCurl = function (args) { return _this.asCurl(args); @@ -2465,16 +2498,19 @@ SwaggerOperation.prototype.getMatchingParams = function (paramTypes, args) { return matchingParams; }; -SwaggerOperation.prototype.help = function () { - var msg = ''; +SwaggerOperation.prototype.help = function (dontPrint) { + var msg = this.nickname + ': ' + this.summary; var params = this.parameters; for (var i = 0; i < params.length; i++) { var param = params[i]; - if (msg !== '') - msg += '\n'; - msg += '* ' + param.name + (param.required ? ' (required)' : '') + " - " + param.description; + msg += '\n* ' + param.name + (param.required ? ' (required)' : '') + " - " + param.description; + } + if(dontPrint) + return msg; + else { + console.log(msg); + return msg; } - return msg; }; SwaggerOperation.prototype.asCurl = function (args) { @@ -2851,6 +2887,7 @@ JQueryHttpClient.prototype.execute = function(obj) { url: request.url, method: request.method, status: response.status, + statusText: response.statusText, data: response.responseText, headers: headers }; diff --git a/dist/swagger-ui.js b/dist/swagger-ui.js index 4ebbae90..9b45fd13 100644 --- a/dist/swagger-ui.js +++ b/dist/swagger-ui.js @@ -193,14 +193,6 @@ var Docs = { } }; -this["Handlebars"] = this["Handlebars"] || {}; -this["Handlebars"]["templates"] = this["Handlebars"]["templates"] || {}; -this["Handlebars"]["templates"]["apikey_button_view"] = Handlebars.template({"compiler":[6,">= 2.0.0-beta.1"],"main":function(depth0,helpers,partials,data) { - var helper, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression; - return "\n