express-openapi-validator
Advanced tools
Comparing version
@@ -13,4 +13,5 @@ import { NextFunction, Response } from 'express'; | ||
private buildMiddleware; | ||
private multipartNested; | ||
private discriminatorValidator; | ||
private processQueryParam; | ||
} |
@@ -98,2 +98,5 @@ "use strict"; | ||
const schemaBody = validator === null || validator === void 0 ? void 0 : validator.schemaBody; | ||
if (contentType.mediaType === 'multipart/form-data') { | ||
this.multipartNested(req, schemaBody); | ||
} | ||
const discriminator = (_d = (_c = schemaBody === null || schemaBody === void 0 ? void 0 : schemaBody.properties) === null || _c === void 0 ? void 0 : _c.body) === null || _d === void 0 ? void 0 : _d._discriminator; | ||
@@ -122,2 +125,18 @@ const discriminatorValidator = this.discriminatorValidator(req, discriminator); | ||
} | ||
multipartNested(req, schemaBody) { | ||
Object.keys(req.body).forEach((key) => { | ||
var _a, _b, _c; | ||
const value = req.body[key]; | ||
const type = (_c = (_b = (_a = schemaBody === null || schemaBody === void 0 ? void 0 : schemaBody.properties) === null || _a === void 0 ? void 0 : _a.body) === null || _b === void 0 ? void 0 : _b.properties[key]) === null || _c === void 0 ? void 0 : _c.type; | ||
if (['array', 'object'].includes(type)) { | ||
try { | ||
req.body[key] = JSON.parse(value); | ||
} | ||
catch (e) { | ||
// NOOP | ||
} | ||
} | ||
}); | ||
return null; | ||
} | ||
discriminatorValidator(req, discriminator) { | ||
@@ -124,0 +143,0 @@ if (discriminator) { |
{ | ||
"name": "express-openapi-validator", | ||
"version": "5.0.1", | ||
"version": "5.0.2", | ||
"description": "Automatically validate API requests and responses with OpenAPI 3 and Express.", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
Sorry, the diff of this file is not supported yet
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
350871
0.43%6033
0.33%