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

hyperswitch

Package Overview
Dependencies
Maintainers
4
Versions
75
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hyperswitch - npm Package Compare versions

Comparing version 0.9.2 to 0.9.3

16

lib/filters/validator.js

@@ -47,4 +47,13 @@ "use strict";

class Validator {
constructor(parameters) {
constructor(parameters, definitions) {
this._ajv = constructAjv({ verbose: true });
if (definitions) {
Object.keys(definitions).forEach((schemaName) => {
this._ajv.addSchema(
definitions[schemaName],
`#/definitions/${schemaName}`
);
});
}
this._paramCoercionFunc = this._createTypeCoercionFunc(parameters.filter((p) => {

@@ -251,3 +260,6 @@ return p.in !== 'formData' && p.in !== 'body' && p.type !== 'string';

} else {
const validator = new Validator(specInfo.spec.parameters);
const validator = new Validator(
specInfo.spec.parameters,
specInfo.specRoot && specInfo.specRoot.definitions
);
CACHE.set(specInfo.spec, validator);

@@ -254,0 +266,0 @@ validator.validate(req);

3

lib/hyperswitch.js

@@ -220,3 +220,4 @@ 'use strict';

path: match.value.path,
spec: handler.spec
spec: handler.spec,
specRoot: match.value.specRoot
});

@@ -223,0 +224,0 @@ // This is a hack. Pure P.try get's executed on this tick, but we wanna

{
"name": "hyperswitch",
"version": "0.9.2",
"version": "0.9.3",
"description": "REST API creation framework",

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

@@ -9,3 +9,3 @@ "use strict";

var testValidator = function (req, parameters, example) {
var testValidator = function (req, parameters, example, definitions) {
return validator(null, req, function (hyper, req) {

@@ -18,2 +18,5 @@ if (example) {

parameters: parameters
},
specRoot: {
definitions: definitions
}

@@ -291,2 +294,33 @@ });

});
it('Should support refs to definitions for parameters', () => {
testValidator({
body: {
test_value: 'four',
int_test_value: 4
}
}, [
{
name: 'bodyParam',
in: 'body',
type: 'object',
schema: {
$ref: '#/definitions/test_schema'
},
required: 'true'
}
], undefined, {
test_schema: {
type: 'object',
parameters: {
test_value: {
type: 'string'
},
int_test_value: {
type: 'integer'
}
}
}
});
});
});
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