Skip to content

Commit

Permalink
Merge pull request #5 from natura-cosmeticos/ndp1456
Browse files Browse the repository at this point in the history
NDP-1456
  • Loading branch information
marcelofabricanti authored Feb 9, 2024
2 parents 557204e + 17f967e commit 728471c
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 21 deletions.
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
](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)
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
31 changes: 14 additions & 17 deletions src/middleware/express.app.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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);
Expand Down Expand Up @@ -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); };
}
}
Expand Down

0 comments on commit 728471c

Please sign in to comment.