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 ;
25
+ import java .util .Optional ;
30
26
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 ;
27
+ import io .swagger .v3 .core .converter .ModelConverter ;
28
+ import io .swagger .v3 .core .converter .ModelConverters ;
29
+ import org .junit .jupiter .api .BeforeAll ;
37
30
import org .junit .jupiter .api .Test ;
38
- import org .springdoc .core .providers .ObjectMapperProvider ;
31
+ import org .springdoc .core .converters .PageOpenAPIConverter ;
32
+ import org .springdoc .core .converters .SchemaPropertyDeprecatingConverter ;
39
33
import org .springdoc .core .utils .Constants ;
34
+ import test .org .springdoc .api .AbstractSpringDocTest ;
40
35
41
- import org .springframework .beans .factory .annotation .Autowired ;
42
- import org .springframework .boot .SpringBootConfiguration ;
43
36
import org .springframework .boot .autoconfigure .SpringBootApplication ;
44
- import org .springframework .data .web .config .EnableSpringDataWebSupport ;
45
- import test .org .springdoc .api .AbstractSpringDocTest ;
46
37
47
38
import static org .hamcrest .Matchers .is ;
48
39
import static org .springframework .test .web .servlet .request .MockMvcRequestBuilders .get ;
49
- import static org .springframework .test .web .servlet .result .MockMvcResultMatchers .*;
40
+ import static org .springframework .test .web .servlet .result .MockMvcResultMatchers .content ;
41
+ import static org .springframework .test .web .servlet .result .MockMvcResultMatchers .jsonPath ;
42
+ import static org .springframework .test .web .servlet .result .MockMvcResultMatchers .status ;
50
43
51
44
public class SpringDocApp10NotSpecifiedTest extends AbstractSpringDocTest {
52
45
53
- private final Map <ClassKey , Class <?>> springMixins = new HashMap <>();
54
46
55
- @ Autowired
56
- ObjectMapperProvider objectMapperProvider ;
47
+ @ BeforeAll
48
+ public static void init () {
49
+ Optional <ModelConverter > pageOpenAPIConverter =
50
+ ModelConverters .getInstance ().getConverters ()
51
+ .stream ().filter (modelConverter -> modelConverter instanceof PageOpenAPIConverter ).findAny ();
52
+ pageOpenAPIConverter .ifPresent (ModelConverters .getInstance ()::removeConverter );
53
+ }
57
54
58
55
@ Override
59
56
@ Test
@@ -69,29 +66,4 @@ public static class SpringDocTestApp {
69
66
70
67
}
71
68
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
- }
97
69
}
0 commit comments