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 6.0.0-alpha.2 to 6.0.0-alpha.3

2

dist/framework/ajv/index.js

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

const { ajvFormats } = options, ajvOptions = __rest(options, ["ajvFormats"]);
const ajv = new ajv_draft_04_1.default(Object.assign(Object.assign({}, ajvOptions), { allErrors: true, formats: formats_1.formats }));
const ajv = new ajv_draft_04_1.default(Object.assign(Object.assign({}, ajvOptions), { formats: formats_1.formats }));
// Clean openApiSpec

@@ -34,0 +34,0 @@ traverse(openApiSpec, { allKeys: true }, (schema => {

@@ -12,9 +12,10 @@ "use strict";

get response() {
const { coerceTypes, removeAdditional } = (this.options.validateResponses);
return Object.assign(Object.assign({}, this.baseOptions()), { useDefaults: false, coerceTypes,
const { allErrors, coerceTypes, removeAdditional } = (this.options.validateResponses);
return Object.assign(Object.assign({}, this.baseOptions()), { allErrors, useDefaults: false, coerceTypes,
removeAdditional });
}
get request() {
const { allowUnknownQueryParameters, coerceTypes, removeAdditional } = this.options.validateRequests;
return Object.assign(Object.assign({}, this.baseOptions()), { allowUnknownQueryParameters,
const { allErrors, allowUnknownQueryParameters, coerceTypes, removeAdditional } = this.options.validateRequests;
return Object.assign(Object.assign({}, this.baseOptions()), { allErrors,
allowUnknownQueryParameters,
coerceTypes,

@@ -27,3 +28,3 @@ removeAdditional });

baseOptions() {
const { coerceTypes, formats, validateFormats, serDes, ajvFormats } = this.options;
const { coerceTypes, formats, validateFormats, serDes, ajvFormats, } = this.options;
const serDesMap = {};

@@ -52,3 +53,3 @@ for (const serDesObject of serDes) {

removeAdditional: false,
validateFormats: validateFormats,
validateFormats,
formats,

@@ -55,0 +56,0 @@ serDesMap,

import * as ajv from 'ajv';
import * as multer from 'multer';
import { FormatsPluginOptions } from 'ajv-formats';
import { Request, Response, NextFunction, RequestHandler } from 'express';
import { Request, Response, NextFunction } from 'express';
import { RouteMetadata } from './openapi.spec.loader';

@@ -35,2 +35,9 @@ export { OpenAPIFrameworkArgs };

export declare type ValidateRequestOpts = {
/**
* Whether AJV should check all rules and collect all errors or return after the first error.
*
* This should not be set to `true` in production. See [AJV: Security risks of trusted
* schemas](https://ajv.js.org/security.html#security-risks-of-trusted-schemas).
*/
allErrors?: boolean;
allowUnknownQueryParameters?: boolean;

@@ -41,2 +48,9 @@ coerceTypes?: boolean | 'array';

export declare type ValidateResponseOpts = {
/**
* Whether AJV should check all rules and collect all errors or return after the first error.
*
* This should not be set to `true` in production. See [AJV: Security risks of trusted
* schemas](https://ajv.js.org/security.html#security-risks-of-trusted-schemas).
*/
allErrors?: boolean;
removeAdditional?: boolean | 'all' | 'failing';

@@ -51,3 +65,3 @@ coerceTypes?: boolean | 'array';

basePath: string;
resolver: (handlersPath: string, route: RouteMetadata, apiDoc: OpenAPIV3.DocumentV3 | OpenAPIV3.DocumentV3_1) => RequestHandler | Promise<RequestHandler>;
resolver: (handlersPath: string, route: RouteMetadata, apiDoc: OpenAPIV3.DocumentV3 | OpenAPIV3.DocumentV3_1) => unknown;
};

@@ -89,3 +103,3 @@ export declare type Format = {

export interface OpenApiValidatorOpts {
apiSpec: DeepImmutable<OpenAPIV3.DocumentV3> | string;
apiSpec: DeepImmutable<OpenAPIV3.DocumentV3> | DeepImmutable<OpenAPIV3.DocumentV3_1> | string;
validateApiSpec?: boolean;

@@ -92,0 +106,0 @@ validateResponses?: boolean | ValidateResponseOpts;

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

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

"compile:release": "rimraf dist && tsc --sourceMap false",
"test": "mocha -r source-map-support/register -r ts-node/register --files --recursive -R spec --extension .spec.ts test",
"test:debug": "mocha -r source-map-support/register -r ts-node/register --inspect-brk --files --recursive --extension .spec.ts test",
"test:coverage": "nyc mocha -r source-map-support/register -r ts-node/register --recursive --extension .spec.ts test",
"test": "mocha -r source-map-support/register -r ts-node/register --files --recursive -R spec 'test/**/*.spec.ts' 'test/*.spec.ts'",
"test:debug": "mocha -r source-map-support/register -r ts-node/register --inspect-brk --files --recursive 'test/**/*.spec.ts' 'test/*.spec.ts'",
"test:coverage": "nyc mocha -r source-map-support/register -r ts-node/register --recursive 'test/**/*.spec.ts' 'test/*.spec.ts'",
"test:reset": "rimraf node_modules && npm i && npm run compile && npm t",

@@ -14,0 +14,0 @@ "coveralls": "cat coverage/lcov.info | coveralls -v",

# ๐Ÿฆ‹ express-openapi-validator
docs.
[![example workflow](https://github.com/cdimascio/express-openapi-validator/actions/workflows/default.yml/badge.svg)](#) [![](https://img.shields.io/npm/v/express-openapi-validator.svg)](https://www.npmjs.com/package/express-openapi-validator) [![](https://img.shields.io/npm/dm/express-openapi-validator?color=blue)](https://www.npmjs.com/package/express-openapi-validator) [![All Contributors](https://img.shields.io/badge/all_contributors-54-darkcyan.svg?style=flat)](#contributors) [![Coverage Status](https://coveralls.io/repos/github/cdimascio/express-openapi-validator/badge.svg?branch=master)](https://coveralls.io/github/cdimascio/express-openapi-validator?branch=master) [![Codacy Badge](https://api.codacy.com/project/badge/Grade/1570a06f609345ddb237114bbd6ceed7)](https://www.codacy.com/manual/cdimascio/express-openapi-validator?utm_source=github.com&utm_medium=referral&utm_content=cdimascio/express-openapi-validator&utm_campaign=Badge_Grade) [![](https://img.shields.io/gitter/room/cdimascio-oss/community?color=%23eb205a)](https://gitter.im/cdimascio-oss/community) [![Gitpod Ready-to-Code](https://img.shields.io/badge/Gitpod-Ready--to--Code-blue?logo=gitpod)](https://gitpod.io/#https://github.com/cdimascio/express-openapi-validator) [![](https://img.shields.io/badge/documentation-yes-informational)](https://cdimascio.github.io/express-openapi-validator-documentation/) [![](https://img.shields.io/badge/license-MIT-blue.svg)](#license)

@@ -33,2 +31,4 @@

[OAS 3.1 (experimental)](https://github.com/cdimascio/express-openapi-validator/pull/882)
## Install

@@ -39,4 +39,4 @@

## latest beta
npm install express-openapi-validator@4.14.0-beta.1
# experimental OAS 3.1 in alpha (contributions welcome - see branch `oas-3.1` and pr-882)
npm install express-openapi-validator@6.0.0-alpha.2
```

@@ -43,0 +43,0 @@

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

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