Improve message when fields cannot be documented due to empty body
Closes gh-278
This commit is contained in:
@@ -99,6 +99,17 @@ public class RequestFieldsSnippetFailureTests {
|
||||
.content("{ \"a\": { \"c\": 5 }}").build());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void attemptToDocumentFieldsWithNoRequestBody() throws IOException {
|
||||
this.thrown.expect(SnippetException.class);
|
||||
this.thrown.expectMessage(
|
||||
equalTo("Cannot document request fields as the request body is empty"));
|
||||
new RequestFieldsSnippet(Arrays.asList(fieldWithPath("a").description("one")))
|
||||
.document(new OperationBuilder("no-request-body",
|
||||
this.snippet.getOutputDirectory()).request("http://localhost")
|
||||
.build());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void undocumentedXmlRequestField() throws IOException {
|
||||
this.thrown.expect(SnippetException.class);
|
||||
|
||||
@@ -50,6 +50,17 @@ public class ResponseFieldsSnippetFailureTests {
|
||||
@Rule
|
||||
public ExpectedException thrown = ExpectedException.none();
|
||||
|
||||
@Test
|
||||
public void attemptToDocumentFieldsWithNoResponseBody() throws IOException {
|
||||
this.thrown.expect(SnippetException.class);
|
||||
this.thrown.expectMessage(
|
||||
equalTo("Cannot document response fields as the response body is empty"));
|
||||
new ResponseFieldsSnippet(Arrays.asList(fieldWithPath("a").description("one")))
|
||||
.document(new OperationBuilder("no-response-body",
|
||||
this.snippet.getOutputDirectory()).request("http://localhost")
|
||||
.build());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void undocumentedXmlResponseField() throws IOException {
|
||||
this.thrown.expect(SnippetException.class);
|
||||
|
||||
Reference in New Issue
Block a user