Multiple headers required in Swashbuckle for OpenAPI authentication

Viewed 237

I have an API that requires two headers, a "user ID" and a "secret". I am failing to find a way to get them listed in the OpenAPI output as both needed, they are shown as separate options for authorization. OpenAPI says it can do this for Multiple API Keys (leave out a dash) but I cannot find a way to specify that the two are related in code. Is this possible in Swashbuckle? (Am using .Net Core 3.1)

          options.AddSecurityDefinition("appkey", new OpenApiSecurityScheme
            {
                Description = "Unique application key (user ID)",
                In = ParameterLocation.Header,
                Name = CustomAuthenticationOptions.ApplicationKeyHeaderName,
                Type = SecuritySchemeType.ApiKey
            });
            options.AddSecurityDefinition("secret", new OpenApiSecurityScheme
            {
                Description = "Secret key (password)",
                In = ParameterLocation.Header,
                Name = CustomAuthenticationOptions.SecretKeyHeaderName,
                Type = SecuritySchemeType.ApiKey,
            });
0 Answers
Related