diff --git a/spring-restdocs-core/src/test/java/org/springframework/restdocs/payload/ResponseFieldsSnippetTests.java b/spring-restdocs-core/src/test/java/org/springframework/restdocs/payload/ResponseFieldsSnippetTests.java index a7f2f047e..294f40283 100644 --- a/spring-restdocs-core/src/test/java/org/springframework/restdocs/payload/ResponseFieldsSnippetTests.java +++ b/spring-restdocs-core/src/test/java/org/springframework/restdocs/payload/ResponseFieldsSnippetTests.java @@ -378,6 +378,23 @@ public void mapResponseWithVaryingKeysMatchedUsingWildcard() throws IOException .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;