New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

swagger-router

Package Overview
Dependencies
Maintainers
3
Versions
40
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

swagger-router - npm Package Compare versions

Comparing version 0.2.4 to 0.2.5

config.example.yaml

21

lib/reqTemplate.js

@@ -18,3 +18,4 @@ "use strict";

if (typeof destination !== 'object' || typeof source !== 'object') {
throw new Error('Illegal spec. Merge source and destination must be objects');
throw new Error('Illegal argument. ' +
'Merge source and destination must be objects');
}

@@ -29,2 +30,20 @@

return result;
},
strip: function(object, properties) {
if (typeof object !== 'object') {
throw new Error('Illegal argument. ' +
'Strip can only be applied to objects');
}
object = Object.assign({}, object);
if (typeof properties === 'string') {
delete object[properties];
} else if (Array.isArray(properties)) {
properties.forEach(function(prop) {
delete object[prop];
});
} else {
throw new Error('Illegal argument. ' +
'Strip "properties" argument must be string or array');
}
return object;
}

@@ -31,0 +50,0 @@ };

2

package.json
{
"name": "swagger-router",
"version": "0.2.4",
"version": "0.2.5",
"description": "An efficient swagger 2 based router with support for multiple APIs. For use in RESTBase.",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -129,1 +129,3 @@ # Swagger 2 router

with merged properties, but without overriding.
- `$$.strip(object, properties)` - removes field names listed in `properties` array from an `object`. `properties`
could also be a string, if a single field should be removed.

@@ -318,2 +318,29 @@ "use strict";

});
it('should strip the object', function() {
var template = new Template({
method: 'get',
uri: 'test.com',
headers: '{$$.strip($.request.headers, "removed_header")}',
body: '{$$.strip($.request.body, ["removed_field1", "removed_field2"])}'
});
var result = template.expand({
request: {
headers: {
not_removed_header: 'value',
removed_header: 'value'
},
body: {
not_removed_field: 'value',
removed_field1: 'value',
removed_field2: 'value'
}
}
});
assert.deepEqual(result.headers.not_removed_header, 'value');
assert.deepEqual(result.headers.removed_header, undefined);
assert.deepEqual(result.body.not_removed_field, 'value');
assert.deepEqual(result.body.removed_field1, undefined);
assert.deepEqual(result.body.removed_field2, undefined);
});
});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc