使用带有 Express 和 JSON 格式的 swagger OpenAPI 3.0 的多重授权

Multiple authorization using swagger OpenAPI 3.0 with Express and JSON format

项目有两个授权系统,basic auth和bearer。单击“试用”和“执行”按钮后,我需要为每个请求附加授权 headers,其中将有一个基本行和一个 jwt header,其中将有一个不记名令牌。问题是我可以单独附加这些 header,但不能附加在一起。感觉两个授权都想写入 Authorization header 并且其中一个覆盖了另一个,即使我在架构中明确指出了 header 名称。

我的架构:

    {
    "securitySchemes": {
        "Bearer": {
            "in": "header",
            "name": "jwt",
            "type": "http",
            "scheme": "bearer"
          
        },
        "basicAuth": {
            "type": "http",
            "scheme": "basic"
        }
      }
   }

以及我如何使用它:

    {
    "/channel/base-list": {
        "get": {
            "tags": [
                "CMS Channel"
            ],
            "security": [
                {
                    "Bearer": [],
                    "basicAuth": []
                }
            ],
            "summary": "Get _id and title of all channels",
            "produces": [
                "application/json"
            ],
            "parameters": [
                {
                    "in": "query",
                    "name": "count",
                    "required": false,
                    "schema": {
                        "type": "Integer"
                    },
                    "default": 25,
                    "example": 10
                },
                {
                    "in": "query",
                    "name": "search",
                    "required": false,
                    "schema": {
                        "type": "String"
                    },
                    "description": "Channel name"
                }
            ],
            "responses": {
                "200": {
                    "description": "A list of channels",
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/definitions/get-channel-base-list"
                            }
                        }
                    }
                }
            }
        }
    }
}

我将 swagger-ui-express 用于 node.JS 和 OpenAPI 3.0

一个请求可以包含 only one Authorization header, and the Authorization header can only contain a single set of credentials(即 Basic 或 Bearer,但不能同时包含两者)。 HTTP 协议不支持您的用例。