22
22
23
23
package test .org .springdoc .api .app10 ;
24
24
25
+ import java .lang .reflect .Field ;
26
+ import java .util .HashMap ;
27
+ import java .util .Iterator ;
28
+ import java .util .Map ;
29
+ import java .util .Map .Entry ;
30
+
31
+ import com .fasterxml .jackson .databind .ObjectMapper ;
32
+ import com .fasterxml .jackson .databind .introspect .SimpleMixInResolver ;
33
+ import com .fasterxml .jackson .databind .type .ClassKey ;
34
+ import org .apache .commons .lang3 .reflect .FieldUtils ;
35
+ import org .junit .jupiter .api .AfterEach ;
36
+ import org .junit .jupiter .api .BeforeEach ;
25
37
import org .junit .jupiter .api .Test ;
38
+ import org .springdoc .core .providers .ObjectMapperProvider ;
26
39
import org .springdoc .core .utils .Constants ;
40
+
41
+ import org .springframework .beans .factory .annotation .Autowired ;
27
42
import org .springframework .boot .SpringBootConfiguration ;
28
43
import org .springframework .boot .autoconfigure .SpringBootApplication ;
29
44
import org .springframework .data .web .config .EnableSpringDataWebSupport ;
35
50
36
51
public class SpringDocApp10NotSpecifiedTest extends AbstractSpringDocTest {
37
52
53
+ private final Map <ClassKey , Class <?>> springMixins = new HashMap <>();
54
+
55
+ @ Autowired
56
+ ObjectMapperProvider objectMapperProvider ;
57
+
38
58
@ Override
39
59
@ Test
40
60
public void testApp () throws Exception {
@@ -49,4 +69,29 @@ public static class SpringDocTestApp {
49
69
50
70
}
51
71
72
+ @ BeforeEach
73
+ void init () throws IllegalAccessException {
74
+ Field convertersField2 = FieldUtils .getDeclaredField (ObjectMapper .class , "_mixIns" , true );
75
+ SimpleMixInResolver _mixIns = (SimpleMixInResolver ) convertersField2 .get (objectMapperProvider .jsonMapper ());
76
+ Field convertersField3 = FieldUtils .getDeclaredField (SimpleMixInResolver .class , "_localMixIns" , true );
77
+ Map <ClassKey , Class <?>> _localMixIns = (Map <ClassKey , Class <?>>) convertersField3 .get (_mixIns );
78
+ Iterator <Entry <ClassKey , Class <?>>> it = _localMixIns .entrySet ().iterator ();
79
+ while (it .hasNext ()) {
80
+ Entry <ClassKey , Class <?>> entry = it .next ();
81
+ if (entry .getKey ().toString ().startsWith ("org.springframework" )) {
82
+ springMixins .put (entry .getKey (), entry .getValue ());
83
+ it .remove ();
84
+ }
85
+ }
86
+
87
+ }
88
+
89
+ @ AfterEach
90
+ void clean () throws IllegalAccessException {
91
+ Field convertersField2 = FieldUtils .getDeclaredField (ObjectMapper .class , "_mixIns" , true );
92
+ SimpleMixInResolver _mixIns = (SimpleMixInResolver ) convertersField2 .get (objectMapperProvider .jsonMapper ());
93
+ Field convertersField3 = FieldUtils .getDeclaredField (SimpleMixInResolver .class , "_localMixIns" , true );
94
+ Map <ClassKey , Class <?>> _localMixIns = (Map <ClassKey , Class <?>>) convertersField3 .get (_mixIns );
95
+ _localMixIns .putAll (springMixins );
96
+ }
52
97
}
0 commit comments