gpt4 book ai didi

swagger - Swagger 创建部分

转载 作者:行者123 更新时间:2023-12-05 01:19:41 28 4
gpt4 key购买 nike

我正在编写一个 swagger 规范,并且我有三个独立的端点。我如何在文档中将它们分开?我想明确区分示例:用户、帖子和其他。所以每个人都会有一个 CRUD 描述并显示在 swagger UI 中,它看起来像:

USERS
// user specs

POST
// post specs

OTHER
// other specs

最佳答案

您需要使用标签来完成此操作。

因此,在您的“路径”对象上,您对所有路线进行排序,并在每一个路线上添加一个“标签”:[“{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": "...",
}
},
}

这在文档中一点也不明显。实际上文档非常完整,但缺少索引和一些组织。

关于swagger - Swagger 创建部分,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38722718/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com