我正在编写一个swagger规范,我有三个独立的端点。如何在文档中分隔它们?我希望明确区分示例:用户,帖子和广告;其他。因此,每个人都会有一个CRUD描述,并在swagger UI中显示它看起来像:
USERS
// user specs
POST
// post specs
OTHER
// other specs
答案 0 :(得分:6)
您需要使用标签来完成此任务。
因此,在您的“路径”对象上,您对所有路线进行排序,并在每个路线上添加“标签”:[“{resource}”],应将其分组。
例如:
"paths": {
"/users": {
"get": {
"tags": ["User"],
"description": "...",
},
"post": {
"tags": ["User"],
"description": "...",
}
},
"/posts": {
"get": {
"tags": ["Post"],
"description": "...",
},
"post": {
"tags": ["Post"],
"description": "...",
}
},
"/other": {
"get": {
"tags": ["Other"],
"description": "...",
},
"post": {
"tags": ["Other"],
"description": "...",
}
},
}
这在文档中根本不明显。实际上,文档非常完整,但缺少索引和一些组织。