express-openapi-validator
Advanced tools
Comparing version 5.0.1 to 5.0.2
@@ -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
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
350871
6033