Polishing
This commit is contained in:
@@ -75,18 +75,13 @@ public abstract class AbstractHeadersSnippet extends TemplatedSnippet {
|
|||||||
|
|
||||||
private void validateHeaderDocumentation(Operation operation) {
|
private void validateHeaderDocumentation(Operation operation) {
|
||||||
List<HeaderDescriptor> missingHeaders = findMissingHeaders(operation);
|
List<HeaderDescriptor> missingHeaders = findMissingHeaders(operation);
|
||||||
|
|
||||||
if (!missingHeaders.isEmpty()) {
|
if (!missingHeaders.isEmpty()) {
|
||||||
String message = "";
|
List<String> names = new ArrayList<String>();
|
||||||
if (!missingHeaders.isEmpty()) {
|
for (HeaderDescriptor headerDescriptor : missingHeaders) {
|
||||||
List<String> names = new ArrayList<String>();
|
names.add(headerDescriptor.getName());
|
||||||
for (HeaderDescriptor headerDescriptor : missingHeaders) {
|
|
||||||
names.add(headerDescriptor.getName());
|
|
||||||
}
|
|
||||||
message += "Headers with the following names were not found in the "
|
|
||||||
+ this.type + ": " + names;
|
|
||||||
}
|
}
|
||||||
throw new SnippetException(message);
|
throw new SnippetException("Headers with the following names were not found"
|
||||||
|
+ " in the " + this.type + ": " + names);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -400,30 +400,6 @@ public class MockMvcRestDocumentationIntegrationTests {
|
|||||||
"$ curl 'http://localhost:8080/custom/' -i -H 'Accept: application/json'"))));
|
"$ curl 'http://localhost:8080/custom/' -i -H 'Accept: application/json'"))));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void stackOverflowQuestion() throws Exception {
|
|
||||||
MockMvc mockMvc = MockMvcBuilders.webAppContextSetup(this.context)
|
|
||||||
.apply(documentationConfiguration(this.restDocumentation)).build();
|
|
||||||
|
|
||||||
mockMvc.perform(get("/company/5").accept(MediaType.APPLICATION_JSON))
|
|
||||||
.andExpect(status().isOk())
|
|
||||||
.andDo(document(
|
|
||||||
"company",
|
|
||||||
responseFields(
|
|
||||||
fieldWithPath("companyName").description(
|
|
||||||
"The name of the company"),
|
|
||||||
fieldWithPath("employee").description(
|
|
||||||
"An array of the company's employees"))))
|
|
||||||
.andDo(document(
|
|
||||||
"employee",
|
|
||||||
responseFields(
|
|
||||||
fieldWithPath("companyName").ignored(),
|
|
||||||
fieldWithPath("employee[].name").description(
|
|
||||||
"The name of the employee"),
|
|
||||||
fieldWithPath("employee[].age").description(
|
|
||||||
"The age of the employee"))));
|
|
||||||
}
|
|
||||||
|
|
||||||
private void assertExpectedSnippetFilesExist(File directory, String... snippets) {
|
private void assertExpectedSnippetFilesExist(File directory, String... snippets) {
|
||||||
for (String snippet : snippets) {
|
for (String snippet : snippets) {
|
||||||
assertTrue(new File(directory, snippet).isFile());
|
assertTrue(new File(directory, snippet).isFile());
|
||||||
|
|||||||
Reference in New Issue
Block a user