Reputation: 511
How to add multiple servers to swagger with swagger-autogen
?
the documentation is providing only one host here
I want to do something like that:
const doc = {
.
.
hosts: ['localhost:3000', 'localhost:5000'],
.
.
};
but when I did it, the base URL became http://localhost:3000localhost:5000/
is there any way to add multiple servers to swagger-autogen
?
Upvotes: 1
Views: 1748
Reputation: 511
yes, there is a way:
const swaggerAutogen = require('swagger-autogen')({openapi: '3.0.0'});
host
, basePath
, and schemes
from object doc
const doc = {
.
.
servers: [
{
url: "http://localhost:3000/",
description: "main server"
},
{
url: "http://localhost:5000/",
description: "the other server"
}
],
.
.
};
it didn't exist in the documentation, but it works since the object doc
is converted into a JSON object inside the file named swagger-output.json
Upvotes: 3