如何更改 Swagger-UI “默认"小路 [英] How to change Swagger-UI "Default" Path

查看:19
本文介绍了如何更改 Swagger-UI “默认"小路的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have tried changing the basePath in my json file, which only seems to change the bottom "baseurl" of swagger-UI. I want to get rid of the "Default" that appears as a group title of my swagger-UI. Has anyone been able to fix this problem? I am using Swagger ~2.0.

推荐答案

Default 不是路径,而是标签.

The Default is not a path, it's a tag.

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

In Swagger 2.0, grouping is done using tags. Each operation can be assigned to zero or more tags. In the UI, any operation that has no tag will end up under the Default group.

"/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",并且该操作将分组在该标题下.

You can see the operations has a tags property with the value of "pet", and that operation would be grouped under that header.

这篇关于如何更改 Swagger-UI “默认"小路的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆