Add a test that shows problem with sometimes null field within an array

Closes gh-399
This commit is contained in:
Nakul Chaudhari
2017-06-06 16:42:52 +02:00
committed by Andy Wilkinson
parent dff9062a32
commit 288ebf771a

View File

@@ -378,6 +378,23 @@ public class ResponseFieldsSnippetTests extends AbstractSnippetTests {
.build());
}
@Test
public void responseWithSomeNullOcurrencesOfAField() throws IOException {
this.snippets.expectResponseFields()
.withContents(tableWithHeader("Path", "Type", "Description")
.row("`assets[].name`", "`String`", "one"));
new ResponseFieldsSnippet(Arrays.asList(
fieldWithPath("assets[].name").description("one")))
.document(this.operationBuilder.response()
.content(
"{\"assets\": [" +
"{\"name\": \"sample1\"}, " +
"{\"name\": null}, " +
"{\"name\": \"sample2\"}]}")
.build());
}
private String escapeIfNecessary(String input) {
if (this.templateFormat.equals(TemplateFormats.markdown())) {
return input;