express-openapi-validator
Advanced tools
Comparing version 5.1.6 to 5.2.0
@@ -38,1 +38,2 @@ "use strict"; | ||
}; | ||
//# sourceMappingURL=formats.js.map |
@@ -209,1 +209,2 @@ "use strict"; | ||
} | ||
//# sourceMappingURL=index.js.map |
@@ -59,1 +59,2 @@ "use strict"; | ||
exports.AjvOptions = AjvOptions; | ||
//# sourceMappingURL=options.js.map |
@@ -113,1 +113,2 @@ "use strict"; | ||
} | ||
//# sourceMappingURL=base.path.js.map |
@@ -27,1 +27,2 @@ "use strict"; | ||
]; | ||
//# sourceMappingURL=base.serdes.js.map |
@@ -94,1 +94,2 @@ "use strict"; | ||
exports.OpenAPIFramework = OpenAPIFramework; | ||
//# sourceMappingURL=index.js.map |
@@ -188,1 +188,2 @@ /* istanbul ignore file */ | ||
exports.default = mung; | ||
//# sourceMappingURL=modded.express.mung.js.map |
@@ -68,1 +68,2 @@ "use strict"; | ||
exports.OpenApiContext = OpenApiContext; | ||
//# sourceMappingURL=openapi.context.js.map |
@@ -43,1 +43,2 @@ "use strict"; | ||
exports.OpenAPISchemaValidator = OpenAPISchemaValidator; | ||
//# sourceMappingURL=openapi.schema.validator.js.map |
@@ -89,1 +89,2 @@ "use strict"; | ||
exports.OpenApiSpecLoader = OpenApiSpecLoader; | ||
//# sourceMappingURL=openapi.spec.loader.js.map |
import * as ajv from 'ajv'; | ||
import * as multer from 'multer'; | ||
import { FormatsPluginOptions } from 'ajv-formats'; | ||
import { Request, Response, NextFunction } from 'express'; | ||
import { Request, Response, NextFunction, RequestHandler } from 'express'; | ||
import { RouteMetadata } from './openapi.spec.loader'; | ||
export { OpenAPIFrameworkArgs }; | ||
@@ -48,3 +49,3 @@ export declare type BodySchema = OpenAPIV3.ReferenceObject | OpenAPIV3.SchemaObject | {}; | ||
basePath: string; | ||
resolver: Function; | ||
resolver: (handlersPath: string, route: RouteMetadata, apiDoc: OpenAPIV3.Document) => RequestHandler | Promise<RequestHandler>; | ||
}; | ||
@@ -76,4 +77,13 @@ export declare type Format = { | ||
}; | ||
declare type Primitive = undefined | null | boolean | string | number | Function; | ||
declare type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : T extends Map<infer K, infer V> ? DeepImmutableMap<K, V> : DeepImmutableObject<T>; | ||
interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> { | ||
} | ||
interface DeepImmutableMap<K, V> extends ReadonlyMap<DeepImmutable<K>, DeepImmutable<V>> { | ||
} | ||
declare type DeepImmutableObject<T> = { | ||
readonly [K in keyof T]: DeepImmutable<T[K]>; | ||
}; | ||
export interface OpenApiValidatorOpts { | ||
apiSpec: OpenAPIV3.Document | string; | ||
apiSpec: DeepImmutable<OpenAPIV3.Document> | string; | ||
validateApiSpec?: boolean; | ||
@@ -80,0 +90,0 @@ validateResponses?: boolean | ValidateResponseOpts; |
@@ -163,1 +163,2 @@ "use strict"; | ||
exports.Forbidden = Forbidden; | ||
//# sourceMappingURL=types.js.map |
@@ -33,1 +33,2 @@ "use strict"; | ||
} | ||
//# sourceMappingURL=index.js.map |
@@ -14,1 +14,2 @@ "use strict"; | ||
Object.defineProperty(exports, "security", { enumerable: true, get: function () { return openapi_security_1.security; } }); | ||
//# sourceMappingURL=index.js.map |
@@ -103,1 +103,2 @@ "use strict"; | ||
exports.applyOpenApiMetadata = applyOpenApiMetadata; | ||
//# sourceMappingURL=openapi.metadata.js.map |
@@ -139,1 +139,2 @@ "use strict"; | ||
} | ||
//# sourceMappingURL=openapi.multipart.js.map |
@@ -21,3 +21,7 @@ "use strict"; | ||
options.allowUnknownQueryParameters; | ||
this.ajv = (0, ajv_1.createRequestAjv)(apiDoc, Object.assign(Object.assign({}, options), { coerceTypes: true })); | ||
this.ajv = (0, ajv_1.createRequestAjv)(apiDoc, | ||
// This should always be true as it handles query params (everything, but the body) | ||
// This should always be coerced. Note that coerceTypes = 'array` also operates as true | ||
// but also coerces 'array' types | ||
!options.coerceTypes ? Object.assign(Object.assign({}, options), { coerceTypes: true }) : options); | ||
this.ajvBody = (0, ajv_1.createRequestAjv)(apiDoc, options); | ||
@@ -129,2 +133,5 @@ } | ||
multipartNested(req, schemaBody) { | ||
if (!req.body) { | ||
return; | ||
} | ||
Object.keys(req.body).forEach((key) => { | ||
@@ -265,1 +272,2 @@ var _a, _b, _c, _d; | ||
} | ||
//# sourceMappingURL=openapi.request.validator.js.map |
@@ -256,1 +256,2 @@ "use strict"; | ||
exports.ResponseValidator = ResponseValidator; | ||
//# sourceMappingURL=openapi.response.validator.js.map |
@@ -237,1 +237,2 @@ "use strict"; | ||
} | ||
//# sourceMappingURL=openapi.security.js.map |
@@ -73,1 +73,2 @@ "use strict"; | ||
exports.BodySchemaParser = BodySchemaParser; | ||
//# sourceMappingURL=body.parse.js.map |
@@ -286,1 +286,2 @@ "use strict"; | ||
exports.RequestParameterMutator = RequestParameterMutator; | ||
//# sourceMappingURL=req.parameter.mutator.js.map |
@@ -74,1 +74,2 @@ "use strict"; | ||
exports.ParametersSchemaParser = ParametersSchemaParser; | ||
//# sourceMappingURL=schema.parse.js.map |
@@ -509,1 +509,2 @@ "use strict"; | ||
exports.SchemaPreprocessor = SchemaPreprocessor; | ||
//# sourceMappingURL=schema.preprocessor.js.map |
@@ -86,1 +86,2 @@ "use strict"; | ||
} | ||
//# sourceMappingURL=util.js.map |
@@ -160,1 +160,2 @@ "use strict"; | ||
exports.zipObject = zipObject; | ||
//# sourceMappingURL=util.js.map |
@@ -18,3 +18,3 @@ import { Application, Router } from 'express'; | ||
private responseValidationMiddleware; | ||
installOperationHandlers(baseUrl: string, context: OpenApiContext): Router; | ||
installOperationHandlers(baseUrl: string, context: OpenApiContext): Promise<Router>; | ||
private validateOptions; | ||
@@ -21,0 +21,0 @@ private normalizeOptions; |
@@ -189,4 +189,4 @@ "use strict"; | ||
return pContext | ||
.then(({ context }) => (router = self.installOperationHandlers(req.baseUrl, context))) | ||
.then((router) => router(req, res, next)) | ||
.then(({ context }) => self.installOperationHandlers(req.baseUrl, context)) | ||
.then((installedRouter) => (router = installedRouter)(req, res, next)) | ||
.catch(next); | ||
@@ -241,3 +241,3 @@ }); | ||
} | ||
installOperationHandlers(baseUrl, context) { | ||
async installOperationHandlers(baseUrl, context) { | ||
const router = express.Router({ mergeParams: true }); | ||
@@ -258,3 +258,4 @@ this.installPathParams(router, context); | ||
: expressRoute; | ||
router[method.toLowerCase()](path, resolver(basePath, route, context.apiDoc)); | ||
const handler = await resolver(basePath, route, context.apiDoc); | ||
router[method.toLowerCase()](path, handler); | ||
} | ||
@@ -354,1 +355,2 @@ } | ||
exports.OpenApiValidator = OpenApiValidator; | ||
//# sourceMappingURL=openapi.validator.js.map |
@@ -48,1 +48,2 @@ "use strict"; | ||
exports.modulePathResolver = modulePathResolver; | ||
//# sourceMappingURL=resolvers.js.map |
{ | ||
"name": "express-openapi-validator", | ||
"version": "5.1.6", | ||
"version": "5.2.0", | ||
"description": "Automatically validate API requests and responses with OpenAPI 3 and Express.", | ||
@@ -36,5 +36,5 @@ "main": "dist/index.js", | ||
"dependencies": { | ||
"@apidevtools/json-schema-ref-parser": "^9.1.2", | ||
"@types/multer": "^1.4.7", | ||
"ajv": "^8.11.2", | ||
"@apidevtools/json-schema-ref-parser": "^11.6.2", | ||
"@types/multer": "^1.4.11", | ||
"ajv": "^8.14.0", | ||
"ajv-draft-04": "^1.0.0", | ||
@@ -49,3 +49,3 @@ "ajv-formats": "^2.1.1", | ||
"ono": "^7.1.3", | ||
"path-to-regexp": "^6.2.0" | ||
"path-to-regexp": "^6.2.2" | ||
}, | ||
@@ -64,3 +64,3 @@ "devDependencies": { | ||
"coveralls": "^3.1.1", | ||
"express": "^4.17.3", | ||
"express": "^4.19.2", | ||
"mocha": "^9.2.2", | ||
@@ -76,3 +76,6 @@ "morgan": "^1.10.0", | ||
"typescript": "^4.6.2" | ||
}, | ||
"peerDependencies": { | ||
"express": "*" | ||
} | ||
} |
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
365652
85
6225
14
+ Added@apidevtools/json-schema-ref-parser@11.7.2(transitive)
+ Addedaccepts@2.0.0(transitive)
+ Addedarray-flatten@3.0.0(transitive)
+ Addedbody-parser@2.0.2(transitive)
+ Addedbytes@3.1.2(transitive)
+ Addedcall-bind@1.0.7(transitive)
+ Addedcontent-disposition@1.0.0(transitive)
+ Addedcookie@0.7.1(transitive)
+ Addedcookie-signature@1.2.2(transitive)
+ Addeddebug@2.6.93.1.04.3.6(transitive)
+ Addeddefine-data-property@1.1.4(transitive)
+ Addeddepd@2.0.0(transitive)
+ Addeddestroy@1.2.0(transitive)
+ Addedee-first@1.1.1(transitive)
+ Addedencodeurl@1.0.22.0.0(transitive)
+ Addedes-define-property@1.0.0(transitive)
+ Addedes-errors@1.3.0(transitive)
+ Addedescape-html@1.0.3(transitive)
+ Addedetag@1.8.1(transitive)
+ Addedexpress@5.0.1(transitive)
+ Addedfinalhandler@2.0.0(transitive)
+ Addedforwarded@0.2.0(transitive)
+ Addedfresh@0.5.22.0.0(transitive)
+ Addedfunction-bind@1.1.2(transitive)
+ Addedget-intrinsic@1.2.4(transitive)
+ Addedgopd@1.0.1(transitive)
+ Addedhas-property-descriptors@1.0.2(transitive)
+ Addedhas-proto@1.0.3(transitive)
+ Addedhas-symbols@1.0.3(transitive)
+ Addedhasown@2.0.2(transitive)
+ Addedhttp-errors@2.0.0(transitive)
+ Addediconv-lite@0.5.20.6.3(transitive)
+ Addedipaddr.js@1.9.1(transitive)
+ Addedis-promise@4.0.0(transitive)
+ Addedmerge-descriptors@2.0.0(transitive)
+ Addedmethods@1.1.2(transitive)
+ Addedmime-db@1.53.0(transitive)
+ Addedmime-types@3.0.0(transitive)
+ Addedms@2.0.02.1.22.1.3(transitive)
+ Addednegotiator@1.0.0(transitive)
+ Addedobject-inspect@1.13.3(transitive)
+ Addedon-finished@2.4.1(transitive)
+ Addedonce@1.4.0(transitive)
+ Addedparseurl@1.3.3(transitive)
+ Addedpath-to-regexp@8.2.0(transitive)
+ Addedproxy-addr@2.0.7(transitive)
+ Addedqs@6.13.0(transitive)
+ Addedrange-parser@1.2.1(transitive)
+ Addedraw-body@3.0.0(transitive)
+ Addedrouter@2.0.0(transitive)
+ Addedsafe-buffer@5.2.1(transitive)
+ Addedsafer-buffer@2.1.2(transitive)
+ Addedsend@1.1.0(transitive)
+ Addedserve-static@2.1.0(transitive)
+ Addedset-function-length@1.2.2(transitive)
+ Addedsetprototypeof@1.2.0(transitive)
+ Addedside-channel@1.0.6(transitive)
+ Addedstatuses@2.0.1(transitive)
+ Addedtoidentifier@1.0.1(transitive)
+ Addedtype-is@2.0.0(transitive)
+ Addedunpipe@1.0.0(transitive)
+ Addedutils-merge@1.0.1(transitive)
+ Addedvary@1.1.2(transitive)
+ Addedwrappy@1.0.2(transitive)
- Removed@apidevtools/json-schema-ref-parser@9.1.2(transitive)
- Removedcall-me-maybe@1.0.2(transitive)
Updated@types/multer@^1.4.11
Updatedajv@^8.14.0
Updatedpath-to-regexp@^6.2.2