express-openapi-validator
Advanced tools
Comparing version 0.2.32-beta to 0.3.33-beta
@@ -7,3 +7,3 @@ var express = require('express'); | ||
var http = require('http'); | ||
var OpenApiMiddleware = require('express-middleware-openapi').OpenApiMiddleware; | ||
var OpenApiValidator = require('express-openapi-validator').OpenApiValidator; | ||
var app = express(); | ||
@@ -18,3 +18,3 @@ | ||
new OpenApiMiddleware({ | ||
new OpenApiValidator({ | ||
apiSpecPath: '../openapi.yaml', | ||
@@ -21,0 +21,0 @@ }).install(app); |
{ | ||
"name": "express-openapi-validator", | ||
"version": "0.2.32-beta", | ||
"version": "0.3.33-beta", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
# express-openapi-validator | ||
![](https://travis-ci.com/cdimascio/express-middleware-openapi.svg?branch=master) ![](https://img.shields.io/npm/v/express-middleware-openapi.svg) [![Coverage Status](https://coveralls.io/repos/github/cdimascio/express-middleware-openapi/badge.svg?branch=master)](https://coveralls.io/github/cdimascio/express-middleware-openapi?branch=master) ![](https://img.shields.io/badge/license-MIT-blue.svg) | ||
![](https://travis-ci.com/cdimascio/express-openapi-validator.svg?branch=master) ![](https://img.shields.io/npm/v/express-openapi-validator.svg) [![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) ![](https://img.shields.io/badge/license-MIT-blue.svg) | ||
ExpressJs middleware that automatically validates API requests using an OpenAPI 3.0 specification, | ||
An OpenApi validator for ExpressJS that automatically validates API requests using an OpenAPI 3.0 specification, | ||
@@ -10,3 +10,3 @@ ## Install | ||
```shell | ||
npm i express-middleware-openapi | ||
npm i express-openapi-validator | ||
``` | ||
@@ -16,6 +16,6 @@ | ||
Register openapi validation middleware | ||
Install the openapi validator | ||
```javascript | ||
new OpenApiMiddleware({ | ||
new OpenApiValidator({ | ||
apiSpecPath: './openapi.yaml', | ||
@@ -49,3 +49,3 @@ }).install(app); | ||
var http = require('http'); | ||
var OpenApiMiddleware = require('express-middleware-openapi').OpenApiMiddleware; | ||
var OpenApiValidator = require('express-openapi-validator').OpenApiValidator; | ||
var app = express(); | ||
@@ -60,3 +60,3 @@ | ||
new OpenApiMiddleware({ | ||
new OpenApiValidator({ | ||
apiSpecPath: './openapi.yaml', | ||
@@ -63,0 +63,0 @@ }).install(app); |
@@ -10,7 +10,7 @@ import * as _ from 'lodash'; | ||
export interface OpenApiMiddlewareOpts { | ||
export interface OpenApiValidatorOpts { | ||
apiSpecPath: string; | ||
} | ||
export function OpenApiMiddleware(options: OpenApiMiddlewareOpts) { | ||
export function OpenApiValidator(options: OpenApiValidatorOpts) { | ||
if (!options.apiSpecPath) throw ono('apiSpecPath required'); | ||
@@ -28,3 +28,3 @@ | ||
OpenApiMiddleware.prototype.install = function(app: ExpressApp) { | ||
OpenApiValidator.prototype.install = function(app: ExpressApp) { | ||
const pathParams = []; | ||
@@ -31,0 +31,0 @@ for (const route of this.context.routes) { |
@@ -7,3 +7,3 @@ var express = require('express'); | ||
const { OpenApiMiddleware } = require('../src'); | ||
const { OpenApiValidator } = require('../src'); | ||
const { startServer, routes } = require('./app.common'); | ||
@@ -20,3 +20,3 @@ | ||
new OpenApiMiddleware({ | ||
new OpenApiValidator({ | ||
apiSpecPath: './openapi.yaml', | ||
@@ -23,0 +23,0 @@ }).install(app); |
const expect = require('chai').expect; | ||
const { OpenApiMiddleware } = require('../src'); | ||
const { OpenApiValidator } = require('../src'); | ||
const packageJson = require('../package.json'); | ||
@@ -7,3 +7,3 @@ | ||
it('should succeed when spec exists and is valid', async () => { | ||
const oam = new OpenApiMiddleware({ | ||
const oam = new OpenApiValidator({ | ||
apiSpecPath: './openapi.yaml', | ||
@@ -20,3 +20,3 @@ enableObjectCoercion: true, // should be default | ||
const createMiddleware = () => | ||
new OpenApiMiddleware({ | ||
new OpenApiValidator({ | ||
apiSpecPath: './not-found.yaml', | ||
@@ -23,0 +23,0 @@ enableObjectCoercion: true, // should be default |
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
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
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
219607
63
2490
3