diff --git a/README.md b/README.md index 4f4e3738e..64ca42827 100644 --- a/README.md +++ b/README.md @@ -3,10 +3,13 @@ This is a forked project from https://github.com/apigee-127/swagger-tools with a ## Warning This package was generated due to slowness of PR merging in original repo [bug-hunters/oas3-tools](https://github.com/bug-hunters/oas3-tools). -We needed the custom-middlewares feature so we've forked temporary. +We needed some extra features so we've forked temporarly. -We do not encourage using this package, cause once the original library merges this feature, we'll exclude the duplicate package here. +We do not encourage using this package, cause it can be deleted overnight. ## Features included in this package (since fork) * [feat(custom-middleware): added support of custom middlewares binding #47 -](https://github.com/bug-hunters/oas3-tools/pull/47) \ No newline at end of file +](https://github.com/bug-hunters/oas3-tools/pull/47) + +* [feat(entity-too-large): Fixed request entity too large #2 +](https://github.com/paxet-io/oas3-tools/pull/2) \ No newline at end of file diff --git a/package.json b/package.json index f98995406..4ee223765 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,6 @@ ], "dependencies": { "async": "^2.6.3", - "body-parser": "1.19.0", "cookie-parser": "^1.4.4", "cors": "^2.8.5", "debug": "^4.1.1", diff --git a/src/middleware/express.app.config.ts b/src/middleware/express.app.config.ts index 0115e7a55..d1705a730 100644 --- a/src/middleware/express.app.config.ts +++ b/src/middleware/express.app.config.ts @@ -2,7 +2,6 @@ import * as express from 'express'; import cookieParser = require('cookie-parser'); -import bodyParser = require('body-parser'); import cors = require('cors'); import { SwaggerUI } from './swagger.ui'; import { SwaggerRouter } from './swagger.router'; @@ -25,22 +24,20 @@ export class ExpressAppConfig { this.routingOptions = appOptions.routing; this.setOpenApiValidatorOptions(definitionPath, appOptions); - // Create new express app only if not passed by options + // Create new express app only if not passed by options this.app = appOptions.app || express(); - this.app.use(cors(appOptions.cors)); - + this.app.use(cors(appOptions.cors)); + const spec = fs.readFileSync(definitionPath, 'utf8'); const swaggerDoc = jsyaml.safeLoad(spec); - this.app.use(bodyParser.urlencoded()); - this.app.use(bodyParser.text()); - this.app.use(bodyParser.json()); - this.app.use(bodyParser.raw({ type: 'application/pdf' })); + this.app.use(express.urlencoded({ limit: '50mb', extended: true })); + this.app.use(express.text({ limit: '50mb' })); + this.app.use(express.json({ limit: '50mb' })); + this.app.use(express.raw({ limit: '50mb', type: 'application/pdf' })); this.app.use(this.configureLogger(appOptions.logging)); - this.app.use(express.json()); - this.app.use(express.urlencoded({ extended: false })); this.app.use(cookieParser()); const swaggerUi = new SwaggerUI(swaggerDoc, appOptions.swaggerUI); @@ -71,16 +68,16 @@ export class ExpressAppConfig { public configureLogger(loggerOptions) { let format = 'dev'; - let options:{} = {}; + let options: {} = {}; if (loggerOptions != undefined) { - if(loggerOptions.format != undefined - && typeof loggerOptions.format === 'string'){ - format = loggerOptions.format; + if (loggerOptions.format != undefined + && typeof loggerOptions.format === 'string') { + format = loggerOptions.format; } - - if(loggerOptions.errorLimit != undefined - && (typeof loggerOptions.errorLimit === 'string' || typeof loggerOptions.errorLimit === 'number')){ + + if (loggerOptions.errorLimit != undefined + && (typeof loggerOptions.errorLimit === 'string' || typeof loggerOptions.errorLimit === 'number')) { options['skip'] = function (req, res) { return res.statusCode < parseInt(loggerOptions.errorLimit); }; } }