public class RestDocumentationResultHandler extends Object implements ResultHandler
ResultHandler for documenting RESTful APIs.MockMvcRestDocumentation.document(String, Snippet...)| Modifier and Type | Method and Description |
|---|---|
RestDocumentationResultHandler |
document(Snippet... snippets)
Creates a new
RestDocumentationResultHandler to be passed into
ResultActions.andDo(ResultHandler) that will produce documentation using
the given snippets. |
protected RestDocumentationGenerator<MockHttpServletRequest,MockHttpServletResponse> |
getDelegate()
Returns the
RestDocumentationGenerator that is used as a delegate. |
void |
handle(MvcResult result) |
RestDocumentationResultHandler |
snippets(Snippet... snippets)
Deprecated.
since 1.1 in favor of
document(Snippet...) and passing the
return value into ResultActions.andDo(ResultHandler) |
public void handle(MvcResult result) throws Exception
handle in interface ResultHandlerException@Deprecated public RestDocumentationResultHandler snippets(Snippet... snippets)
document(Snippet...) and passing the
return value into ResultActions.andDo(ResultHandler)snippets such that they are documented when this result
handler is called.snippets - the snippets to addRestDocumentationResultHandlerpublic RestDocumentationResultHandler document(Snippet... snippets)
RestDocumentationResultHandler to be passed into
ResultActions.andDo(ResultHandler) that will produce documentation using
the given snippets. For example:
this.mockMvc.perform(MockMvcRequestBuilders.get("/search"))
.andExpect(status().isOk())
.andDo(this.documentationHandler.document(responseFields(
fieldWithPath("page").description("The requested Page")
));
snippets - the snippetsprotected final RestDocumentationGenerator<MockHttpServletRequest,MockHttpServletResponse> getDelegate()
RestDocumentationGenerator that is used as a delegate.