How to use swagger-ui-express.serve and setup swagger document inside call back function Nodejs
up vote
2
down vote
favorite
const swaggerUi = require('swagger-ui-express');
const swaggerDocument = require('./swagger.json');
app.use('/swagger', swaggerUi.serve, swaggerUi.setup(swaggerDocument));
instead of this, i want to use inside callback function of NodeJS
Need to set basepath dynamically inside callback function.
app.use('/swagger', function(req,res) {
swaggerDocument.basepath = "/pet/details",
res.send(swaggerUi.serve, swaggerUi.setup(swaggerDocument));
});
Please help me to resolve this..
swagger swagger-ui swagger-node
add a comment |
up vote
2
down vote
favorite
const swaggerUi = require('swagger-ui-express');
const swaggerDocument = require('./swagger.json');
app.use('/swagger', swaggerUi.serve, swaggerUi.setup(swaggerDocument));
instead of this, i want to use inside callback function of NodeJS
Need to set basepath dynamically inside callback function.
app.use('/swagger', function(req,res) {
swaggerDocument.basepath = "/pet/details",
res.send(swaggerUi.serve, swaggerUi.setup(swaggerDocument));
});
Please help me to resolve this..
swagger swagger-ui swagger-node
add a comment |
up vote
2
down vote
favorite
up vote
2
down vote
favorite
const swaggerUi = require('swagger-ui-express');
const swaggerDocument = require('./swagger.json');
app.use('/swagger', swaggerUi.serve, swaggerUi.setup(swaggerDocument));
instead of this, i want to use inside callback function of NodeJS
Need to set basepath dynamically inside callback function.
app.use('/swagger', function(req,res) {
swaggerDocument.basepath = "/pet/details",
res.send(swaggerUi.serve, swaggerUi.setup(swaggerDocument));
});
Please help me to resolve this..
swagger swagger-ui swagger-node
const swaggerUi = require('swagger-ui-express');
const swaggerDocument = require('./swagger.json');
app.use('/swagger', swaggerUi.serve, swaggerUi.setup(swaggerDocument));
instead of this, i want to use inside callback function of NodeJS
Need to set basepath dynamically inside callback function.
app.use('/swagger', function(req,res) {
swaggerDocument.basepath = "/pet/details",
res.send(swaggerUi.serve, swaggerUi.setup(swaggerDocument));
});
Please help me to resolve this..
swagger swagger-ui swagger-node
swagger swagger-ui swagger-node
edited Nov 21 at 10:03
asked Nov 14 at 13:21
Harry Lausen
216
216
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
1
down vote
accepted
Found the solution,
Used callback function like this,
router.use(
swaggerUi.serve,
function(req, res) {
swaggerDocument.host = req.get('host'); // Replace hardcoded host information in swagger file
swaggerDocument.schemes = [req.protocol]; // Replace hardcoded protocol information in Swagger file
swaggerUi.setup(swaggerDocument)(req, res);
}
});
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
accepted
Found the solution,
Used callback function like this,
router.use(
swaggerUi.serve,
function(req, res) {
swaggerDocument.host = req.get('host'); // Replace hardcoded host information in swagger file
swaggerDocument.schemes = [req.protocol]; // Replace hardcoded protocol information in Swagger file
swaggerUi.setup(swaggerDocument)(req, res);
}
});
add a comment |
up vote
1
down vote
accepted
Found the solution,
Used callback function like this,
router.use(
swaggerUi.serve,
function(req, res) {
swaggerDocument.host = req.get('host'); // Replace hardcoded host information in swagger file
swaggerDocument.schemes = [req.protocol]; // Replace hardcoded protocol information in Swagger file
swaggerUi.setup(swaggerDocument)(req, res);
}
});
add a comment |
up vote
1
down vote
accepted
up vote
1
down vote
accepted
Found the solution,
Used callback function like this,
router.use(
swaggerUi.serve,
function(req, res) {
swaggerDocument.host = req.get('host'); // Replace hardcoded host information in swagger file
swaggerDocument.schemes = [req.protocol]; // Replace hardcoded protocol information in Swagger file
swaggerUi.setup(swaggerDocument)(req, res);
}
});
Found the solution,
Used callback function like this,
router.use(
swaggerUi.serve,
function(req, res) {
swaggerDocument.host = req.get('host'); // Replace hardcoded host information in swagger file
swaggerDocument.schemes = [req.protocol]; // Replace hardcoded protocol information in Swagger file
swaggerUi.setup(swaggerDocument)(req, res);
}
});
answered Nov 21 at 10:02
Harry Lausen
216
216
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53301234%2fhow-to-use-swagger-ui-express-serve-and-setup-swagger-document-inside-call-back%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown