Add support for documenting HTTP headers

This commit adds support for documenting HTTP headers in both requests
and responses.

Closes gh-140
This commit is contained in:
andreasevers
2015-09-20 12:44:33 +02:00
committed by Andy Wilkinson
parent 5a010160a1
commit 48f4d1343a
18 changed files with 897 additions and 1 deletions

View File

@@ -18,6 +18,8 @@ package com.example.notes;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.notNullValue;
import static org.springframework.restdocs.headers.HeaderDocumentation.headerWithName;
import static org.springframework.restdocs.headers.HeaderDocumentation.responseHeaders;
import static org.springframework.restdocs.hypermedia.HypermediaDocumentation.linkWithRel;
import static org.springframework.restdocs.hypermedia.HypermediaDocumentation.links;
import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document;
@@ -98,6 +100,15 @@ public class ApiDocumentation {
.alwaysDo(this.document)
.build();
}
@Test
public void headersExample() throws Exception {
this.document.snippets(responseHeaders(
headerWithName("Content-Type").description("The Content-Type of the payload, e.g. `application/hal+json`")));
this.mockMvc.perform(get("/"))
.andExpect(status().isOk());
}
@Test
public void errorExample() throws Exception {