title: C#: Swagger/Swashbuckle - Connect security schemes with "AND"
body: <p>I have an ASP.NET Core Api where it is required to use multiple authentication schemes for one operation. I am trying to document those operations with displaying all required authentication schemes in Swagger UI.
  Therefore I use the <strong>Swashbuckle.AspNetCore (5.1.0)</strong> library for a dynamic adding of <code>OpenApiSecurityRequirement</code> to the <code>OpenApiOperation</code> in an <code>IOperationFilter</code>:</p>
  
  <pre><code>if (authorizeAttributes.Any(x =&gt; x.AuthenticationSchemes.Contains(InternalControllerBasicAuthentication.AuthenticationScheme)))
  {
         requirements.Add(new OpenApiSecurityRequirement
         {
               {
                     new OpenApiSecurityScheme {
                          Reference = new OpenApiReference {
                              Type = ReferenceType.SecurityScheme,
                              Id = "credentials"
                          }
                     },
                     new [] { "Basic &lt;credentials-value&gt;" }
               }
        });
  } 
  
  if (authorizeAttributes.Any(x =&gt; x.AuthenticationSchemes.Contains(OneTimePasswordAuthentication.AuthenticationScheme)))
  {
        requirements.Add(new OpenApiSecurityRequirement
        {
               {
                     new OpenApiSecurityScheme {
                          Reference = new OpenApiReference {
                              Type = ReferenceType.SecurityScheme,
                              Id = "one-time-password"
                          }
                     },
                     new [] { "Basic &lt;one-time-password-value&gt;" }
               }
        });
  }
  
  operation.Security = new List&lt;OpenApiSecurityRequirement&gt;(requirements);
  </code></pre>
  
  <p>Furthemore I use the <code>SwaggerGenOptions</code> to register all possible schemes:</p>
  
  <pre><code>var oneTimePasswordScheme = new OpenApiSecurityScheme
  {
      Name = "one-time-password",
      In = ParameterLocation.Header,
      Scheme = "one-time-password",
      Type = SecuritySchemeType.ApiKey
  };
  
  options.AddSecurityDefinition("one-time-password", oneTimePasswordScheme);
  
  var credentialsScheme = new OpenApiSecurityScheme
  {
      Name = "credentials",
      In = ParameterLocation.Header,
      Scheme = "credentials",
      Type = SecuritySchemeType.ApiKey
  };
  
  options.AddSecurityDefinition("credentials", credentialsScheme);
  </code></pre>
  
  <p>Everything works fine except for Swagger using the <code>OR</code> connector in the UI:</p>
  
  <p><a href="https://i.stack.imgur.com/JIOjc.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/JIOjc.png" alt="enter image description here"></a></p>
  
  <p>Is there a way to configure Swagger using the <code>AND</code> connector?</p>
  
  <p>Any help will be highly appreciated!</p>