Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request entity too large error #53

Open
susi-jey opened this issue Jul 6, 2022 · 0 comments · Fixed by paxet-io/oas3-tools#2
Open

Request entity too large error #53

susi-jey opened this issue Jul 6, 2022 · 0 comments · Fixed by paxet-io/oas3-tools#2

Comments

@susi-jey
Copy link

susi-jey commented Jul 6, 2022

[request entity too large error when using oas3-tools package,openapi 3.0 in node.js]

index.js file

'use strict';

var path = require('path');
var http = require('http');
var cors = require('cors');
var oas3Tools = require('oas3-tools');

require("dotenv").config({ path: ".env" });
console.log(`### Running on ~~~ ${process.env.Instance} ~~~ ENV ###`);

var serverPort = 8080;

function validate(request, scopes, schema) {
    // security stuff here
    return true;
}

// swaggerRouter configuration
var options = {
    routing: {
        controllers: path.join(__dirname, './controllers')
    },
    logging: {
        format: 'combined',
        errorLimit: 400
    },
}; 


var expressAppConfig = oas3Tools.expressAppConfig(
    path.join(__dirname, "./api/openapi.yaml"),
    options
  );
  expressAppConfig.addValidator();
  var app = expressAppConfig.getApp();

  app.use(cors());
  var json2xls = require('json2xls');
  app.use(json2xls.middleware);

// Initialize the Swagger middleware
http.createServer(app).listen(serverPort, function () {

});


// Connect to database 
var mongo = require("./utils/db");

----------------------------------------EOF----------------------------------------------

PFB the version of the tools which we've used. "express": "^4.17.1", "oas3-tools": "2.1.3"

I've tried body-parser and app.use(express.json({limit:'25mb'})). But nothing resolved the request entity too large error. It would be great if anyone suggest me any different solution.

MartinSunal added a commit to paxet-io/oas3-tools that referenced this issue Aug 16, 2022
- removed body-parser and use express middlewares instead
- removed duplicit middlewares
- set limit to 50mb for middlewares

Fixes bug-hunters#53

Signed-off-by: Martin Sunal <[email protected]>
MartinSunal added a commit to paxet-io/oas3-tools that referenced this issue Aug 16, 2022
- removed body-parser and use express middlewares instead
- removed duplicit middlewares
- set limit to 50mb for middlewares

Fixes bug-hunters#53

Signed-off-by: Martin Sunal <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant