title: Applying ApiOperation's to all or subset of controllers
body: <p>I have generated a JHipster application without a frontend, thus I wanted to congfigure swagger ui on the server side.</p>
  <p>I ended up having to define a Docket and WebMvcEndpointHandlerMapping bean which seem to do the trick.</p>
  <p>In the swagger UI, in order to have the bearer token (added in the ‘Authorize’ dialog) automatically appended as a request header to api calls I had to however add an annotation to the method in my rest controller</p>
  <pre><code>@ApiOperation(value = “…” , authorizations = {@Authorization(value = &quot;Bearer&quot;)})
  @GetMapping(&quot;/account&quot;)
  public AdminUserDTO getAccount() {
  ...
  </code></pre>
  <p>I just wondered if there was any easy way to apply this at a class or package level in one fell swoop ?</p>
  <p>Here is my SpringFox config fwiw</p>
  <pre><code>@Configuration
  public class SpringFoxConfig {
  
      @Value(&quot;${spring.application.name}&quot;)
      private String applicationName;
  
  
      @Bean
      public Docket api() {
          return new Docket(DocumentationType.SWAGGER_2)
              .select()
              .apis(RequestHandlerSelectors.withClassAnnotation(RestController.class))
              .paths(PathSelectors.any())
              .build()
              .securitySchemes(Arrays.asList(
                  new ApiKey(&quot;Bearer&quot;, HttpHeaders.AUTHORIZATION, In.HEADER.name())))
              .apiInfo(new ApiInfo(applicationName, &quot;TODO&quot;, &quot;1.0&quot;, &quot;&quot;,
                  new Contact(&quot;..., &quot;&quot;, null), &quot;&quot;, &quot;&quot;, Arrays.asList(new VendorExtension() {
                  @Override
                  public String getName() {
                      return &quot;&quot;;
                  }
  
                  @Override
                  public Object getValue() {
                      return &quot;null&quot;;
                  }
              })));
      }
  
      @Bean
      public WebMvcEndpointHandlerMapping webEndpointServletHandlerMapping(WebEndpointsSupplier webEndpointsSupplier, ServletEndpointsSupplier servletEndpointsSupplier, ControllerEndpointsSupplier controllerEndpointsSupplier, EndpointMediaTypes endpointMediaTypes, CorsEndpointProperties corsProperties, WebEndpointProperties webEndpointProperties, Environment environment) {
          List&lt;ExposableEndpoint&lt;?&gt;&gt; allEndpoints = new ArrayList();
          Collection&lt;ExposableWebEndpoint&gt; webEndpoints = webEndpointsSupplier.getEndpoints();
          allEndpoints.addAll(webEndpoints);
          allEndpoints.addAll(servletEndpointsSupplier.getEndpoints());
          allEndpoints.addAll(controllerEndpointsSupplier.getEndpoints());
          String basePath = webEndpointProperties.getBasePath();
          EndpointMapping endpointMapping = new EndpointMapping(basePath);
          boolean shouldRegisterLinksMapping = this.shouldRegisterLinksMapping(webEndpointProperties, environment, basePath);
          return new WebMvcEndpointHandlerMapping(endpointMapping, webEndpoints, endpointMediaTypes, corsProperties.toCorsConfiguration(), new EndpointLinksResolver(allEndpoints, basePath), shouldRegisterLinksMapping, null);
      }
  
      private boolean shouldRegisterLinksMapping(WebEndpointProperties webEndpointProperties, Environment environment, String basePath) {
          return webEndpointProperties.getDiscovery().isEnabled() &amp;&amp; (StringUtils.hasText(basePath) || ManagementPortType.get(environment).equals(ManagementPortType.DIFFERENT));
      }
  }
  </code></pre>
  <p>Also had to set</p>
  <p><code>spring.mvc.pathmatch.matching-strategy=ant-path-matcher</code></p>