Merge branch '1.2.x'

This commit is contained in:
Andy Wilkinson
2017-07-01 16:30:37 +01:00
5 changed files with 48 additions and 6 deletions

View File

@@ -158,6 +158,20 @@ public class RequestFieldsSnippetTests extends AbstractSnippetTests {
.content("{\"a\": 5, \"b\": 4}").build());
}
@Test
public void allUndocumentedFieldsContinueToBeIgnoredAfterAddingDescriptors()
throws IOException {
this.snippets.expectRequestFields()
.withContents(tableWithHeader("Path", "Type", "Description")
.row("`b`", "`Number`", "Field b")
.row("`c.d`", "`Number`", "Field d"));
new RequestFieldsSnippet(Arrays.asList(fieldWithPath("b").description("Field b")),
true).andWithPrefix("c.", fieldWithPath("d").description("Field d"))
.document(this.operationBuilder.request("http://localhost")
.content("{\"a\":5,\"b\":4,\"c\":{\"d\": 3}}").build());
}
@Test
public void missingOptionalRequestField() throws IOException {
this.snippets.expectRequestFields()

View File

@@ -134,6 +134,21 @@ public class ResponseFieldsSnippetTests extends AbstractSnippetTests {
.content("{\"a\": 5, \"b\": 4}").build());
}
@Test
public void allUndocumentedFieldsContinueToBeIgnoredAfterAddingDescriptors()
throws IOException {
this.snippets.expectResponseFields()
.withContents(tableWithHeader("Path", "Type", "Description")
.row("`b`", "`Number`", "Field b")
.row("`c.d`", "`Number`", "Field d"));
new ResponseFieldsSnippet(
Arrays.asList(fieldWithPath("b").description("Field b")), true)
.andWithPrefix("c.", fieldWithPath("d").description("Field d"))
.document(this.operationBuilder.response()
.content("{\"a\":5,\"b\":4,\"c\":{\"d\": 3}}").build());
}
@Test
public void responseFieldsWithCustomAttributes() throws IOException {
TemplateResourceResolver resolver = mock(TemplateResourceResolver.class);