'Multiple authorization using swagger OpenAPI 3.0 with Express and JSON format

The project has two authorization systems, basic auth and bearer. I need for each request after clicking on the "try it out" and "execute" buttons to attach to the request the Authorization headers, in which there will be a Basic line and a jwt header, in which there will be a bearer token. The problem is that I can attach these headers individually, but not together. There is a feeling that both authorizations want to write to the Authorization header and one of them overwrites the other, even though I explicitly indicated the header names in the schema.

My schemas:

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

and how I use it:

    {
    "/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"
                            }
                        }
                    }
                }
            }
        }
    }
}

I use swagger-ui-express for node.JS and OpenAPI 3.0



Solution 1:[1]

A request can contain only one Authorization header, and the Authorization header can only contain a single set of credentials (i.e. either Basic or Bearer, but not both). Your use case is not supported by the HTTP protocol.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Helen