|
26 | 26 | import com.fasterxml.jackson.databind.ObjectMapper;
|
27 | 27 | import com.fasterxml.jackson.databind.SerializationFeature;
|
28 | 28 |
|
| 29 | +import org.springframework.beans.BeansException; |
| 30 | +import org.springframework.beans.factory.config.BeanPostProcessor; |
29 | 31 | import org.springframework.boot.actuate.autoconfigure.endpoint.EndpointAutoConfiguration;
|
| 32 | +import org.springframework.boot.actuate.autoconfigure.endpoint.jackson.JacksonEndpointAutoConfiguration; |
30 | 33 | import org.springframework.boot.actuate.autoconfigure.endpoint.web.WebEndpointAutoConfiguration;
|
31 | 34 | import org.springframework.boot.actuate.autoconfigure.endpoint.web.reactive.WebFluxEndpointManagementContextConfiguration;
|
32 | 35 | import org.springframework.boot.actuate.autoconfigure.endpoint.web.servlet.WebMvcEndpointManagementContextConfiguration;
|
| 36 | +import org.springframework.boot.actuate.endpoint.jackson.EndpointObjectMapper; |
33 | 37 | import org.springframework.boot.autoconfigure.ImportAutoConfiguration;
|
34 | 38 | import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
|
35 | 39 | import org.springframework.boot.autoconfigure.http.HttpMessageConvertersAutoConfiguration;
|
|
38 | 42 | import org.springframework.boot.autoconfigure.web.reactive.WebFluxAutoConfiguration;
|
39 | 43 | import org.springframework.boot.autoconfigure.web.servlet.DispatcherServletAutoConfiguration;
|
40 | 44 | import org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration;
|
| 45 | +import org.springframework.context.annotation.Bean; |
41 | 46 | import org.springframework.context.annotation.Configuration;
|
42 | 47 | import org.springframework.restdocs.operation.preprocess.ContentModifyingOperationPreprocessor;
|
43 | 48 | import org.springframework.restdocs.operation.preprocess.OperationPreprocessor;
|
|
54 | 59 | *
|
55 | 60 | * @author Andy Wilkinson
|
56 | 61 | */
|
57 |
| -@TestPropertySource(properties = { "spring.jackson.serialization.indent_output=true", |
58 |
| - "management.endpoints.web.exposure.include=*", "spring.jackson.default-property-inclusion=non_null" }) |
| 62 | +@TestPropertySource(properties = { "management.endpoints.web.exposure.include=*" }) |
59 | 63 | public abstract class AbstractEndpointDocumentationTests {
|
60 | 64 |
|
61 | 65 | protected static String describeEnumValues(Class<? extends Enum<?>> enumType) {
|
@@ -119,9 +123,26 @@ private <T> List<Object> select(List<Object> candidates, Predicate<T> filter) {
|
119 | 123 | WebMvcAutoConfiguration.class, DispatcherServletAutoConfiguration.class, EndpointAutoConfiguration.class,
|
120 | 124 | WebEndpointAutoConfiguration.class, WebMvcEndpointManagementContextConfiguration.class,
|
121 | 125 | WebFluxEndpointManagementContextConfiguration.class, PropertyPlaceholderAutoConfiguration.class,
|
122 |
| - WebFluxAutoConfiguration.class, HttpHandlerAutoConfiguration.class }) |
| 126 | + WebFluxAutoConfiguration.class, HttpHandlerAutoConfiguration.class, |
| 127 | + JacksonEndpointAutoConfiguration.class }) |
123 | 128 | static class BaseDocumentationConfiguration {
|
124 | 129 |
|
| 130 | + @Bean |
| 131 | + static BeanPostProcessor endpointObjectMapperBeanPostProcessor() { |
| 132 | + return new BeanPostProcessor() { |
| 133 | + |
| 134 | + @Override |
| 135 | + public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException { |
| 136 | + if (bean instanceof EndpointObjectMapper) { |
| 137 | + return (EndpointObjectMapper) () -> ((EndpointObjectMapper) bean).get() |
| 138 | + .enable(SerializationFeature.INDENT_OUTPUT); |
| 139 | + } |
| 140 | + return bean; |
| 141 | + } |
| 142 | + |
| 143 | + }; |
| 144 | + } |
| 145 | + |
125 | 146 | }
|
126 | 147 |
|
127 | 148 | }
|
0 commit comments