2222
2323package test .org .springdoc .api .app10 ;
2424
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 ;
2537import org .junit .jupiter .api .Test ;
38+ import org .springdoc .core .providers .ObjectMapperProvider ;
2639import org .springdoc .core .utils .Constants ;
40+
41+ import org .springframework .beans .factory .annotation .Autowired ;
2742import org .springframework .boot .SpringBootConfiguration ;
2843import org .springframework .boot .autoconfigure .SpringBootApplication ;
2944import org .springframework .data .web .config .EnableSpringDataWebSupport ;
3550
3651public class SpringDocApp10NotSpecifiedTest extends AbstractSpringDocTest {
3752
53+ private final Map <ClassKey , Class <?>> springMixins = new HashMap <>();
54+
55+ @ Autowired
56+ ObjectMapperProvider objectMapperProvider ;
57+
3858 @ Override
3959 @ Test
4060 public void testApp () throws Exception {
@@ -49,4 +69,29 @@ public static class SpringDocTestApp {
4969
5070 }
5171
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+ }
5297}
0 commit comments