在 NodeJS 中,分组 API 对我来说是不可能的。看到的各种方法并没有像预期的那么简单;因为端点仍然保持默认的 swagger 分组。下面的方法使事情成功了。
对于 NodeJS,预计在您的 swagger.js 或 swagger.ts 文件中, 你有以下内容;
swagger: "2.0",
info: {
title: 'My API',
description: 'My API docs',
},
host: 'localhost:9000/api/v1',
schemes: ['http', 'https'],
tags: [
{
name: 'Patient Management',
description: "Patient Management"
},
{
name: 'Doctor Management',
description: "Doctor Management"
},
...
...
]
}
然后在你的控制器文件中,你应该有以下内容;
const GetDoctorsController = (req:Request, res:Response) => {
// #swagger.tags = ['Doctor Management']
try{
}catch(error){
}
}
运行 api 的脚本并在浏览器上运行链接