File tree Expand file tree Collapse file tree 1 file changed +50
-0
lines changed
modules/swagger-core/src/test/java/io/swagger/models Expand file tree Collapse file tree 1 file changed +50
-0
lines changed Original file line number Diff line number Diff line change 1+ package io .swagger .models ;
2+
3+ import io .swagger .util .Json ;
4+ import org .testng .annotations .Test ;
5+
6+ import static org .testng .Assert .assertNull ;
7+ import static org .testng .Assert .assertTrue ;
8+
9+ public class ComposedModelTest {
10+ @ Test
11+ public void testDeserializeComposedModel () throws Exception {
12+ String json = "{\n " +
13+ " \" type\" : \" object\" ,\n " +
14+ " \" allOf\" : [\n " +
15+ " {\n " +
16+ " \" $ref\" : \" #/definitions/Pet\" \n " +
17+ " },\n " +
18+ " {\n " +
19+ " \" $ref\" : \" #/definitions/Furry\" \n " +
20+ " },\n " +
21+ " {\n " +
22+ " \" type\" : \" object\" ,\n " +
23+ " \" properties\" : {\n " +
24+ " \" propInt\" : {\n " +
25+ " \" type\" : \" string\" \n " +
26+ " }\n " +
27+ " }\n " +
28+ " },\n " +
29+ " {\n " +
30+ " \" type\" : \" object\" ,\n " +
31+ " \" properties\" : {\n " +
32+ " \" propEx\" : {\n " +
33+ " \" type\" : \" string\" \n " +
34+ " }\n " +
35+ " }\n " +
36+ " }\n " +
37+ " ]\n " +
38+ "}" ;
39+
40+ Model model = Json .mapper ().readValue (json , Model .class );
41+ assertTrue (model instanceof ComposedModel );
42+ ComposedModel cm = (ComposedModel ) model ;
43+
44+ assertTrue (cm .getAllOf ().size () == 4 );
45+ assertTrue (cm .getAllOf ().get (2 ).getProperties ().containsKey ("propInt" ));
46+ assertTrue (cm .getAllOf ().get (3 ).getProperties ().containsKey ("propEx" ));
47+
48+ assertNull (cm .getProperties ());
49+ }
50+ }
You can’t perform that action at this time.
0 commit comments