gpt4 book ai didi

swagger - 如何更改 Swagger-UI "Default"路径

转载 作者:行者123 更新时间:2023-12-04 03:00:42 24 4
gpt4 key购买 nike

我曾尝试更改我的 json 文件中的 basePath,这似乎只会更改 swagger-UI 的底部“baseurl”。我想摆脱作为我的 swagger-UI 的组标题出现的“默认”。有没有人能够解决这个问题?我正在使用 Swagger ~2.0。

最佳答案

Default不是路径,而是标签。

在 Swagger 2.0 中,分组是使用标签完成的。每个操作都可以分配给零个或多个标签。在 UI 中,任何没有标签的操作都将在 Default 下结束。团体。

"/pet/findByStatus": {
"get": {
"tags": [
"pet"
],
"summary": "Finds Pets by status",
"description": "Multiple status values can be provided with comma seperated strings",
"operationId": "findPetsByStatus",
"consumes": [
"application/xml",
"application/json",
"multipart/form-data",
"application/x-www-form-urlencoded"
],
"produces": [
"application/xml",
"application/json"
],
"parameters": [
{
"name": "status",
"in": "query",
"description": "Status values that need to be considered for filter",
"required": false,
"type": "array",
"items": {
"type": "string"
},
"collectionFormat": "multi",
"default": "available",
"enum": [
"available",
"pending",
"sold"
]
}
],
"responses": {
"200": {
"description": "successful operation",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/Pet"
}
}
},
"400": {
"description": "Invalid status value"
}
},
"security": [
{
"petstore_auth": [
"write:pets",
"read:pets"
]
}
]
}
}

可以看到操作有 tags值为 "pet" 的属性,并且该操作将分组在该标题下。

关于swagger - 如何更改 Swagger-UI "Default"路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30174624/

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