Socket
Socket
Sign inDemoInstall

express-openapi-validator

Package Overview
Dependencies
Maintainers
1
Versions
278
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

express-openapi-validator - npm Package Compare versions

Comparing version 4.13.1 to 4.13.2

2

dist/framework/base.path.js

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

const allParamCombos = cartesian(...allParams);
const toPath = path_to_regexp_1.compile(this.expressPath);
const toPath = (0, path_to_regexp_1.compile)(this.expressPath);
const paths = new Set();

@@ -66,0 +66,0 @@ for (const combo of allParamCombos) {

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

};
const regexp = path_to_regexp_1.pathToRegexp(expressRoute, keys, pathOpts);
const regexp = (0, path_to_regexp_1.pathToRegexp)(expressRoute, keys, pathOpts);
const matchedRoute = regexp.exec(path);

@@ -75,0 +75,0 @@ if (matchedRoute) {

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

const mult = multer(options.multerOpts);
const Ajv = ajv_1.createRequestAjv(apiDoc, Object.assign({}, options.ajvOpts));
const Ajv = (0, ajv_1.createRequestAjv)(apiDoc, Object.assign({}, options.ajvOpts));
return (req, res, next) => {

@@ -12,0 +12,0 @@ // TODO check that format: binary (for upload) else do not use multer.any()

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

options.allowUnknownQueryParameters;
this.ajv = ajv_1.createRequestAjv(apiDoc, Object.assign(Object.assign({}, options), { coerceTypes: true }));
this.ajvBody = ajv_1.createRequestAjv(apiDoc, options);
this.ajv = (0, ajv_1.createRequestAjv)(apiDoc, Object.assign(Object.assign({}, options), { coerceTypes: true }));
this.ajvBody = (0, ajv_1.createRequestAjv)(apiDoc, options);
}

@@ -101,6 +101,6 @@ validate(req, res, next) {

else {
const errors = util_1.augmentAjvErrors([]
const errors = (0, util_1.augmentAjvErrors)([]
.concat((_e = validator.validatorGeneral.errors) !== null && _e !== void 0 ? _e : [])
.concat((_f = validatorBody.errors) !== null && _f !== void 0 ? _f : []));
const err = util_1.ajvErrorsToValidatorError(400, errors);
const err = (0, util_1.ajvErrorsToValidatorError)(400, errors);
const message = this.ajv.errorsText(errors, { dataVar: 'request' });

@@ -107,0 +107,0 @@ const error = new types_1.BadRequest({

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

this.spec = openApiSpec;
this.ajvBody = ajv_1.createResponseAjv(openApiSpec, options);
this.ajvBody = (0, ajv_1.createResponseAjv)(openApiSpec, options);
this.eovOptions = eovOptions;

@@ -105,3 +105,3 @@ // This is a pseudo-middleware function. It doesn't get registered with

const validatorContentTypes = Object.keys(svalidator);
const contentType = util_1.findResponseContent(accepts, validatorContentTypes) ||
const contentType = (0, util_1.findResponseContent)(accepts, validatorContentTypes) ||
validatorContentTypes[0]; // take first contentType, if none found

@@ -152,3 +152,3 @@ if (validatorContentTypes.length === 0) {

if (!valid) {
const errors = util_1.augmentAjvErrors(validator.errors);
const errors = (0, util_1.augmentAjvErrors)(validator.errors);
const message = this.ajvBody.errorsText(errors, {

@@ -159,3 +159,3 @@ dataVar: '', // responses

path: path,
errors: util_1.ajvErrorsToValidatorError(500, errors).errors,
errors: (0, util_1.ajvErrorsToValidatorError)(500, errors).errors,
message: message,

@@ -162,0 +162,0 @@ });

@@ -45,3 +45,8 @@ "use strict";

if (!content) {
const msg = contentType.contentType === 'not_provided'
// check if required is false, if so allow request when no content type is supplied
const contentNotProvided = contentType.contentType === 'not_provided';
if ((contentType.contentType === undefined || contentNotProvided) && requestBody.required === false) {
return {};
}
const msg = contentNotProvided
? 'media type not specified'

@@ -48,0 +53,0 @@ : `unsupported media type ${contentType.contentType}`;

@@ -42,4 +42,4 @@ "use strict";

(parameters || []).forEach((p) => {
const parameter = util_1.dereferenceParameter(this._apiDocs, p);
const { name, schema } = util_1.normalizeParameter(this.ajv, parameter);
const parameter = (0, util_1.dereferenceParameter)(this._apiDocs, p);
const { name, schema } = (0, util_1.normalizeParameter)(this.ajv, parameter);
const { type } = schema;

@@ -46,0 +46,0 @@ const { style, explode } = parameter;

@@ -30,6 +30,6 @@ "use strict";

parameters.forEach((p) => {
const parameter = util_1.dereferenceParameter(this._apiDocs, p);
const parameter = (0, util_1.dereferenceParameter)(this._apiDocs, p);
this.validateParameterType(path, parameter);
const reqField = PARAM_TYPE[parameter.in];
const { name, schema } = util_1.normalizeParameter(this._ajv, parameter);
const { name, schema } = (0, util_1.normalizeParameter)(this._ajv, parameter);
if (!schemas[reqField].properties) {

@@ -36,0 +36,0 @@ schemas[reqField] = {

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

constructor(apiDoc, ajvOptions, validateResponsesOpts) {
this.ajv = ajv_1.createRequestAjv(apiDoc, ajvOptions);
this.ajv = (0, ajv_1.createRequestAjv)(apiDoc, ajvOptions);
this.apiDoc = apiDoc;

@@ -42,0 +42,0 @@ this.serDesMap = ajvOptions.serDesMap;

@@ -264,6 +264,6 @@ "use strict";

if (!options.apiSpec)
throw ono_1.default('apiSpec required');
throw (0, ono_1.default)('apiSpec required');
const securityHandlers = options.securityHandlers;
if (securityHandlers != null) {
throw ono_1.default('securityHandlers is not supported. Use validateSecurities.handlers instead.');
throw (0, ono_1.default)('securityHandlers is not supported. Use validateSecurities.handlers instead.');
}

@@ -275,3 +275,3 @@ if (options.coerceTypes) {

if (multerOpts != null) {
throw ono_1.default('multerOpts is not supported. Use fileUploader instead.');
throw (0, ono_1.default)('multerOpts is not supported. Use fileUploader instead.');
}

@@ -281,3 +281,3 @@ const unknownFormats = options.unknownFormats;

if (!unknownFormats) {
throw ono_1.default("unknownFormats must contain an array of unknownFormats, 'ignore' or true");
throw (0, ono_1.default)("unknownFormats must contain an array of unknownFormats, 'ignore' or true");
}

@@ -288,3 +288,3 @@ }

!Array.isArray(unknownFormats))
throw ono_1.default("unknownFormats must contain an array of unknownFormats, 'ignore' or true");
throw (0, ono_1.default)("unknownFormats must contain an array of unknownFormats, 'ignore' or true");
}

@@ -291,0 +291,0 @@ normalizeOptions(options) {

{
"name": "express-openapi-validator",
"version": "4.13.1",
"version": "4.13.2",
"description": "Automatically validate API requests and responses with OpenAPI 3 and Express.",

@@ -52,5 +52,5 @@ "main": "dist/index.js",

"@types/express": "4.17.11",
"@types/mocha": "^8.2.2",
"@types/morgan": "^1.9.2",
"@types/node": "^15.3.1",
"@types/mocha": "^9.0.0",
"@types/morgan": "^1.9.3",
"@types/node": "^16.9.1",
"@types/supertest": "^2.0.11",

@@ -62,14 +62,14 @@ "body-parser": "^1.19.0",

"cookie-parser": "^1.4.5",
"coveralls": "^3.1.0",
"coveralls": "^3.1.1",
"express": "^4.17.1",
"mocha": "^8.4.0",
"mocha": "^9.1.1",
"morgan": "^1.10.0",
"nodemon": "^2.0.7",
"nodemon": "^2.0.12",
"nyc": "^15.1.0",
"prettier": "^2.3.0",
"source-map-support": "0.5.19",
"supertest": "^6.1.3",
"ts-node": "^9.1.1",
"typescript": "^4.2.4"
"prettier": "^2.4.0",
"source-map-support": "0.5.20",
"supertest": "^6.1.6",
"ts-node": "^10.2.1",
"typescript": "^4.4.3"
}
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

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