title: Get request body as string/json to validate with a json schema- Spring boot REST API
body: <p>I'm trying to validate JSON (passed by a client as a request body) before it is converted into a model in Controller method.</p>
  <p>If validation passes then return nothing, let the process continue as it was (spring boot to convert JSON into a model marked as @RequestBody). Throw error in case validation fails (<a href="https://github.com/everit-org/json-schema" rel="nofollow noreferrer">everit-org/json-schema</a>).</p>
  <p>I tried to two way:</p>
  <ol>
  <li><p>Implement <code>HandlerMethodArgumentResolver</code>, but <code>resolveArgument()</code> doesn't give request body details as it is already read and stored in <code>ContentCachingRequestWrapper</code>.</p>
  <p>NOTE: <code>inputStream</code> in <code>ContentCachingRequestWrapper</code> doesn't have any request body details.</p>
  </li>
  <li><p>Using <a href="https://stackoverflow.com/questions/10457963/spring-rest-service-retrieving-json-from-request/29005111">spring</a> <code>Interceptor</code>. But this doesn't help me to find request body type passed in the request. As JSON schema is different for each request.</p>
  </li>
  </ol>
  <p>Any other approaches I can try with?</p>