express-openapi-validator
Advanced tools
Comparing version 4.12.15 to 4.13.0
@@ -12,5 +12,6 @@ import { OpenAPIV3 } from './types'; | ||
readonly routes: RouteMetadata[]; | ||
readonly ignoreUndocumented: boolean; | ||
private readonly basePaths; | ||
private readonly ignorePaths; | ||
constructor(spec: Spec, ignorePaths: RegExp | Function); | ||
constructor(spec: Spec, ignorePaths: RegExp | Function, ignoreUndocumented?: boolean); | ||
isManagedRoute(path: string): boolean; | ||
@@ -17,0 +18,0 @@ shouldIgnoreRoute(path: string): any; |
@@ -5,3 +5,3 @@ "use strict"; | ||
class OpenApiContext { | ||
constructor(spec, ignorePaths) { | ||
constructor(spec, ignorePaths, ignoreUndocumented = false) { | ||
this.expressRouteMap = {}; | ||
@@ -14,2 +14,3 @@ this.openApiRouteMap = {}; | ||
this.ignorePaths = ignorePaths; | ||
this.ignoreUndocumented = ignoreUndocumented; | ||
this.buildRouteMaps(spec.routes); | ||
@@ -16,0 +17,0 @@ } |
@@ -80,2 +80,3 @@ import * as ajv from 'ajv'; | ||
ignorePaths?: RegExp | Function; | ||
ignoreUndocumented?: boolean; | ||
securityHandlers?: SecurityHandlers; | ||
@@ -82,0 +83,0 @@ coerceTypes?: boolean | 'array'; |
@@ -21,2 +21,6 @@ "use strict"; | ||
if (!schema) { | ||
// Prevents validation for routes which match on path but mismatch on method | ||
if (openApiContext.ignoreUndocumented) { | ||
return next(); | ||
} | ||
throw new types_1.MethodNotAllowed({ | ||
@@ -44,3 +48,3 @@ path: req.path, | ||
} | ||
else if (openApiContext.isManagedRoute(path)) { | ||
else if (openApiContext.isManagedRoute(path) && !openApiContext.ignoreUndocumented) { | ||
throw new types_1.NotFound({ | ||
@@ -47,0 +51,0 @@ path: req.path, |
@@ -209,2 +209,3 @@ "use strict"; | ||
validateApiKey() { | ||
var _d; | ||
const { req, scheme, path } = this; | ||
@@ -223,3 +224,3 @@ if (scheme.type === 'apiKey') { | ||
else if (scheme.in === 'cookie') { | ||
if (!req.cookies[scheme.name]) { | ||
if (!req.cookies[scheme.name] && !((_d = req.signedCookies) === null || _d === void 0 ? void 0 : _d[scheme.name])) { | ||
throw Error(`cookie '${scheme.name}' required`); | ||
@@ -226,0 +227,0 @@ } |
@@ -88,3 +88,3 @@ "use strict"; | ||
return { | ||
context: new openapi_context_1.OpenApiContext(spec, this.options.ignorePaths), | ||
context: new openapi_context_1.OpenApiContext(spec, this.options.ignorePaths, this.options.ignoreUndocumented), | ||
responseApiDoc: sp.apiDocRes, | ||
@@ -91,0 +91,0 @@ error: null, |
{ | ||
"name": "express-openapi-validator", | ||
"version": "4.12.15", | ||
"version": "4.13.0", | ||
"description": "Automatically validate API requests and responses with OpenAPI 3 and Express.", | ||
@@ -35,3 +35,3 @@ "main": "dist/index.js", | ||
"dependencies": { | ||
"@types/multer": "^1.4.6", | ||
"@types/multer": "^1.4.7", | ||
"ajv": "^6.12.6", | ||
@@ -38,0 +38,0 @@ "content-type": "^1.0.4", |
@@ -512,2 +512,3 @@ # 🦋 express-openapi-validator | ||
ignorePaths: /.*\/pets$/, | ||
ignoreUndocumented: false, | ||
fileUploader: { ... } | true | false, | ||
@@ -879,2 +880,8 @@ $refParser: { | ||
### ▪️ ignoreUndocumented (optional) | ||
Disables any form of validation for requests which are not documented in the OpenAPI spec. | ||
Defaults to `false` | ||
### ▪️ fileUploader (optional) | ||
@@ -881,0 +888,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
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
391650
5772
1334
5
21
Updated@types/multer@^1.4.7