title: Utilize Spring Restdocs DSL for validation
body: <p>our REST API is documented by set of tests using Spring Restdocs in standard way (via <code>mockMvc.perform(...)...andDo(document().fieldWithPath(...))</code> statement. Since fields have type and mandatory/optional flag, I play with idea to reuse this info for purpose of response body validation also in production code.</p>
  
  <p>I moved Spring Restdocs to <code>compile</code> Maven scope and moved snippet creation to production code where it is visible for both the documenting test and response body interceptor in src/main code (the latter just calls <code>ResponseFieldsSnippet.createModel</code> method). Everything works fine except following pitfall: empty collection of objects looks like invalid since framework tries to match <code>fieldWithPath</code> rule of object field against nonexistent data.</p>
  
  <p>For example, assuming JSON of cat is described as <code>fieldWithPath("kittens[]"), fieldWithPath("kittens[].name")</code>, the actual JSON <code>{"kittens":[]}</code> appears invalid since the latter descriptor is not satisfied. This doesn't happen for test samples where data is fabricated to maximize documentation benefit but it's issue for real cases.</p>
  
  <p>Based on this observation, I tend to consider reusing Restdocs DSL for validation as a bad idea. Before switching to heavy-weight solution á la JSON schema, I would like to ask: does Restdocs offer some way to express field descriptors as tree rather than list of rules? For example above, something like <code>fieldWithPath("kittens[]", subfieldWithPath("name"))</code>. (I think it could be useful regardless of how abusing is my case.)</p>
  
  <p>I browsed and elaborated examples from documentation which seemed promising but AFAIK don't actually cover this case, namely: subsectionWithPath (which skips subtree), beneathPath (which focuses only to subtree) or <code>ResponseFieldsSnippet.andWithPrefix</code> (only shortcut for list creation but still list not tree).</p>
  
  <p>Thanks for your opinion!</p>