How to extract out BodyParser from Express and put into Swagger

Viewed 56

I'm using Express with Swagger-Express-MW , where Express is the external entity that manages all the HTTP requests and Swagger is the internal.

One of the modules that express uses is BodyParser :

const bodyParser = require('body-parser');
const SwaggerExpress = require('swagger-express-mw');

...
...
...

function createSwagger(.......) {


    ...
    ...
    ...
    const app = express();
    app.use(bodyParser.raw({
            ...
            ...
            ...
        }));
    app.use((err, req, res, next) => {
    if (err) {
        return next(new Error(err.message));      
    } else {
        next();
    }
    });



   ... more app.uses
}

I'm trying to take as much of responsibility out of Express and put it inside Swagger and its default.yaml , how can we do that ?

0 Answers
Related