Example usage for org.springframework.restdocs.http HttpDocumentation httpRequest

List of usage examples for org.springframework.restdocs.http HttpDocumentation httpRequest

Introduction

In this page you can find the example usage for org.springframework.restdocs.http HttpDocumentation httpRequest.

Prototype

public static HttpRequestSnippet httpRequest() 

Source Link

Document

Returns a new Snippet that will document the HTTP request for the API operation.

Usage

From source file:capital.scalable.restdocs.misc.SectionSnippetTest.java

@Test
public void customSnippets() throws Exception {
    HandlerMethod handlerMethod = new HandlerMethod(new TestResource(), "getItemById");

    setField(snippet, "expectedType", "section");
    this.snippet.withContents(equalTo("[[resources-customSnippets]]\n" + "=== Get Item By Id\n\n"
            + "include::{snippets}/customSnippets/method-path.adoc[]\n\n"
            + "include::{snippets}/customSnippets/description.adoc[]\n\n" + "==== Example response\n\n"
            + "include::{snippets}/customSnippets/http-response.adoc[]\n\n" + "==== Response fields\n\n"
            + "include::{snippets}/customSnippets/response-fields.adoc[]\n\n" + "==== Example request\n\n"
            + "include::{snippets}/customSnippets/http-request.adoc[]\n"));

    new SectionBuilder().snippetNames(HTTP_RESPONSE, RESPONSE_FIELDS, HTTP_REQUEST).build()
            .document(operationBuilder.attribute(HandlerMethod.class.getName(), handlerMethod).attribute(
                    ATTRIBUTE_NAME_DEFAULT_SNIPPETS,
                    Arrays.asList(pathParameters(), requestParameters(), requestFields(), responseFields(),
                            curlRequest(), HttpDocumentation.httpRequest(), HttpDocumentation.httpResponse()))
                    .request("http://localhost/items/1").build());
}