title: Adding authorization to Annotation-driven swagger.json with Jersey 2 and Spring Boot
body: <p>I'm trying to add Basic Authentication to Swagger UI for a to a Swagger-annotated Jersey 2.0 web service built with Spring Boot.  I'm using:</p>
  
  <ul>
  <li>Spring Boot 1.5.4 </li>
  <li>spring-boot-starter-jersey </li>
  <li>Swagger UI 3.0.4 </li>
  <li>(Maven package) swagger-jersey2-jaxrs 1.5.13</li>
  </ul>
  
  <p>I'm able to generate a swagger.json file with the following JerseyConfig and with Swagger annotations on my Resources.  <a href="http://tech.asimio.net/2016/04/05/Microservices-using-Spring-Boot-Jersey-Swagger-and-Docker.html" rel="noreferrer">This article was immensely helpful in getting this far</a>.</p>
  
  <pre><code>@Component
  public class JerseyConfiguration extends ResourceConfig {
    private static Log logger = LogFactory.getLog(JerseyConfiguration.class);
  
    @Value("${spring.jersey.application-path:/}")
    private String apiPath;
  
    public JerseyConfiguration() {
      registerEndpoints();
      configureSwagger();
    }
  
    private void registerEndpoints() {
      register(MyEndpoints.class);
  
      // Generate Jersey WADL at /&lt;Jersey's servlet path&gt;/application.wadl
      register(WadlResource.class);
  
      // Lets us get to static content like swagger
      property(ServletProperties.FILTER_STATIC_CONTENT_REGEX, "((/swagger/.*)|(.*\\.html))");
     }
  
  
    /**
     * Configure the Swagger documentation for this API.
     */
    private void configureSwagger() {
      // Creates file at localhost:port/swagger.json
      this.register(ApiListingResource.class);
      this.register(SwaggerSerializers.class);
  
  
      BeanConfig config = new BeanConfig();
      config.setConfigId("example-jersey-app");
      config.setTitle("Spring Boot + Jersey + Swagger");
      config.setVersion("2");
      config.setContact("Me &lt;me@example.com&gt;");
      config.setSchemes(new String[] {"http", "https"});
      config.setResourcePackage("com.example.api");
      config.setBasePath(this.apiPath);
      config.setPrettyPrint(true);
      config.setScan(true);
    }
  }
  </code></pre>
  
  <p>Now I want to be able to use Basic Authentication to connect to these services from Swagger UI.  I've configured it in Spring and can use it to authenticate to the site, but not from Swagger UI. 
   Unfortunately, none of the Spring Boot <a href="https://github.com/swagger-api/swagger-samples/tree/master/java" rel="noreferrer">examples currently on the Swagger sample site</a> include Jersey and authentication, and none of the Jersey examples use Spring Boot and <code>@SpringBootApplication</code> like I'm using on in my project.</p>
  
  <p>How do I get Basic Auth to show up in the Swagger UI?</p>