如何将多个服务器添加到使用swagger-autogen的swagger
文档只提供一个主机这里。
我想做这样的事:
const doc = {
.
.
hosts: ['localhost:3000', 'localhost:5000'],
.
.
};但是当我这么做的时候,基本的网址变成了http://localhost:3000localhost:5000/
有没有办法向swagger-autogen中添加多个服务器?
发布于 2022-11-21 16:21:07
是的,有一种方法:
const swaggerAutogen = require('swagger-autogen')({openapi: '3.0.0'});host、basePath和schemes从对象doc中删除const doc = {
.
.
servers: [
{
url: "http://localhost:3000/",
description: "main server"
},
{
url: "http://localhost:5000/",
description: "the other server"
}
],
.
.
};文档中不存在它,但是它可以工作,因为对象doc被转换为名为swagger-output.json的文件中的JSON对象
https://stackoverflow.com/questions/74521883
复制相似问题