Omit null properties from actuator endpoint API response examples

Closes gh-11757
pull/11759/head
Andy Wilkinson 7 years ago
parent 41bfe07964
commit 292025936e

@ -56,7 +56,8 @@ import static org.springframework.restdocs.payload.PayloadDocumentation.fieldWit
* @author Andy Wilkinson
*/
@TestPropertySource(properties = { "spring.jackson.serialization.indent_output=true",
"management.endpoints.web.expose=*" })
"management.endpoints.web.expose=*",
"spring.jackson.default-property-inclusion=non_null" })
public class AbstractEndpointDocumentationTests {
protected String describeEnumValues(Class<? extends Enum<?>> enumType) {

@ -31,6 +31,7 @@ import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.restdocs.mockmvc.MockMvcRestDocumentation;
import org.springframework.restdocs.payload.FieldDescriptor;
import org.springframework.restdocs.payload.JsonFieldType;
import static org.springframework.restdocs.payload.PayloadDocumentation.fieldWithPath;
import static org.springframework.restdocs.payload.PayloadDocumentation.responseFields;
@ -80,9 +81,11 @@ public class LiquibaseEndpointDocumentationTests
fieldWithPath("labels")
.description("Labels associated with the change set."),
fieldWithPath("checksum").description("Checksum of the change set."),
fieldWithPath("orderExecuted")
.description("Order of the execution of the change set."),
fieldWithPath("tag").description("Tag associated with the change set."));
fieldWithPath("orderExecuted").description(
"Order of the execution of the change set."),
fieldWithPath("tag")
.description("Tag associated with the change set, if any.")
.optional().type(JsonFieldType.STRING));
}
@Configuration

@ -36,8 +36,7 @@ import org.springframework.web.context.WebApplicationContext;
* @author Andy Wilkinson
*/
@RunWith(SpringRunner.class)
@SpringBootTest(properties = { "spring.jackson.serialization.indent_output=true",
"management.endpoints.web.expose=*" })
@SpringBootTest
public abstract class MockMvcEndpointDocumentationTests
extends AbstractEndpointDocumentationTests {

@ -123,8 +123,8 @@ public class ThreadDumpEndpointDocumentationTests
fieldWithPath("threads.[].lockOwnerName")
.description("Name of the thread that owns the "
+ "object on which the thread is "
+ "blocked.")
.optional(),
+ "blocked, if any.")
.optional().type(JsonFieldType.STRING),
fieldWithPath("threads.[].priority")
.description("Priority of the thread. Only "
+ "available on Java 9 or later.")

Loading…
Cancel
Save