From 295fa75dc43fe856a3c10581c3dcdac4c8365869 Mon Sep 17 00:00:00 2001 From: Jeremy Whitlock Date: Mon, 27 Oct 2014 19:36:02 -0600 Subject: [PATCH] Do not create operations for non-HTTP methods/verbs Fixes #678 --- lib/swagger-client.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/lib/swagger-client.js b/lib/swagger-client.js index 567dc8e9..28c34639 100644 --- a/lib/swagger-client.js +++ b/lib/swagger-client.js @@ -95,7 +95,7 @@ SwaggerAuthorizations.prototype.apply = function(obj, authorizations) { if (result === true) status = true; } - } + } } } @@ -415,6 +415,9 @@ SwaggerClient.prototype.buildFromSpec = function(response) { if(typeof response.paths[path] === 'object') { var httpMethod; for(httpMethod in response.paths[path]) { + if(['delete', 'get', 'head', 'options', 'patch', 'post', 'put'].indexOf(httpMethod) === -1) { + continue; + } var operation = response.paths[path][httpMethod]; var tags = operation.tags; if(typeof tags === 'undefined') { @@ -991,7 +994,7 @@ Operation.prototype.encodeCollection = function(type, name, value) { } /** - * TODO this encoding needs to be changed + * TODO this encoding needs to be changed **/ Operation.prototype.encodeQueryParam = function(arg) { return escape(arg); @@ -1031,7 +1034,7 @@ var Model = function(name, definition) { if(requiredFields.indexOf(key) >= 0) required = true; this.properties.push(new Property(key, property, required)); - } + } } } @@ -1210,7 +1213,7 @@ Property.prototype.toString = function() { str += ', optional'; str += ')'; } - else + else str = this.name + ' (' + JSON.stringify(this.obj) + ')'; if(typeof this.description !== 'undefined') @@ -1474,4 +1477,4 @@ ShredHttpClient.prototype.execute = function(obj) { obj.on = res; } return this.shred.request(obj); -}; \ No newline at end of file +};