title: How to use Bearer or Apikey keywords automatically onswagger java
body: <p>I am trying to make some security configurations in my <strong>SwaggerConfiguration</strong> class. My purpose is sending scheme keyword with authentication key like</p>
  <p><code>curl -X GET &quot;http://localhost:8080&quot; -H &quot;accept: */*&quot; -H &quot;Authorization: Bearer &lt;authorization-value&gt;&quot;</code></p>
  <p>or</p>
  <p><code>curl -X GET &quot;http://localhost:8080&quot; -H &quot;accept: */*&quot; -H &quot;Authorization: ApiKey &lt;authorization-value&gt;&quot;</code></p>
  <p>It is possible on <a href="https://codeburst.io/api-security-in-swagger-f2afff82fb8e" rel="nofollow noreferrer">ASP.Core</a> but I can only achive this on java like this:</p>
  <p><a href="https://i.stack.imgur.com/N1zCI.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/N1zCI.png" alt="enter image description here" /></a></p>
  <p>What shall I use for my Docket security scheme instead of <code>ApiKey</code>?</p>
  <pre><code>Docket docket = new Docket(DocumentationType.SWAGGER_2)
                      .select()
                      .apis(RequestHandlerSelectors.basePackage(&quot;mypackagename&quot;))
                      .build()
                      .useDefaultResponseMessages(false)
                      .apiInfo(metaData())
                      .securitySchemes(Collections.singletonList(getApiKey()))
                      .securityContexts(Collections.singletonList(securityContext()));
  
    private ApiKey getApiKey() {
              return new ApiKey(&quot;apiKey&quot;, &quot;Authorization&quot;, &quot;Header&quot;);
          }
  </code></pre>