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

Not able to add middleware to the app #52

Open
akapuya opened this issue Jun 23, 2022 · 2 comments
Open

Not able to add middleware to the app #52

akapuya opened this issue Jun 23, 2022 · 2 comments

Comments

@akapuya
Copy link

akapuya commented Jun 23, 2022

'use strict';

var path = require('path');
var http = require('http');

var oas3Tools = require('oas3-tools');
var serverPort = 8088;

// 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);
var app = expressAppConfig.getApp();
const r = app.use((req, res, next) => {
console.log(req);
next();
});

// Initialize the Swagger middleware
http.createServer(app).listen(serverPort, function () {
console.log('Your server is listening on port %d (http://localhost:%d)', serverPort, serverPort);
console.log('Swagger-ui is available on http://localhost:%d/docs', serverPort);
});

This is the original generated code and an additional middleware for testing. using the routes never goes into the middleware

@leealandennis
Copy link

I'm having the same issue. I wonder if the latest code on the master branch would help since you are able to pass in your app instead of relying on the one returned from getApp. Looks like there's something wrong with the app that gets returned.

@leealandennis
Copy link

Duplicate of #41

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

No branches or pull requests

2 participants