22
22
*/
23
23
package test .org .springdoc .api .app138 ;
24
24
25
+ import java .lang .reflect .Field ;
25
26
import java .util .HashMap ;
26
27
import java .util .LinkedHashMap ;
27
28
import java .util .Map ;
28
29
30
+ import com .fasterxml .jackson .databind .ObjectMapper ;
31
+ import io .swagger .v3 .core .util .Json ;
32
+ import io .swagger .v3 .core .util .ObjectMapperFactory ;
29
33
import io .swagger .v3 .oas .models .OpenAPI ;
34
+ import org .apache .commons .lang3 .reflect .FieldUtils ;
30
35
import org .junit .jupiter .api .Assertions ;
36
+ import org .junit .jupiter .api .BeforeEach ;
31
37
import org .junit .jupiter .api .Test ;
32
38
import org .springdoc .core .Constants ;
33
39
import test .org .springdoc .api .AbstractSpringDocTest ;
49
55
@ TestPropertySource (properties = "springdoc.writer-with-order-by-keys=true" )
50
56
public class SpringDocApp138Test extends AbstractSpringDocTest {
51
57
58
+ @ BeforeEach
59
+ void init () throws IllegalAccessException {
60
+ Field conField = FieldUtils .getDeclaredField (Json .class , "mapper" , true );
61
+ ObjectMapper mapper = SpringDocObjectMapperFactory .createJson ();
62
+ conField .set (mapper , mapper );
63
+ }
64
+
65
+ private static class SpringDocObjectMapperFactory extends ObjectMapperFactory {
66
+ protected static ObjectMapper createJson () {
67
+ return ObjectMapperFactory .createJson ();
68
+ }
69
+ }
70
+
52
71
@ SpringBootApplication
53
72
static class SpringDocTestApp {
54
73
@ Bean
@@ -68,6 +87,7 @@ private static Map<String, Object> apiExtensions() {
68
87
extensions .put ("x-my-vendor-extensions" , linkedMap );
69
88
return extensions ;
70
89
}
90
+
71
91
@ Test
72
92
public void testApp () throws Exception {
73
93
MvcResult mockMvcResult = mockMvc .perform (MockMvcRequestBuilders .get (Constants .DEFAULT_API_DOCS_URL )).andExpect (status ().isOk ())
@@ -76,4 +96,5 @@ public void testApp() throws Exception {
76
96
String expected = getContent ("results/app138.json" );
77
97
Assertions .assertEquals (expected , result );
78
98
}
99
+
79
100
}
0 commit comments