springmvc - Fails to Validate Request Unless Request Wrapper is Specific Type

Issue #402 new
Ryan Daniels created an issue

In using Spring Boot, there are many types of filters that can wrap requests. For example, as part of Spring HATEOAS, it has a filter for dealing with X-Forwarded-* headers that has its own wrapper:

https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/web/filter/ForwardedHeaderFilter.html

When this is in place, validation does not happen because in OpenApiValidationInterceptor:

(servletRequest instanceof ContentCachingRequestWrapper || servletRequest instanceof ResettableRequestServletWrapper)

This should not prevent validation from executing.

Comments (3)

  1. Ryan Daniels reporter

    I was able to get around the issue by using @Order:

        @Bean
        @Order(Ordered.LOWEST_PRECEDENCE)
        Filter openApiValidationFilter() {
    

  2. Sven Döring

    That is the correct way to solve this issue. And yes, it would fit good into the documentation.

  3. Log in to comment