public class OpenApiValidationFilter
extends org.springframework.web.filter.OncePerRequestFilter
HttpServletRequest into a ResettableRequestServletWrapper
which has the ability to reset its ServletInputStream.
Wrapping is necessary for the validation.
The Swagger Request Validator needs the pure request body for its validation. Additionally the Spring
RestController / Controller
needs the pure request body to unmarshal the JSON.
But a ServletInputStream can only be read once and needs to be rewind after
successful validation against the OpenAPI / Swagger definition. So the controller can then access it again.
| Constructor and Description |
|---|
OpenApiValidationFilter()
Creates a
OpenApiValidationFilter which validates incoming requests. |
OpenApiValidationFilter(boolean validateRequests,
boolean validateResponses)
Creates a
OpenApiValidationFilter which validates incoming requests and / or responses. |
| Modifier and Type | Method and Description |
|---|---|
protected void |
doFilterInternal(javax.servlet.http.HttpServletRequest servletRequest,
javax.servlet.http.HttpServletResponse servletResponse,
javax.servlet.FilterChain filterChain) |
doFilter, getAlreadyFilteredAttributeName, isAsyncDispatch, isAsyncStarted, shouldNotFilter, shouldNotFilterAsyncDispatch, shouldNotFilterErrorDispatchpublic OpenApiValidationFilter()
OpenApiValidationFilter which validates incoming requests.public OpenApiValidationFilter(boolean validateRequests,
boolean validateResponses)
OpenApiValidationFilter which validates incoming requests and / or responses.validateRequests - will enable request validation if truevalidateResponses - will enable response validation if trueprotected void doFilterInternal(javax.servlet.http.HttpServletRequest servletRequest,
javax.servlet.http.HttpServletResponse servletResponse,
javax.servlet.FilterChain filterChain)
throws javax.servlet.ServletException,
IOException
doFilterInternal in class org.springframework.web.filter.OncePerRequestFilterjavax.servlet.ServletExceptionIOExceptionCopyright © 2016–2019 Atlassian. All rights reserved.