From b1a6840b528e1cd7557fa135100ca1394578640b Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Wed, 22 Jul 2015 15:06:29 +0100 Subject: [PATCH] Test that a response that is an array of primitives can be documented Closes gh-96 --- .../restdocs/payload/PayloadDocumentationTests.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/spring-restdocs/src/test/java/org/springframework/restdocs/payload/PayloadDocumentationTests.java b/spring-restdocs/src/test/java/org/springframework/restdocs/payload/PayloadDocumentationTests.java index 7e99a145..c96afe0d 100644 --- a/spring-restdocs/src/test/java/org/springframework/restdocs/payload/PayloadDocumentationTests.java +++ b/spring-restdocs/src/test/java/org/springframework/restdocs/payload/PayloadDocumentationTests.java @@ -120,6 +120,18 @@ public class PayloadDocumentationTests { fieldWithPath("[]a").description("three")).handle(result(response)); } + @Test + public void arrayResponse() throws IOException { + this.snippet.expectResponseFields("array-response").withContents( // + tableWithHeader("Path", "Type", "Description") // + .row("[]", "String", "one")); + + MockHttpServletResponse response = new MockHttpServletResponse(); + response.getWriter().append("[\"a\", \"b\", \"c\"]"); + documentResponseFields("array-response", fieldWithPath("[]").description("one")) + .handle(result(response)); + } + @Test public void undocumentedRequestField() throws IOException { this.thrown.expect(SnippetGenerationException.class);