Skip to content

Commit

Permalink
updated client, version
Browse files Browse the repository at this point in the history
  • Loading branch information
fehguy committed Feb 9, 2015
1 parent 002a63c commit 61a87b8
Show file tree
Hide file tree
Showing 5 changed files with 291 additions and 237 deletions.
39 changes: 33 additions & 6 deletions dist/lib/swagger-client.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* swagger-client - swagger.js is a javascript client for use with swaggering APIs.
* @version v2.1.1-M1
* @version v2.1.2-M1
* @link http://swagger.io
* @license apache 2.0
*/
Expand Down Expand Up @@ -578,6 +578,20 @@ var Operation = function(parent, scheme, operationId, httpMethod, path, args, de
this.description = args.description;
this.useJQuery = parent.useJQuery;

if(typeof this.deprecated === 'string') {
switch(this.deprecated.toLowerCase()) {
case 'true': case 'yes': case '1': {
this.deprecated = true;
break;
}
case 'false': case 'no': case '0': case null: {
this.deprecated = false;
break;
}
default: this.deprecated = Boolean(this.deprecated);
}
}

if(definitions) {
// add to global models
var key;
Expand Down Expand Up @@ -810,9 +824,7 @@ Operation.prototype.getHeaderParams = function (args) {
if (param.in === 'header') {
var value = args[param.name];
if(Array.isArray(value))
value = this.encodePathCollection(param.collectionFormat, param.name, value);
else
value = this.encodePathParam(value);
value = value.toString();
headers[param.name] = value;
}
}
Expand Down Expand Up @@ -1683,6 +1695,7 @@ 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;
Expand Down Expand Up @@ -1761,7 +1774,7 @@ SwaggerResource.prototype.addApiDeclaration = function (response) {
this.consumes = response.consumes;
if ((typeof response.basePath === 'string') && response.basePath.replace(/\s/g, '').length > 0)
this.basePath = response.basePath.indexOf('http') === -1 ? this.getAbsoluteBasePath(response.basePath) : response.basePath;

this.resourcePath = response.resourcePath;
this.addModels(response.models);
if (response.apis) {
for (var i = 0 ; i < response.apis.length; i++) {
Expand Down Expand Up @@ -2040,9 +2053,23 @@ var SwaggerOperation = function (nickname, path, method, parameters, summary, no
this.consumes = consumes;
this.produces = produces;
this.authorizations = typeof authorizations !== 'undefined' ? authorizations : resource.authorizations;
this.deprecated = (typeof deprecated === 'string' ? Boolean(deprecated) : deprecated);
this.deprecated = deprecated;
this['do'] = __bind(this['do'], this);

if(typeof this.deprecated === 'string') {
switch(this.deprecated.toLowerCase()) {
case 'true': case 'yes': case '1': {
this.deprecated = true;
break;
}
case 'false': case 'no': case '0': case null: {
this.deprecated = false;
break;
}
default: this.deprecated = Boolean(this.deprecated);
}
}

if (errors.length > 0) {
console.error('SwaggerOperation errors', errors, arguments);
this.resource.api.fail(errors);
Expand Down
Loading

0 comments on commit 61a87b8

Please sign in to comment.