title: @EnableWebFlux on a WebFluxConfigurer does autoconfigure a ThymeleafViewResolver as expected
body: <p>I'm building a REST api starting with spring-boot-starter-webflux, but I'd also like the app to serve a swagger UI using a webjar. I need to tweak how the swagger UI initializes, so I've made a @Controller that returns a Mono to trigger rendering the view. The REST api also needs a customized jackson ObjectMapper with the snake case naming strategy enabled, among other things.</p>
  
  <p>The <a href="https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#boot-features-webflux-auto-configuration" rel="nofollow noreferrer">Spring Boot Docs</a> say that to accomplish this I should provide a @Configuration class that extends WebFluxConfigurer, but I should leave @EnableWebflux off. Here is what I have so far (Kotlin):</p>
  
  <p>Config</p>
  
  <pre class="lang-kotlin prettyprint-override"><code>@Configuration
  @ComponentScan
  class CommonConfig : WebFluxConfigurer {
  
      override fun configureHttpMessageCodecs(configurer: ServerCodecConfigurer) {
          configurer.defaultCodecs().jackson2JsonDecoder(
                  Jackson2JsonDecoder(objectMapper())
          )
          configurer.defaultCodecs().jackson2JsonEncoder(
                  Jackson2JsonEncoder(objectMapper())
          )
      }
  
      private fun objectMapper() = Jackson2ObjectMapperBuilder
              .json()
              .propertyNamingStrategy(PropertyNamingStrategy.SNAKE_CASE)
              .featuresToDisable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS)
              .build&lt;ObjectMapper&gt;().also {
                  it.configOverride(BigDecimal::class.java).format = JsonFormat.Value.forShape(JsonFormat.Shape.STRING)
              }
  }
  </code></pre>
  
  <p>Controller</p>
  
  <pre class="lang-kotlin prettyprint-override"><code>@Controller
  class SwaggerController(
          val swaggerConfig: SwaggerConfig
  ) {
      @GetMapping("/swagger-ui")
      fun swagger(model: Model): Mono&lt;String&gt; {
  
          model.addAttribute("docUrl", swaggerConfig.docUrl)
          return Mono.just("swagger-ui")
      }
  }
  </code></pre>
  
  <p>With this configuration, the swagger view renders fine, but when I try to post to one of my api endpoints, it complains about missing required properties (which is resolved by sending data with camel case instead of the snake case that I want). If I add @EnableWebFlux to my CommonConfig class, the custom object mapper gets picked up and I can send snake case data, but then the swagger view does not render. I get:</p>
  
  <pre><code>java.lang.IllegalStateException: Could not resolve view with name 'swagger-ui'.
      at org.springframework.web.reactive.result.view.ViewResolutionResultHandler.lambda$resolveViews$3(ViewResolutionResultHandler.java:278) ~[spring-webflux-5.2.5.RELEASE.jar:5.2.5.RELEASE]
      Suppressed: reactor.core.publisher.FluxOnAssembly$OnAssemblyException:
  </code></pre>
  
  <p>This is presumably because there is no thymeleaf ViewResolver registered.</p>
  
  <p>The docs do say that if I want to "take complete control of Spring WebFlux, you can add your own @Configuration annotated with @EnableWebFlux", which explains why there's no ViewResolver. But this isn't what I want. I want most of the webflux autoconfiguration, but I want to provide my own customized ObjectMapper. What is the correct way to do this?</p>