API key in header with swashbuckle
<p>I want to do API key based authentication on a WebAPI project with Swashbuckle (swagger for .net).</p>

<p>I have configured swashbuckle as below:</p>

<pre><code>config
    .EnableSwagger(c =&gt;
    {
        c.ApiKey("apiKey")
            .Description("API Key Authentication")
            .Name("X-ApiKey")
            .In("header");
        c.SingleApiVersion("v1", "My API");

    })
    .EnableSwaggerUi();
</code></pre>

<p>(see <a href="https://github.com/domaindrivendev/Swashbuckle#describing-securityauthorization-schemes" rel="noreferrer">https://github.com/domaindrivendev/Swashbuckle#describing-securityauthorization-schemes</a>)</p>

<p>It appears to create the swagger file I expect:</p>

<pre>
   "securityDefinitions": {
      "apiKey": {
        "type": "apiKey",
        "description": "API Key Authentication",
        "name": "X-ApiKey",
        "in": "header"
      }
    }
</pre>

<p>But when I go to the UI and 'Try it out' it tries to put the API key into the query string (which I think is the default behavior) instead of the headers.</p>

<p>eg:</p>

<p><code>curl -X POST --header 'Accept: application/json' 'http://localhost:63563/api/MyMethod?api_key=key'</code></p>

<p><strong>How can I get swagger to use put the API key in the header instead of the query string?</strong></p>